echo select query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Hammer136
Forum Commoner
Posts: 29
Joined: Sat Mar 19, 2005 12:18 pm

echo select query

Post 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
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

i am sure if you paste your codes up here, someone will help you quicker :)
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post 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)
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

I tried what you have .. And it echoed the query back to the screen fine .. ?
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

i am not sure if he wanted to echo the query only or he meant by echo the data being querried :)
Hammer136
Forum Commoner
Posts: 29
Joined: Sat Mar 19, 2005 12:18 pm

Post by Hammer136 »

what i meant was to echo the results of the query.
dakkonz
Forum Commoner
Posts: 69
Joined: Sat Dec 27, 2003 2:55 am
Location: Asia

Post 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']
Post Reply