Star Rating System:免费的PHP/MySQL评级系统

| 收藏本文 下载本文 作者:小烨啊小烨

以下是小编帮大家整理的Star Rating System:免费的PHP/MySQL评级系统(共含6篇),供大家参考借鉴,希望可以帮助到您。同时,但愿您也能像本文投稿人“小烨啊小烨”一样,积极向本站投稿分享好文章。

Star Rating System:免费的PHP/MySQL评级系统

篇1:Star Rating System:免费的PHP/MySQL评级系统

Star Rating System是一个免费的PHP脚本,可以用来为网站添加Ajax评级功能,

它使用MySQL来存储数据,界面可使用CSS进行样式化,

它支持多套样式模板,你可以选择是否激活Ajax,另外,还可以实现,使用button按钮的形式评级,以星形呈现评级结果等。

本文出自:parandroid.com/free-php-rating-system/

篇2:PHP,Mysql日期和时间

工作中mysql使用的时间是一个UNIX时间戳:从1970年1月1日0点开始到当前时间的秒数,由于是int类型,很方便的适用于计算机处理,不仅仅是php和mysql的数据交互的一种格式,在各种客户端,也是数据交互的标准(android/IOS)等,因此如果只是保存和显示日期的时候,应该使用UNIX时间戳来计算日期和做为标准的日期格式,

工作中常用的流程是:将HTML页面的时间转化为时间戳保存到mysql中,从mysql中取出时间戳格式化展示在web或手机客户端。总之mysql中保存的时间是UNIX时间戳,然后被PHP格式化为合适的时间

介绍几个常用的函数

1.date,2.mktime(),3.getdate(),4.strftime()

1.date()

PHP中获取时间和日期

使用date()函数:将时间戳或当前时间转化成格式化的字符串,例如:

echo date('Y-i-s');//输出-3-25

2.mktime()

使用mktime()将时间转化成UNIX时间戳

$timestamp = mktime();

获取当前时间戳有三种方法:

mktime(),time(),date('U')

mktime做时间运算

mktime(12,0,0,$mon,$day+10,$year);十天以后的时间戳

3.getdate()函数:

$today = getdate();

print_r($today);

//输出

Array

(

[seconds] => 38

[minutes] => 38

[hours] => 22

[mday] => 25

[wday] => 2

[mon] => 3

[year] => 2014

[yday] => 83

[weekday] => Tuesday

[month] => March

[0] => 1395758318

)

使用checkdate()函数检验日期有效性

4.strftime()

格式化时间戳

mysql格式化时间

1.DATE_FORMAT()

2.UNIX_TIMESTAMP()返回格式化成UNIX时间戳的日期,例如:SELECT UNIX_TIMESTAMP(date) FROM table,这样就可以在PHP中处理了

PHP中格式化时间的函数比较少,介绍几个常用的格式化时间函数

/**

*

*将timestamp时间转化为x时x分x秒

*

*/

public static function getTimeLong($seconds) {

if (!$seconds) {

return '0秒';

}

$ret = '';

if ($seconds >= 3600) {

$hours = (int)($seconds / 3600);

$seconds = $seconds % 3600;

if ($hours) {

$ret .= ($hours . '时');

}

}

if ($seconds >= 60) {

$mi = (int)($seconds / 60);

$seconds = $seconds % 60;

if ($mi) {

$ret .= ($mi . '分');

}

}

if ($seconds) {

$ret .= ($seconds . '秒');

}

return $ret;

}

/**

* 将相差timestamp转为如“1分钟前”,“3天前”等形式

*

* @param timestamp $ts_diff 当前时间 - 要格式化的timestamp

*/

public static function formatTime($ts_diff)

{

if ($ts_diff <=0)

{

return date('Y-m-d');

}

else if ( $ts_diff <= 3600 )

{

return max(1, (int)($ts_diff/60)) . '分钟前';

}

else if ( $ts_diff <= 86400 )

{

return ((int)($ts_diff/3600)) . '小时前';

}

else

{

return ((int)($ts_diff/86400)) . '天前';

}

}

/** 将数字星期转换成字符串星期 weekNum2String($num)

* @param int

* @return string

*/

public static function weekNum2String($num){

switch($num){

case 1:

return '星期一';

case 2:

return '星期二';

case 3:

return '星期三';

case 4:

return '星期四';

case 5:

return '星期五';

case 6:

return '星期六';

case 7:

return '星期日';

default:

return '未知';

}

}

