WEB开发网
开发学院WEB开发PHP html中select语句读取mysql表中内容 阅读

html中select语句读取mysql表中内容

 2000-12-05 11:42:03 来源:WEB开发网   
核心提示:<?$record=0;$db=@MySQL_pconnect('localhost','root');@mysql_select_db('1234',$db);$strsql="select * from 1234_data";$result=
<?
 $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";
?>

Tags:html select 语句

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接