Click to See Complete Forum and Search --> : [RESOLVED] Anoying query problem that i need explaining.


mitchell
03-09-2008, 07:14 PM
Hi everyone i have a prob. know when you have a page with a SELECT query, to display all the pages results e.g

$info = sql_query (SELECT.......

echo "
$info[detail]

$info[name]
"

what should i do if i want to add another piece of user info between [detail] and [name] but it requires another query so it gets the data.
like this:

$result = mysql_query("SELECT * FROM alliance WHERE id='" . $user['alliance'] . "'");
$row = mysql_fetch_assoc($result);
echo "$row['alliance_name'] ;

it just doest work if i have more than one query in a script. i need advise.
please help me with my prob:confused:

skywalker2208
03-09-2008, 09:12 PM
I don't really understand what you are asking. Are you wanting to get information from two different tables?

Huevoos
03-10-2008, 03:13 AM
Do you mean like this?

SELECT
t1.id,
t2.name
FROM
table1 as t1,
table2 as t2
WHERE
t1.data1 = "MyData"
AND
t2.id = t1.id

mitchell
03-10-2008, 05:25 AM
Yeah i want to get information from two different tables in a same script. which i need 2 querys but having more than one query in a script brakes it, does anyone know what the page layout of having more than one query

Znupi
03-10-2008, 03:06 PM
I don't see any reason why the script would "brake it" if you use more than one query. If you can make one query, you can make how many queries you like. The only reason I see why your second query wouldn't work, is an error in your code.

mitchell
03-10-2008, 07:20 PM
it was, :rolleyes: thanks