php下拉列表问题 5
<?php$conn=mysql_connect("localhost","root","111111");mysql_select_db('article_tb',$c...
<?php
$conn=mysql_connect("localhost","root","111111");
mysql_select_db('article_tb',$conn);
$relust = mysql_query("SELECT * FROM `leix_tb`");
echo "<select >";
while ($row = mysql_fetch_array($relust))
{
echo $row['id']." ".$row['title'];
//foreach($row as $value){
echo "<option>".$row['family']."</option>";
//}
}
我这样用下拉列表获取到了数据库一张数据表中的值 现在我要把这个值存入另一张数据表要怎么做 展开
$conn=mysql_connect("localhost","root","111111");
mysql_select_db('article_tb',$conn);
$relust = mysql_query("SELECT * FROM `leix_tb`");
echo "<select >";
while ($row = mysql_fetch_array($relust))
{
echo $row['id']." ".$row['title'];
//foreach($row as $value){
echo "<option>".$row['family']."</option>";
//}
}
我这样用下拉列表获取到了数据库一张数据表中的值 现在我要把这个值存入另一张数据表要怎么做 展开
1个回答
展开全部
首先根据文章的分类ID读出分类名,与分类值然后在第一行生成一个
<option selected value="<?=$s_value?>"><?=$s_text?></option>
下面再循环所有分类
代码如下:
<?
$s_name = "T"; //下拉菜名称
$s_table = "zc_newtype"; //数据表名
$TN = getTitle($ary["T"],$s_table,"title");
$s_text = $TN; //默认显示
$s_value = $ary["T"]; //默认值
?>
<select name="<?=$s_name?>">
<option selected value="<?=$s_value?>"><?=$s_text?></option>
<?
$sql = "select * from ".$s_table." order by orderid,id desc";
$rs = @mysql_query($sql);
while($ary1 = @mysql_fetch_array($rs)){
?>
<option value="<?=$ary1["id"]?>"><?=$ary1["title"]?></option>
<?
}
@mysql_free_result($rs);
?>
</select>
<option selected value="<?=$s_value?>"><?=$s_text?></option>
下面再循环所有分类
代码如下:
<?
$s_name = "T"; //下拉菜名称
$s_table = "zc_newtype"; //数据表名
$TN = getTitle($ary["T"],$s_table,"title");
$s_text = $TN; //默认显示
$s_value = $ary["T"]; //默认值
?>
<select name="<?=$s_name?>">
<option selected value="<?=$s_value?>"><?=$s_text?></option>
<?
$sql = "select * from ".$s_table." order by orderid,id desc";
$rs = @mysql_query($sql);
while($ary1 = @mysql_fetch_array($rs)){
?>
<option value="<?=$ary1["id"]?>"><?=$ary1["title"]?></option>
<?
}
@mysql_free_result($rs);
?>
</select>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询