Skippy
03-03-2010, 09:47 PM
In one table of my database called 'users' I store values called `id`, `giftID`, `gifttitle` and `value`.
In another called 'gifts' I store `id`, `gifttitle`, `image` and `value`.
Now, I need to be able to call the id from users to grab the gift title, image and value that the user has selected.
How would I be able to do this?
I tried using this code:
<?php
$ugid = $_SESSION['id'];
$giftresult = mysql_query("SELECT * FROM users WHERE id='$ugid'");
$giftusers = mysql_fetch_array($giftresult);
$giftid = $giftusers['giftID'];
$result = mysql_query("SELECT * FROM gifts WHERE id='$giftid'");
while($list = mysql_fetch_array( $result )){
echo $list['giftID'];
}
?>
However that just lists all the gift id in the users field stored in the database.
Thanks.
In another called 'gifts' I store `id`, `gifttitle`, `image` and `value`.
Now, I need to be able to call the id from users to grab the gift title, image and value that the user has selected.
How would I be able to do this?
I tried using this code:
<?php
$ugid = $_SESSION['id'];
$giftresult = mysql_query("SELECT * FROM users WHERE id='$ugid'");
$giftusers = mysql_fetch_array($giftresult);
$giftid = $giftusers['giftID'];
$result = mysql_query("SELECT * FROM gifts WHERE id='$giftid'");
while($list = mysql_fetch_array( $result )){
echo $list['giftID'];
}
?>
However that just lists all the gift id in the users field stored in the database.
Thanks.