PHP查找mysql指定字段,并将同列另一字段赋值变量+1

2024-11-20 04:32:13
推荐回答(2个)
回答(1):

$q = "SELECT user FROM message where id='1'"; //SQL查询语句
mysql_query("SET NAMES GB2312");
$rs = mysql_query($q, $conn); //获取数据集
if(!$rs){die("Valid result!");}

$row = mysql_fetch_array($rs); //这样从资源中取结果,是一个数组
print_r($row);

回答(2):

num.php:
$searchs = $_POST['search']; //传递search框过来的值
$searchs= trim($searchs);
$result = mysql_query("SELECT * FROM dunling_chat where nicheng like '%$searchs%' and num = num +1");
if (mysql_num_rows($result) < 1) echo ';';?>