Conditional search from two tables?
| From: | Knut Lekvam | Date: | Wed, 20 Sep 2000 10:03:02 +0000 |
| Subject: | Conditional search from two tables? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-2987@lists.php.net to get a copy of this message | ||
I have a MySQL table called "adresse" with a tinyint row called "id". I want to
use it in a second search in another table, "kommentar", wich also has a tinyint row
called "id". I used this script:
$result8 = mysql_query("SELECT * FROM adresse WHERE (gate='$gt')",$db);
while ($myrow8 = mysql_fetch_array($result8)) {
echo $myrow8["id"];
$result9 = mysql_query("SELECT * FROM kommentar WHERE (id=$myrow8["id"]) ",
$db);
$myrow9 = mysql_fetch_array($result9);
echo $myrow9["id"];
}
This gave the following error:
"Parse error: parse error, expecting
STRING' or NUM_STRING' or
`'$'' in
/home/httpd/html/script/side2.php3 on line 68"
It works ok if I put in (id=2) instead of (id=$myrow8["id"])
(it prints out my first id value in both cases, but it halted on the second when the error came).
Why cant I use (id=$myrow8["id"]) here? and how can I pick out values from the second db
based on the first search ?
I think I have now understood the point in differentiating between char and int which David Robley
and zeles pointed out to me after my last question. (Now the char variable is working nice in my
first search statement)
--
Knut Lekvam
__________________________________________________________________
Denne eposten er sendt ved hjelp av http://www.Organizer.net
- Norges ledende webbaserte kommunikasjonsløsning.