Page 1 of 1

echo select query

Posted: Sun Mar 20, 2005 2:07 pm
by Hammer136
Hi

Im new to programming but i have been able to create a table and to set up a successful login script. However, i want to echo a select query and no matter what i try i fail. Any help appreciated. This is with mysql. Thanks.

Hammer

Posted: Sun Mar 20, 2005 2:35 pm
by hongco
i am sure if you paste your codes up here, someone will help you quicker :)

Posted: Sun Mar 20, 2005 3:19 pm
by nickvd
The way I do it (when I'm not using my db class) is as follows

Code: Select all

$query = "SELECT * FROM `table` WHERE field = 'value'";
mysql_query ($query);
that way, if you ever need to see what the query was, it's as simple as

Code: Select all

echo $query;
very useful if you are building a query using variables, or a loop, etc...

my db class has built-in query debugging that echo's the query if i want it too (using the same method as above)

Posted: Sun Mar 20, 2005 3:32 pm
by Jim_Bo
Hi,

I tried what you have .. And it echoed the query back to the screen fine .. ?

Posted: Sun Mar 20, 2005 3:53 pm
by hongco
i am not sure if he wanted to echo the query only or he meant by echo the data being querried :)

Posted: Mon Mar 21, 2005 1:39 am
by Hammer136
what i meant was to echo the results of the query.

Posted: Mon Mar 21, 2005 1:57 am
by dakkonz

Code: Select all

$query ="SELECT ..." 
$result = mysql_query ($query);
$row = mysql_fetch_array($result);
then u can get ur results by echoing out ur $row['column name']