Maison >développement back-end >tutoriel php >怎么隐藏下拉框的值
假设 php网站中
<?php$exists = array(1,2); // 这个表示从数据库中读取到已经有的记录。放到这个数组中,读数据库你自己写就可以了。?><select id="hangye" name="hangye"><option value="0">请选择</option><?if(!in_array(1, $exists)){?><option value="1">服务类</option><?}?><?if(!in_array(2, $exists)){?><option value="2">制造类</option><?}?><?if(!in_array(3, $exists)){?><option value="3">广告类</option><?}?></select>
<?php$exists = array(1,2); // 这个表示从数据库中读取到已经有的记录。放到这个数组中,读数据库你自己写就可以了。?><select id="hangye" name="hangye"><option value="0">请选择</option><?if(!in_array(1, $exists)){?><option value="1">服务类</option><?}?><?if(!in_array(2, $exists)){?><option value="2">制造类</option><?}?><?if(!in_array(3, $exists)){?><option value="3">广告类</option><?}?></select>
$result = mysql_query("SELECT * FROM uid",TABLE);
from uid明显有问题
改为
$uid=xxx; // 要查询的uid
$result = mysql_query("SELECT * FROM TABLE where uid='".$uid."'") or die(mysql_error());
试试
$result = mysql_query("SELECT * FROM uid",TABLE);
from uid明显有问题
改为
$uid=xxx; // 要查询的uid
$result = mysql_query("SELECT * FROM TABLE where uid='".$uid."'") or die(mysql_error());
试试
那更简单
$query = mysql_query("select uid from TABLE") or die(mysql_error());$result = array();while($thread=mysql_fetch_assoc($query)){ $result[] = $thread['uid'];}
那更简单
$query = mysql_query("select uid from TABLE") or die(mysql_error());$result = array();while($thread=mysql_fetch_assoc($query)){ $result[] = $thread['uid'];}
那更简单
$query = mysql_query("select uid from TABLE") or die(mysql_error());$result = array();while($thread=mysql_fetch_assoc($query)){ $result[] = $thread['uid'];}
把$result带进$exists答案不就出来了?
把$result带进$exists答案不就出来了?
那更简单
$query = mysql_query("select uid from TABLE") or die(mysql_error());$result = array();while($thread=mysql_fetch_assoc($query)){ $result[] = $thread['uid'];}
$query = mysql_query("select uid from TABLE") or die(mysql_error());$result = array();while($thread=mysql_fetch_assoc($query)){ $result[] = $thread['uid'];} ?>
那更简单
$query = mysql_query("select uid from TABLE") or die(mysql_error());$result = array();while($thread=mysql_fetch_assoc($query)){ $result[] = $thread['uid'];}
$query = mysql_query("select uid from TABLE") or die(mysql_error());$result = array();while($thread=mysql_fetch_assoc($query)){ $result[] = $thread['uid'];} ?>