篇3:PHP如何与mysql建立链接

PHP如何与mysql建立链接

php.ini 加载mysql组件:

extension=php_mysql.dll 前的; 去掉

extension_dir = ” ” 路径是否正确

PHP链接mysql函数

mysql_connect: 开启 MySQL 链接

mysql_select_db: 打开一个数据库

@ 和 or die 隐藏错误 和 条件显示

mysql_connect(“主机”, “用户名”, “密码”)

mysql_select_db(“打开数据库”,连接标识符);

如果不特别声明连接标识符,则默认为是上一次打开的连接,

PHP如何删除一个Cookie值

删除一个Cookie值,可以把过期日期设置到一个已经过去的.时间

代码如下:

// set the expiration date to one hour ago

setcookie(“user”, “”, time()-3600);

?>

// 设置过期时间会一个小时之前

setcookie(“user”, “”, time()-3600);

?>

PHP如何去执行一个SQL语句

mysql_query (SQL语句 ,连接标识符);

说明:mysql_query用来根据连接标识符向该数据库服务器的当前数据库发送查询,

如果连接标识符默认,则默认为是上一次打开的连接,

返回值:成功后返回一个结果标识符,失败时返回false。

$sql = “SELECT * FROM test”;

$result = @ mysql_query($sql, $conn) or die(mysql_error());

篇4:Mysql入门系列:PHP基础MySQL综合

PHP 的基本功能就是解释一个脚本,来生成发送到客户机的Web 页面,具有代表性的是,脚本包括逐字发送到客户机的HTML 和作为程序执行的PHP 代码的混合编码。无论代码生成什么样的输出,都会发送到客户机,因此客户机永远不会看到代码,它只能看结果的输出。

当PHP 开始读取文件时,假设文件内容表示文字的H T M L,则它仅仅拷贝在那里找到的输出内容。当PHP 解释程序遇到一个特殊的打开标记时,就从HTML 模式切换到PHP 代码模式,而作为要执行的PHP 代码也开始解释文件。代码的结尾由另一个特殊的标记指出,解

释程序在这个位置从代码模式切换回HTML 模式。这就允许将静态的文本( HTML 部分)与动态产生的结果( PHP 代码部分的输出)相混合,产生依赖于调用环境变化的页面。例如,可以使用PHP 脚本来处理表格的结果,在这个格式中,用户已经输入了数据库搜索的参数。

由于格式填入内容的不同,所以每次搜索的参数可能也不同,因此当脚本执行搜索的时候,每个作为结果的页面将反映不同的搜索。

让我们通过一个非常简单的PHP 脚本看一看它是如何工作的:

hello,world

这个脚本并不很有趣,因为它不包括PHP 代码!因此您会问:那它有什么好处?这个问题的回答是:它有时有助于建立包括想要生成页面的HTML 框架的脚本,然后再加入PHP代码。这是非常有效的,PHP 解释程序用于它是没有问题的。

为了在脚本中包括PHP 代码,您可从用两个特殊标记(脚本开始处的‘ < ? p h p’和脚本结束处的‘? >’)把它与周围的文本区分开来。当PHP 解释程序遇到开始的‘< ? p h p’标记时,就从HTML 模式切换到PHP 模式,并解释它找到的任何PHP 代码,直到看见结束的‘ ? >’标记为止。它产生的所有输出解释并替换了两个标记之间的脚本。将前面的实例再重新编写一下,它包括了少量的PHP 代码,如下所示:

此时,代码部分是很小的,由单行组成。当解释代码时,产生了输出“ hello, world”,它作为输出部分发送到客户机浏览器。这样,这个脚本产生的Web 页面与前面实例产生的Web页面一样,前面实例的脚本完全由HTML 组成。

可以使用PHP 代码产生Web 页面的任何部分。我们已经看到了一个特别的实例,在那里整个脚本都由文字的HTML 组成,而不包括PHP 代码。另一个特别的实例是整个脚本都是PHP 代码而不包括文字的H T M L:

这说明PHP 在如何产生输出方面有很大的灵活性。但PHP 也留下一个问题,那就是确定如何组合HTML 和PHP 代码才是合适的。不必把所有代码都放在一个地方, PHP 在这方面也很灵活。只要您高兴,就可以通过脚本在HTML 和PHP 代码模式之间进行转换。

PHP 脚本标记

