php怎么取的指定id的值

WBOY
Release: 2016-06-13 10:02:07
Original
1342 people have browsed it

php如何取的指定id的值啊
php如何取的指定id的值啊
如:
$sql="select * from customers where customers_id=".$_GET["id"];
$result=mysql_query($sql,$conn) or
die("error:".mysql_error);

$num=mysql_num_rows($result);
if ($num >0) {
....这里如何写啊 ,如果有相同的值 是不是就出来两个啊 我只要第一个

}
?>

------解决方案--------------------

PHP code
if($num>0){$row = mysql_fetch_assoc($result); print_r($row);}
------解决方案--------------------
Copy after login
PHP code
$sql="select * from customers where customers_id=".$_GET["id"];$result=mysql_query($sql,$conn) ordie("error:".mysql_error);$num=mysql_num_rows($result);if ($num >0) {mysql_fetch_array($result); }?>
------解决方案--------------------
$result=mysql_query($sql,$conn)
你得到结果集??
你是想从多个行中取第一个行吧??
$rows=mysql_fetch_row($result)
这就是一行了,如果有多行,默认为第一行!
------解决方案--------------------
总感觉你这么写SQL语句有问题
------解决方案--------------------
Copy after login
探讨
php如何取的指定id的值啊
如:
$sql="select * from customers where customers_id=".$_GET["id"];
$result=mysql_query($sql,$conn) or
die("error:".mysql_error);

$num=mysql_num_rows($result);
if ($num >0) {
....这里如何写啊 ,如果有相同的值 是不是就出来两个啊 我只要第一个

}
?>


------解决方案--------------------
id 如果是自动生成的就不会有重复的吧
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn