How do I use a while loop with counter for echoing else statement?

aseel

New Member
I'm not a full time PHP programmer by any means, but wondering what the most efficient way to do this would be? I am running a fetch to grab some data that I want to display on a page. The query results usually have multiple rows.The following below works great, except for the last else statement for showing none. This part doesn't work. Basically I want to display my rows of data and if nothing exists, throw out a message saying "none."I did some reading around and it looks like with a while loop + multiple result sets you can't simply just use the standard else... both with !empty or isset.Someone mentioned doing a counter? Would this be the best way to accomplish this. Open to any suggestions as I will probably be adding more data like this in the future and would like to do it in the correct fashion.Thanks!\[code\]while($myvariable = oci_fetch_assoc($stmt)){if(!empty($myvariable)) { echo "<tr><th>DISPLAY FIELD NAME:</th><td>" . $myvariable['myrowdata'] . </td></tr>"; } else { echo "<tr><th>DISPLAY FIELD NAME:</th><td>None</td></tr>"; }}\[/code\]
 
Back
Top