一段代码

edited 十月 2013 in PHP新手區
<?
$connect = mysql_pconnect("localhost","root","165454");
mysql_select_db("UserInfo");

if($UserName)
{
$query = "SELECT * FROM UserInfo";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$rows = @mysql_num_rows($result);
$a_row = @mysql_affected_rows($result); //有什么作用??
$id = 0;
echo $rows;
for($i = 0;$i < $rows;$i++) //为什么不直接把行数与ID数相等??
{
@mysql_data_seek($result,$i);
$data = @mysql_fetch_array($result);
if($data[id] > $id)
{
$id = $data[id];
}
}
echo $id;
$id++;
$query = "insert into UserInfo values('".$id."','".$UserName."','".$PassWord."','".$Name."')";
$result = mysql_query($query);
}
mysql_close($connect);
?>
哪位知道的麻烦解释一下

原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=1194

評論

Sign In or Register to comment.