Jump to content

Newbie trying to echo some data


Raven1313

Recommended Posts

 

Hello Everyone,

 

I'm new to PHP and I'm trying to output some data using PHP and MYSQL.

 

When I use my MYSQL Query Browser and I type this:

select PREF from  hist_index where DATE(PDATE) = DATE(NOW()) AND STKNO = 11;

 

I get the data I need, which is the Price Index of today.

 

But when I echo this out; I get:

Resource id #4

 

 

I have a project which outputs 10 variable that are available on hist_index table (8 of them under the row where STKNO=11, and the other two are when STKNO=10).

 

I can query the data but I can't seem to find a way to echo them.

 

I read that making an array is the way to go.

Instead of "select"ing them one by one, I can select them all and assign them to an array then out put the array. Do I HAVE to use arrays to out put them?

 

Thank in advance :)

 

Link to comment
https://forums.phpfreaks.com/topic/264041-newbie-trying-to-echo-some-data/
Share on other sites

you are echoing out the resource created from running the query. you need to actually fetch the records:

 

$result = mysql_query("select PREF from  hist_index where DATE(PDATE) = DATE(NOW()) AND STKNO = 11");
while($row = mysql_fetch_array($result)){
echo $row['PREF];
}

 

hope it helps :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.