jesushax Posted July 10, 2008 Share Posted July 10, 2008 hi was wondering if anyone knew how to put record numbers next to records my search for prints out results onto a table i just want a number next to the results eg 1 result | 2 result | 3 result 4 result etc Link to comment https://forums.phpfreaks.com/topic/114072-solved-numbers-next-to-records-1234-etc/ Share on other sites More sharing options...
LooieENG Posted July 10, 2008 Share Posted July 10, 2008 <?php for ( $i = 1; $i < 10; $i++ ) { echo $i . '<br />'; } ?> Will print off 1 2 3 4 5 6 7 8 9 10 So just set $i then echo it with the result, and add one to $i using $i++ after each result. If that's what you mean Link to comment https://forums.phpfreaks.com/topic/114072-solved-numbers-next-to-records-1234-etc/#findComment-586303 Share on other sites More sharing options...
jesushax Posted July 10, 2008 Author Share Posted July 10, 2008 ill show you where i have "NUMBER OF RESULT HERE" i would like a number 1 2 3 or 4 etc next to it echo '<p>Search Results</p>'."\n"; if (mysql_num_rows($SEARCH) > 0) { $col = 1; $colMax = 3; echo '<table border="0" width="100%">'."\n"; while($row=mysql_fetch_array($SEARCH)) { if ($col == 1) echo "<tr>\n"; echo '<td style="padding:5px;">'."\n"; echo 'NUMBER OF RESULT HERE'; echo '<a href="javascript:;"'."\n"; echo "onclick=\"return popup_flood('print_record.php?ID=".$row["CompanyID"]."','NewPage');\">\n"; echo $row["CompanyName"].'</a></td>'."\n"; if ($col == $colMax) { echo " </tr>\n"; $col = 1; } else $col++; } while ($col <= $colMax && $col !== 1) { echo " <td> </td>\n"; $col++; if ($col > $colMax) echo " </tr>\n"; } echo "</table>\n"; } Link to comment https://forums.phpfreaks.com/topic/114072-solved-numbers-next-to-records-1234-etc/#findComment-586307 Share on other sites More sharing options...
LooieENG Posted July 10, 2008 Share Posted July 10, 2008 <?php $i = 1; echo '<p>Search Results</p>'."\n"; if (mysql_num_rows($SEARCH) > 0) { $col = 1; $colMax = 3; echo '<table border="0" width="100%">'."\n"; while($row=mysql_fetch_array($SEARCH)) { if ($col == 1) echo "<tr>\n"; echo '<td style="padding:5px;">'."\n"; echo $i; $i++; echo '<a href="javascript:;"'."\n"; echo "onclick=\"return popup_flood('print_record.php?ID=".$row["CompanyID"]."','NewPage');\">\n"; echo $row["CompanyName"].'</a></td>'."\n"; if ($col == $colMax) { echo " </tr>\n"; $col = 1; } else $col++; } while ($col <= $colMax && $col !== 1) { echo " <td> </td>\n"; $col++; if ($col > $colMax) echo " </tr>\n"; } echo "</table>\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/114072-solved-numbers-next-to-records-1234-etc/#findComment-586311 Share on other sites More sharing options...
jesushax Posted July 10, 2008 Author Share Posted July 10, 2008 ncie and simple Thanks Link to comment https://forums.phpfreaks.com/topic/114072-solved-numbers-next-to-records-1234-etc/#findComment-586315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.