Forum Moderators: coopster
Queried first database and am passing results like this for example:
<?php echo $home['dimen'];?>
Now I want to query second database using the userid from first query (this is written incorrectly):
$result = mysql_query("SELECT a, b, c FROM lists WHERE userid='<?php echo $home['userid'];?>'");
How do I get userid to equal the value of <?php echo $home['userid'];?>
How is this written?
don't forget using
$home=mysql_real_escape_string($home);
use the above if magic_quotes_gpc is off
if it is on then stripslahes()
$result = mysql_query("SELECT a, b, c
FROM lists
WHERE userid='$id' "or die (mysql_error());
remove "die" on production server
The first query is in an array format:
'userid' => '',
Values are displayed using format: <?php echo $home['userid'];?>
Works:
$result = mysql_query("SELECT a, b, c FROM lists WHERE userid='27'");
Doesn't Work:
$result = mysql_query("SELECT a, b, c FROM lists WHERE userid='<?php echo $home['userid'];?>'");
Just need to figure out how to get value from <?php echo $home['userid'];?> inside query.