你好,不知道我这样写能不能帮你解决问题,如下:
创新新互联,凭借十载的成都做网站、成都网站设计、成都外贸网站建设经验,本着真心·诚心服务的企业理念服务于成都中小企业设计网站有上1000+案例。做网站建设,选成都创新互联。
//在查询的时候添加条件,GiftType的值可以通过点击的时候传过来
$sql = "SELECT * FROM `cards` where GiftType=1 ORDER BY RAND() LIMIT 1";
?php
header("Content-Type:text/html;charset=utf-8");
mysql_connect ('localhost', 'kiko', '123456')or die("不能连接数据库");
//$res = mysql_db_query("user","select O2,PH,TP,NH3,DT from user_pool");
$res=mysql_db_query("user","select o2,PH,TP,NH3,DT from user_pool where us='qwe');
while ($row = mysql_fetch_array($res)) {
?
trtd检测时间/tdtd? echo $row["DT"];?/td /tr
trtd温度(单位:)/tdtd? echo $row["TP"];?/td /tr
trtd酸碱度/tdtd? echo $row["PH"];?/td
trtd含氧量(单位:mg/L) /tdtd? echo $row["O2"];?/td /tr
trtd含氨量(单位:mg/L)/tdtd? echo $row["NH3"];?/td/tr
?
}
mysql_free_result($res);
?
/table
?php
$servername = "localhost";
$username = "root";
$password = "password";//mysql密码
$dbname = "myDB";//选择数据库
// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);
// 检测连接
if ($conn-connect_error) {
die("Connection failed: " . $conn-connect_error);
}
$sql = "SELECT id, firstname, lastname FROM MyGuests";//sql查询语句
$result = $conn-query($sql);//获得查询结果
if ($result-num_rows 0) {
// 输出每行数据
while($row = $result-fetch_assoc()) {
echo "br id: ". $row["id"]. " - Name: ". $row["firstname"]. " " . $row["lastname"];
}
} else {
echo "0 results";
}
$conn-close();
?
?phpfunction test_defaultargs ( $arg = " default value " ){echo " 参数值为: " . $arg . " br " ;}test_defaultargs () ;test_defaultargs ( " new value " ) ;??phpfunction makecoffee ( $type = " cappuccino " ){return " Making a cup of $type . " ;}echo makecoffee () ;echo makecoffee ( " espresso " ) ;?
请注意当使用默认参数时,任何默认参数必须放在任何非默认参数的右侧;否则,可能函数将不会按照预期的情况运行。
?phpfunction makeyogurt ( $type = " acidophilus " ,$flavour ){return " Making a bowl of $type $flavour . " ;}echo makeyogurt ( " raspberry " ) ; // 这个例子将不会按照我们预期的情况运行。??phpfunction makeyogurt ( $flavour , $type = " acidophilus" ){return " Making a bowl of $type $flavour . " ;}echo makeyogurt ( " raspberry " ) ; // 这个例子的输出是:Making a bowl of acidophilus raspberry.?如果还不明白可以去后盾网问问php专家教师。希望能帮到你。