我正在尝试按顺序从数据库中获取id列。我已经编写了这段代码,但它没有用。
<div id="page">
<img src="http://www.clker.com/cliparts/0/f/d/b/12917289761851255679earth-map-huge.jpg">
</div>
<div id="load_screen" class="text-center">
<div id="loading" class="text-center">
<h3>Welcome to Jack Loud Photo!</h3>
<p>Loading content...</p><i class="fa fa-spinner fa-spin fa-2x" aria-
hidden="true"></i>
</div>
</div>
所以,这段代码给了我这个错误:
注意:未定义的偏移量:第24行的C:\ xampp \ htdocs \ gt \ fetch_channel.php中的1
任何人都可以帮助我吗?
答案 0 :(得分:0)
问题是:$ row中没有$ i索引 我不确定你想要什么,但我想你会喜欢这样的东西:
$connection = mysqli_connect($servername,$username,$password,$dbname);
if(!$connection)
die("Database connection failed: " . mysqli_connect_error());
$query = "SELECT ID FROM channel ";
if($result = mysqli_query($connection,$query))
{
//fetch one and one row
while($row=mysqli_fetch_row($result))
{
echo "<span>".$row['id']."</span><br/>";
}
}
mysqli_close($connection);