多测试—函数版的$query='select * from tables where test1='.&_POST['string'];
$result=mysql_query($query);
while($row=fetch_assoc($result)){
$test1=$row['test1']
echo $test1;
$test2=$row['test2']
echo $test2;
$test3=$row['test3']
echo $test2;};
$result=mysql_query($query);
while($row=fetch_assoc($result)){
$test1=$row['test1']
echo $test1;
$test2=$row['test2']
echo $test2;
$test3=$row['test3']
echo $test2;};
$query='select * from tables where test1='.&_POST['string'];
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){
$test1=$row['test1']
echo $test1;
$test2=$row['test2']
echo $test2;
$test3=$row['test3']
echo $test2;};
&_POST为什么哪
不该是$_POST吗?其它同fxs
if ($row=$result->fetch_assoc())
extract($row); //extract这个函数
$test3=$row['test3']
$test4=$row['test4']
还有提一句多动手就对了
if ($_GET['isbn']){
@ $db=mysqli_connect('localhost','book','book','books');
if (mysqli_connect_errno()){
echo 'fail to connect the database.';
exit;
}
$query="select * from books where isbn=".addslashes($_GET['isbn']);
$result=mysqli_query($db,$query);
$row=mysqli_fetch_array($result);
if ($row){
echo stripslashes($row['author']);
}
}
else{
exit;
}
?>什么问题啊,数据库中字段author的类型是char(50),我添加时author为数字就显示出来,为字符就不显示出来 PS:小弟刚学PHP,问题是简单点,望各位多多见谅,不胜感激
所以,建议修改为:<?
if ($_GET['isbn']){
@ $db=mysqli_connect('localhost','book','book','books');
if (mysqli_connect_errno()){
echo 'fail to connect the database.';
exit;
}
$query="select * from books where isbn='".addslashes($_GET['isbn'])."'";
$result=mysqli_query($db,$query);
$row=mysqli_fetch_array($result);
if ($row){
echo stripslashes($row['author']);
}
}
else{
exit;
}
?>