html中select语句读取mysql表中内容
时间:2007-02-17 来源:PHP爱好者
<?
$record=0;
$db=@mysql_pconnect('localhost','root');
@mysql_select_db('1234',$db);
$strsql="select * from 1234_data";
$result=@mysql_query($strsql);
$data=@mysql_fetch_array($result);
$record=@mysql_num_rows($result);
echo "<select name=type size=1>n";
do{
if ($record==1){
echo "<option value=".$data['cname']." selected>".$data['cname']."</option>n";
}
else{
echo "<option value=".$data['cname'].">".$data'cname']."</option>n";
}
}while($data=@mysql_fetch_array($result));
echo "</select>n";
?>
php爱好者站 http://www.phpfans.net php基础|php进阶|php模板.
$record=0;
$db=@mysql_pconnect('localhost','root');
@mysql_select_db('1234',$db);
$strsql="select * from 1234_data";
$result=@mysql_query($strsql);
$data=@mysql_fetch_array($result);
$record=@mysql_num_rows($result);
echo "<select name=type size=1>n";
do{
if ($record==1){
echo "<option value=".$data['cname']." selected>".$data['cname']."</option>n";
}
else{
echo "<option value=".$data['cname'].">".$data'cname']."</option>n";
}
}while($data=@mysql_fetch_array($result));
echo "</select>n";
?>
php爱好者站 http://www.phpfans.net php基础|php进阶|php模板.
相关阅读 更多 +