Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

Php and making up the numbers

Hi Experts,

If this is my query:

$result = mysql_query("SELECT * FROM table where name='alan' ");
while($row = mysql_fetch_array($result))
{
echo "  <tr>
    <td>".$row['title']."</td>
  </tr>\n";
 
}

But i must have 6 rows in the table even if there are 4 results... how can I make up the number with blank rows ie. :

echo "  <tr>
    <td>&nbsp;</td>
  </tr>\n";


Thnaks in advance
0
maccaj51
Asked:
maccaj51
1 Solution
 
Rik-LeggerCommented:
<?php 

$result = mysql_query("SELECT * FROM table where name='alan' ");
$iRow = 0;
while($row = mysql_fetch_array($result))
{
	$iRow++;
echo "  <tr>
    <td>".$row['title']."</td>
  </tr>\n";
 
}

for ($i = $iRow; $i <= 6; $i++) {
	
echo "  <tr>
    <td>&nbsp;</td>
  </tr>\n";
}

?>

Open in new window

0
 
maccaj51Author Commented:
Thank you... Quick, Correct!!! Very helpful!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now