RE: Entering a Query

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

 



> I would be very interested to see an example of how it would be
possible
> to
> enter a query into a text area and the results of the query displayed
on
> the
> next page, similar to PHP admin I guess, are they any examples out
there?

Issue the query with mysql_query() and check for an error. If there's an
error, display mysql_error() or do your own error handling. From there,
you'll count the number of fields returned by mysql_num_fields(). Loop
through with mysql_field_name() to create your "header" row. The
"header" text will match whatever the name of the column was. Then loop
through mysql_fetch_row() to get all of the rows returned from the
query. You already know how many fields there are, so just loop through
the result of mysql_fetch_row() that many times and put each element in
it's own <td> tag. 

That's pretty much it.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
  



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