Jump to content

[SOLVED] numbers next to records 1,2,3,4 etc


jesushax

Recommended Posts

<?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

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";
}

<?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";
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.