在mysqli中正确填充我的查询结果 [英] Populate the results of my query properly in mysqli

查看:85
本文介绍了在mysqli中正确填充我的查询结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?php
        $con = mysqli_connect('server','username','password','DBName');
        // Check connection
        if (mysqli_connect_errno())
           {
           echo "<option>Failed to connect to the DB</option>" . mysqli_connect_error();
           }
         mysqli_query($con,"SELECT Category FROM Category");
         
         // HERE IS WHERE I NEED TO STORE THE VALUES & CREATE THE WHILE LOOP 
         // PRODUCING OPTION TAGS & VALUES BASED UPON THE RESULTS OF THE QUERY


         mysqli_close($con);
?>





有人可以帮我完成这个。我的database.table只有一列Category。我只需要使用while循环打印此查询的结果,这将允许我向HTML中的选择框添加选项



Can someone help me complete this. My database.table only has one column "Category". I just need to print the results of this query with a while loop that will allow me to add options to a select box in HTML

推荐答案

con = mysqli_connect(' server'' < span class =code-string> username',' password'' DBName');
// 检查连接
if (mysqli_connect_errno())
{
echo < span class =code-string>< option>无法连接到数据库< / option>。 mysqli_connect_error();
}
mysqli_query(
con = mysqli_connect('server','username','password','DBName'); // Check connection if (mysqli_connect_errno()) { echo "<option>Failed to connect to the DB</option>" . mysqli_connect_error(); } mysqli_query(


con, SELECT类别);

// 这里我需要存储价值和价值创建圈子
// 生产选项标签&基于QUERY结果的价值


mysqli_close(
con,"SELECT Category FROM Category"); // HERE IS WHERE I NEED TO STORE THE VALUES & CREATE THE WHILE LOOP // PRODUCING OPTION TAGS & VALUES BASED UPON THE RESULTS OF THE QUERY mysqli_close(


con);
?>





有人可以帮我完成这个。我的database.table只有一列Category。我只需要使用while循环打印此查询的结果,这将允许我向HTML中的选择框添加选项



Can someone help me complete this. My database.table only has one column "Category". I just need to print the results of this query with a while loop that will allow me to add options to a select box in HTML


这篇关于在mysqli中正确填充我的查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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