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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.