[英]PHP loop while not empty array
I am a beginner to php/sql so bear with me if I'm missing something. 我是php / sql的初学者,因此如果我缺少某些内容,请多多包涵。
I have a database that I'm querying but not all the rows are complete. 我有一个正在查询的数据库,但并非所有行都是完整的。 I'm trying to figure out which rows have a value in a certain column.
我试图找出哪些行在特定列中具有值。 Essentially what I have now is:
我现在基本上拥有的是:
while (!empty($result['c1']))
{
echo $result['c2'];
}
The server doesn't seem to like this. 服务器似乎不喜欢这样。 Any thoughts?
有什么想法吗?
Assuming you already have a while loop, this goes in it like so... Ignore the mysql part....Im just illustrating...you should use PDO anyways...but since you're still learning, Im assuming you're just using mysql_* deprecated functions, as thats where most of us start. 假设您已经有一个while循环,就这样进入它……忽略mysql部分...。我只是在说明...您仍然应该使用PDO ...但是由于您仍在学习,我假设您只是使用mysql_ *不推荐使用的函数,这就是我们大多数人开始的地方。
while($result = mysql_fetch_array($query)){
if(!empty($result['c1'])){
echo $result['c2'];
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.