当前位置:数据库 > SQLServer >>

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

<?
  $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> ";
       do{
             if ($record==1){
                echo "<option value=".$data[cname]." selected>".$data[cname]."</option> ";
                          }
             else{
                echo "<option value=".$data[cname].">".$datacname]."</option> ";
             }
       }while($data=@mysql_fetch_array($result));
       echo "</select> ";
?>

补充:Web开发 , php ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,