您好,我在 Mysql select query
中始终需要 5 行计数
我当前的输出是
my query ---------------------- $query = mysql_query("select * from table_name where MOBILE='$mobile_no' order by ID LIMIT 5 "); ---------------------- Result ---------------------- ARUN - 987654321 VINO - 987654321 RAJA - 987654321 ------------------- But I need like this (Need to return empty rows) ---------------------- ARUN - 987654321 VINO - 987654321 RAJA - 987654321 0 - 0 0 - 0 -------------------
这样我就可以在
while loop ----- while($row=mysql_fetch_array($query))中创建带有空值的
html 表格行
(总是 5 行)文本框
最佳答案
您可以在 php 中使用循环,并在循环中使用计数器。如果计数小于 5,则不填充文本框。它会给你类似的东西
$count = 0;
while($row=mysql_fetch_array($query)) {
// Fill your text box
$count+=1;
}
for($i=count; $i <= 5; $i++) {
// Fill your text box with empty string or whatever.
}
关于PHP Mysql 总是需要返回 5 行,即使表中有 3 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37475801/