Re: results of query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Will this work (assume you're using mysql):


function printresult ($rs)
{
	if ($a = mysql_fetch_assoc($rs))
	{
		// Print header

		echo '<table><tr>';

		foreach (array_keys ($a) as $v)
			echo '<th>' . $v . '</th>';

		echo '</tr>';

		while ($a)
		{
			echo '<tr>';
			foreach ($a as $v)
				echo '<td>' . $v . '</td>';
			echo '</tr>';

			$a = mysql_fetch_assoc($rs);
		}

		echo '</table>';
	}
	else
		echo '<b>No results found.</b>';
}

You can embellish the resulting HTML code as needed. (Also, please note
that I'm doing this from memory... so it might not work right off ;)


Marco

On Mon, 2002-10-07 at 16:07, Edward Peloke wrote:
> What does everyone typically use to display the results of a query.  For
> example, I have a database that has a series of subjects and grades.  If I
> select * from the table, I want a nice way for the data to be displayed.  In
> cold fusion, I can simply use a grid that dynamically fills in.  Can I do
> this with php?
> 
> Thanks,
> Eddie
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux