Newbie-Prob

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Thanatos
Forum Newbie
Posts: 3
Joined: Thu Jul 04, 2002 8:19 am
Contact:

Newbie-Prob

Post by Thanatos »

Hi,
my prob is the following:

$result = mysql_query("SELECT * FROM week WHERE id = 1")
or die (mysql_error());

This gives me " Resource id #2", but what I want to have is the content of the row with id 1.

What did I make wrong?

Greets
Thanatos
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

$result is a result resource to get the information you are looking for you have to go one step further:

Code: Select all

$info = mysql_fetch_assoc($result);
Then you can work with $info because it is an associative array full of all the data from your table:

Code: Select all

foreach ($info as $field => $value) {
    echo $field.' = '.$value.'<br />';
&#125;
This will show you all the info in the first row of the result. For more information check out mysql_fetch_assoc() in the manual.

Mac
Thanatos
Forum Newbie
Posts: 3
Joined: Thu Jul 04, 2002 8:19 am
Contact:

Post by Thanatos »

Cool. It works...

Thanks a lot !
Post Reply