tekrscom Posted June 13, 2007 Share Posted June 13, 2007 Hi, I think I'm having a bit of a looping issue... I need to number a number on every row result, but what I am getting is the amount of result rows multiplied times how many results there are... $query = mysql_query("SELECT MTES_direct_sub_task_id, MTES_direct_sub_task FROM MTES_direct_sub_tasks WHERE MTES_direct_task = '$_SESSION[task]'"); while ($row = mysql_fetch_array($query)) { $count = mysql_num_rows($query); $count = $count + 1; for($i = 1; $i < $count; $i++) echo ' <tr> <td> <input type="hidden" name="MTES_direct_sub_task" value="', $row[MTES_direct_sub_task], '"><input type="hidden" name="count" value="', $i, '"> <input type="text" name="hours" size="4"> ', $row[MTES_direct_sub_task], ' </td> </tr> '; } Any ideas on what I am doing wrong? Link to comment https://forums.phpfreaks.com/topic/55495-solved-numbering-result-rows/ Share on other sites More sharing options...
ToonMariner Posted June 13, 2007 Share Posted June 13, 2007 <?php $query = mysql_query("SELECT MTES_direct_sub_task_id, MTES_direct_sub_task FROM MTES_direct_sub_tasks WHERE MTES_direct_task = '$_SESSION[task]'"); $i = 0; while ($row = mysql_fetch_array($query)) { ?> <tr> <td> <input type="hidden" name="MTES_direct_sub_task" value="<?php echo $row[MTES_direct_sub_task];?>"> <input type="hidden" name="count" value="<?php echo $i++;?>"> <input type="text" name="hours" size="4" value="<?php echo $row[MTES_direct_sub_task]; ?>"> </td> </tr> <?php } ?> try that... Link to comment https://forums.phpfreaks.com/topic/55495-solved-numbering-result-rows/#findComment-274236 Share on other sites More sharing options...
tekrscom Posted June 13, 2007 Author Share Posted June 13, 2007 You're a genius! Thank you very much for your help, it is most appreciated... Link to comment https://forums.phpfreaks.com/topic/55495-solved-numbering-result-rows/#findComment-274237 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.