除了本章实例中使用的标记之外, PHP还支持其他的脚本标记。您可以在其他人编写的PHP 代码中看到它们,或者可以自己使用这些标记。PHP 识别四种标记风格:

缺省标记风格。这是PHP 配置为缺省时使用的风格:

简洁开标记风格。这个风格除了开标记较简洁外,其他与缺省风格相类似:

兼容ASP 的风格。这个风格在Active Server Page 环境内部是通用的:

<% print (“hello,

关 键 字:MYSQL

篇5:Ubuntu Server Nginx PHP MySQL相关命令

目的 命令 备注

关闭服务器 shutdown -h now shutdown -h 3 ”System will shutdown after 3 minutes“

表示系统通知用户将在3分钟后关闭 www.dnzg.cn

重启服务器 shutdown -r now

对现有安装软件进行更新 sudo apt-get update

sudo apt-get upgrade

安装SSH sudo apt-get install ssh 安装后,即可使用ssh或winscp进行远程连接操作

安装ftp sudo apt-get install vsftpd

安装Nginx sudo apt-get install nginx

安装mysql服务器端 sudo apt-get install mysql-server 安装过程中需要为mysql的root用户设置密码

安装mysql客户端 sudo apt-get install mysql-client

安装php5 sudo apt-get install php5

安装php5-fpm sudo apt-get install php5-fpm

安装php5-mysql sudo apt-get install php5-mysql

安装php-apc sudo apt-get install php-apc

篇6:Apache+SSL, PHP, and MySQL的配置过程 Updated: 12/10/Unix系统

Apache+SSL,PHP,and MySQL Updated:12/10/2004 GeneralInformation I'msuremanyofyouhavebeenwonderinghowpeoplehostsecuresitesusingSecureSocketsLayer(SSL).ThisguidewillshowyouhowtosetupawebserverwithSSL,PHP,andMySQLsupport. Requirements Inorderf

Apache+SSL, PHP, andMySQL

Updated: 12/10/2004

General Information

I'm sure many of you have been wondering how people host secure sites using Secure Sockets Layer (SSL).  This guide will show you how to set up a web server with SSL, PHP, and MySQL support.

Requirements

In order for public aclearcase/” target=“_blank” >ccess to your website, you must have a valid domain name.

A text editor (for this guide we will use Nano)

Installation

Section A -- Apache+mod_ssl

First thing we need to do is install the Apache web server.  Currently there are two main versions available: 1.3.x and 2.0.x.  I will be teaching from the 1.3x branch, but many of the steps are the same for 2.0.x.  I will also make notes for those of you who choose to use the 2.0.x branch.

#cd /usr/ports/www/apache13-modssl

#make install distclean

Apache now gets started on system boot from rc.conf so let's add the respective entry:

# echo 'apache_enable=“YES”' >> /etc/rc.conf

# echo 'apache_flags=“-DSSL”' >> /etc/rc.conf

*Note for Apache2 users: You only need to install the apache2 port, but then you have to manually create the directories for the SSL Certificate and Key.

#cd /usr/ports/www/apache2

#make install distclean

#echo 'apache2_enable=“YES”' >> /etc/rc.conf

#echo 'apache2_flags=“-DSSL”' >> /etc/rc.conf

#mkdir /usr/local/etc/apache2/ssl.key

#mkdir /usr/local/etc/apache2/ssl.crt

#chmod 0700 /usr/local/etc/apache2/ssl.key

#chmod 0700 /usr/local/etc/apache2/ssl.crt

Section B -- MySQL:

#cd /usr/ports/databases/mysql40-server

#make install WITH_OPENSSL=yes distclean

Take a break while it downloads, compiles, and installs.  It'll take about 45 minutes on a K6-2 350MHz.

Section C -- PHP:

#cd /usr/ports/www/mod_php4

#make install distclean

#cd /usr/ports/lang/php4-extensions

#make install distclean

Now, when you get to the PHP configuration screen, you just need to check the OpenSSL box and leave the rest of the default values alone, unless you plan on installing other applications, such as the IMP Webmail, that require other PHP modules.  Time to take another break.

PHP should be installed by now.  At the end of the installation, you will need to edit Apache's configuration file to add two lines after all the “LoadModule” lines for PHP support.

# nano -w /usr/local/etc/apache/httpd.conf

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

Configuration

Section A -- Create Certificate

It is now time to create your own certificate using the openssl utility.  Now, you need to understand that one server can hold multiple certificates, but only one per listening IP address.  So, if your server is listening on one IP address, you can only have one certificate for the server.  All of your virtual domains can share the same certificate, but clients will get warning prompts when they connect to a secure site where the certificate does not match the domain name.  If your server is listening on multiple IP addresses, your virtual hosts have to be IP-based -- not name-based.  This is something to consider when creating your certificate.

Change to any directory you would like to save your certficate in.  I chose root's home directory.  We will then copy the necessary files to the correct directory later.  This way we have a back up in case something happens.

# cd ~

# openssl genrsa -des3 -out server.key 1024

You will be prompted to enter a password for this key.  Remember it because we will need it later.  Now we need to make a Certificate Signing Request (CSR) from the key we just generated

#  openssl req -new -key server.key -out server.csr

Enter your password you had used as this is where you get to enter all the fun information about the certificate, like your name and Fully Qualified Domain Name (FQDN).  Make sure you enter your FQDN for the “Common Name” portion.  For example, if the certificate is for webmail.domain.tld/, then your CommonName should be webmail.domain.tld.

Alright, your certificate is ready to be signed.  The following steps are to self-sign the certificate, but you could pay money and have it signed by Verisign or Thawte.

#  openssl x509 -req -days 365 -in /root/server.csr -signkey /root/server.key -out /root/server.crt

Ok, your certificate is signed and valid for 365 days, which you could have changed if you wanted.  We now need to copy the files to the appropriate directory for Apache to use them.

#cp ~/server.key /usr/local/etc/apache/ssl.key/

#cp ~/server.crt /usr/local/etc/apache/ssl.crt/

If you want to read more about SSL Certificates, you can read the FAQs at httpd.apache.org/docs-2.0/ssl/ssl_faq.html#aboutcerts.

** Apache2 users: The correct permissions must be set.

# chmod 0400 /usr/local/etc/apache2/ssl.key/server.key

# chmod 0400 /usr/local/etc/apache2/ssl.crt/server.crt

Section B -- Configure VirtualHosts

VirtualHosts are neat because they allow you to host many domains on the same server and the same IP address.  For this example, we will make three VirtualHost entries -- one for http and two for https (SSL).

This section will be modifying /usr/local/etc/apache/httpd.conf so you can pull that up in your favorite editor now.  The normal VirtualHosts can be placed at the beginning of the file for easy access and should be set up like this:

ServerName domain.tld

NameVirtualHost 192.168.0.2:80

ServerName domain.tld

ServerAlias www.domain.tld

ServerAdmin admin@domain.tld

DocumentRoot /path/to/website/files

Now at the bottom of httpd.conf, you should see a whole bunch of lines relating to SSL.  Insert the following line just before the default VirtualHost for SSL like this:

NameVirtualHost 192.168.0.2:443

NameVirtualHost tells Apache that there are several virtual hosts under the same IP.  So, at the bottom of httpd.conf you will want to put your VirtualHosts just before .

ServerName domain.tld

ServerAlias www.domain.tld

ServerAdmin admin@domain.tld

DocumentRoot /path/to/website/files

SSLEngine on

SSLCertificateFile /usr/local/etc/apache/ssl.crt/server.crt

SSLCertificateKeyFile /usr/local/etc/apache/ssl.key/server.key

Now, if you had a server listening on another IP address, you could set up another certificate for that IP address to use.  Then, your second VirtualHost could look like this:

ServerName domain2.tld

ServerAlias www.domain2.tld

ServerAdmin admin@domain2.tld

DocumentRoot /path/to/website/files

SSLEngine on

SSLCertificateFile /usr/local/etc/apache/ssl.crt/server2.crt

SSLCertificateKeyFile /usr/local/etc/apache/ssl.key/server2.key

If you notice, SSLCertificateFile and SSLCertificateKeyFile are only paths to the certificate and key.  Just remember that you would have to use IP-based VirtualHosts, like we did, and not name-based.

** Apache2 users: All of your SSL configuration is in a separate file at /usr/local/etc/apache2/ssl.conf so edit that for your SSL-aware VirtualHosts.

Section C -- Start Services

Your server is now ready to start MySQL and Apache with SSL.

# /usr/local/etc/rc.d/mysql-server.sh start

# /usr/local/sbin/apachectl startssl

When you start apache with ssl, you will be prompted to enter that password you were supposed to remember.  The reason for entering it everytime apache starts is because the RSA private key is stored in encrypted format.  You can remove the encryption to eliminate the password prompt if you would like, but it's not recommended for security reasons.  If you removed the encryption and somebodywasable to control your box, they could take your certificate and impersonate you.  But, if you are annoyed by the password prompt and feel confident that your server is secure, these are the steps to remove the encryption:

#cd /usr/local/etc/apache/ssl.key

# cp server.key server.key.orig

# openssl rsa -in server.key.orig -out server.key

Point your favorite browser to domain.tld and you should have a 128-bit secure connection.  That's all there is to setting up a standard web server with SSL support.  Happy hosting!

Comments

ManDude on March 05, 2004 at 3:48:19 pm MST

Thanks for the info. I'll give it a go later.

Hovi on July 28, 2004 at 10:27:04 am MST

Hey i dont get the options to install anything else with mod_php4.How can i install mod_php4 with some of the options it had before (that i could have picked but now cant)?

thnx

Jon on July 28, 2004 at 1:50:19 pm MST

As of 07/19/2004, the php4 and php5 port structure has changed.  The lang/php4, lang/php5, www/mod_php4, and www/mod_php5 ports are only the “base” php.  You can install individual php extensions under the names of php4- or you can install php4-extensions which will give you the familiar look and feel that you are used to.

kingsz1 on December 25, 2004 at 7:46:26 pm MST

I got a error message whene I completed the installation and try to start the mysql:

#mysql

ERROR 2002:Can't connect to local MySQL server through cocket '/tmp/mysql.sock'(2)

How can I solve this problem?

Jon on December 26, 2004 at 7:40:42 pm MST

You do not have mysql running when you tried to access the mysql commandline.  You first need to run

# /usr/local/etc/rc.d/mysql-server.sh start

and then you will be able to connect to mysql.

yueming 回复于:2004-12-31 11:29:52这是一片国外网站上的一个非常好的帖子,虽然是全英文的,但是都比较简单易懂,只要有一点英文基础的东能看懂,

Apache+SSL, PHP, and MySQL的配置过程 Updated: 12/10/2004Unix系统

哈哈。哈啊,

我想对于高手来说没有多少意思,但是对于新手来讲,是非常好的入门的帖子。大家,慢慢看,看不懂也不要紧,只看操作过程,也能达到目的。

HonestQiao 回复于:2004-12-31 12:10:14转帖无罪,可是一贴多发有罪.

yueming 回复于:2004-12-31 12:39:00什么一帖多发,你还什么地方看见了,晕死,

zhanglianxiao 回复于:2005-02-25 08:49:27[quote:d55f045e76=“yueming”]Take a break while it downloads, compiles, and installs. It'll take about 45 minutes on a K6-2 350MHz.

[/quote:d55f045e76]

我的E文很差,但这句话我懂!

如果我们写中文的高手有这么详细该多好!!!!

那么中国的计算机普及事业该多好!!!!!

剑心通明 回复于:2005-02-25 09:14:51[quote:3bac7666df=“zhanglianxiao”]

我的E文很差,但这句话我懂!

如果我们写中文的高手有这么详细该多好!!!!

那么中国的计算机普及事业该多好!!!!![/quote:3bac7666df]

高手写东西几乎都不是针对新手了,他们可能认为很多大家都会了

zhanglianxiao 回复于:2005-02-25 09:19:53是呀,像上面那个大斑竹,写的一个“无毒邮箱的安装”寥寥数语!!

精干!!针对成手的,对于我们这些新手还得自己琢磨!影响计算机技术的普及与发展!!

剑心通明 回复于:2005-02-25 09:23:29也不是所有人都这样的啊

zhanglianxiao 回复于:2005-02-25 09:27:30剑心通明小弟,我知道你写的比较详细,风格有点像红袖,唉,可惜红袖走了!

原文转自:www.ltesting.net

php 面试题

Linux安装mysql

PHP面试题集

php个人简历范文

医院AAA评级申请范文

中国大学排行榜评级指标体系

php开发工程师简历

PHP高级工程师面试问题

PHP面试题及答案

php开发就业前景

Star Rating System:免费的PHP/MySQL评级系统(共6篇)

欢迎下载DOC格式的Star Rating System:免费的PHP/MySQL评级系统,但愿能给您带来参考作用!
推荐度: 推荐 推荐 推荐 推荐 推荐
点击下载文档 文档为doc格式

猜你喜欢

NEW
点击下载本文文档