Jump to content

Array trouble with outputting a table of results from a db query


cparekh

Recommended Posts

Hi,

 

I'm trying to output a table of results from a database query and I'm having trouble generating each row of results.

 

There are 3 columns of values and I don't quite know how to get to each value to print it out.

 

I'm testing $search_results->NumRows to make sure there is a result-set

 

I've made a start with...

for($i=0; $i < $search_results->NumRows; $i++) 
				{
					while ($row = $search_results->Rows[$i])
						{
            					               $p = $search_results;

							$Company = $p['Company'];
							$Contact = $p['Contact'];
							$Job = $p['Jobtitle'];	
							print "<tr><td>$Company</td><td>$Contact</td><td>$Job</td></tr>";
        					         } 
							    							
				}	

however this caused my browser to hang so I'm guessing it goes into an infinite loop?

 

How can I get to each row to print out?

 

Any help is greatly appreciated.

 

Thanks.

Try this:

 

<?php
for($i=0; $i < $search_results->NumRows; $i++) 
{
$row = $search_results->Rows[$i];
$Company = $row['Company'];
$Contact = $row['Contact'];
$Job = $row['Jobtitle'];	
print "<tr><td>$Company</td><td>$Contact</td><td>$Job</td></tr>";
}
?>

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.