首页 > 学院 > 开发设计 > 正文

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

2019-11-18 21:52:09
字体:
来源:转载
供稿:网友
<?
  $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";
?>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表