Forum Moderators: coopster

Message Too Old, No Replies

mysql printing php?

         

Sarah Atkinson

5:14 pm on Jun 29, 2005 (gmt 0)

10+ Year Member



Is there a function in php that prints a mysql query similar tohow it would be output if it were done from the mysql prompt?

mcibor

8:28 am on Jun 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could you please explain it more clearly?

You need a function that would check mysql syntax? Or function that will return the table with table names and then the rows?

If the latter then there's such a function
To get the field names:
mysql_list_fields()
to get the rows:
mysql_fetch_array()

There's not one function that would that both, because php is for writing html, not text output.

hope this helps you
Michal

jatar_k

4:18 pm on Jun 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if I understand properly you are looking for the

-------
¦ ¦ ¦ ¦
-------

style of the prompt, the answer would be no, not exactly like that you would have to build it, what I normally use is

$q = 'select * from mytable';
$query = mysql_query($q);
echo '<pre>';
while ($row = mysql_fetch_array($query)) {
print_r($row);
}
echo '</pre>';

that at least dumps everything in a very readable array style format

Sarah Atkinson

6:17 pm on Jun 30, 2005 (gmt 0)

10+ Year Member



i just ended up runing them in the sql part of phpmyadmin.

I wanted to visualy see how the different type of joins worked.