PHP,我的选择框没有正确填充,我只是获取代码行 [英] PHP, My select box isn't populating properly, I am just getting lines of code

查看:65
本文介绍了PHP,我的选择框没有正确填充,我只是获取代码行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< TD> 
< h4>要查看折扣,只需从下面的类别中选择。< / h4>< br />
<! - 列表类别框 - >

<?php
$ db = new mysqli('50 .62.209.81:3306','user','password','MassWarVetsADM');
$ query =SELECT Category FROM Category;
$ result = mysql_query($ query);
echo< select name ='categoriesSelect'class ='e1'>< option value ='0'> Please Select A Category< / option>;

//打印列表框select命令
while($ categoryinfo = mysql_fetch_array($ result)){//存储在$ nt
echo中的数组或记录<选项值= \ 。用htmlspecialchars($ categoryinfo [ '类别'])。 \ >中。$ categoryinfo [ '类别'] < /选项> 中。
}
echo< / select>;
?>





当我在firefox / IE / chrome中查看我的页面时,我得到了:http://tinypic.com/r/2eqc22v/8 [ ^ ]



出于安全原因,我删除了用户名& pw。我做错了什么?



这应该在选择框内打印我的数据库里面的Category表的Category列中列出的35个左右类别的列表

解决方案

db = new mysqli('50 .62.209.81:3306','user','password','MassWarVetsADM');


< blockquote> query =SELECT Category FROM Category;


result = mysql_query(


<td>
        <h4>To view discounts, simply select from a category below.</h4><br />
        <!-- List Category Box -->
 
        <?php
        $db = new mysqli('50.62.209.81:3306','user','password','MassWarVetsADM');
        $query="SELECT Category FROM Category";
        $result = mysql_query ($query);
        echo "<select name='categoriesSelect' class='e1'><option value='0'>Please Select A Category</option>";
 
        // printing the list box select command
        while($categoryinfo=mysql_fetch_array($result)){//Array or records stored in $nt
        echo "<option value=\"".htmlspecialchars($categoryinfo['category'])."\">".$categoryinfo['category']."</option>";
        }
        echo"</select>";
        ?>



When I look at my page in firefox/IE/chrome I get this: http://tinypic.com/r/2eqc22v/8[^]

I removed the username&pw for security reasons. What am I doing wrong?

This should print inside the select box the list of 35 or so categories listed in the Category column of the Category table inside my database

解决方案

db = new mysqli('50.62.209.81:3306','user','password','MassWarVetsADM');


query="SELECT Category FROM Category";


result = mysql_query (


这篇关于PHP,我的选择框没有正确填充,我只是获取代码行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