Page 1 of 1

Weird...

Posted: Wed Mar 03, 2004 11:06 pm
by Flamie

Code: Select all

<?php

$pastevar =$HTTP_POST_VARS['id'];


print "$pastevar";

$winc = mysql_fetch_array( mysql_query( "select clanid1 from games_rep where id = '$pastevar'" ) );
$losc = mysql_fetch_array( mysql_query( "select clanid from games_rep where id = '$pastevar'" ) );
$plaw1 = mysql_fetch_array( mysql_query( "select win_play1 from games_rep where id = '$pastevar'" ) );
$plaw2 = mysql_fetch_array( mysql_query( "select win_play2 from games_rep where id = '$pastevar'" ) );
$plal1 = mysql_fetch_array( mysql_query( "select los_play1 from games_rep where id = '$pastevar'" ) );
$plal2 = mysql_fetch_array( mysql_query( "select los_play2 from games_rep where id = '$pastevar'" ) );
echo " $winc, $losc, $plaw1, $plaw2, $plal1, $plal2 ";
?>
$pastevar is the good number, the one I input in the previous page, but for some reason, the variables $winc, $losc, $plaw1, $plaw2, $plal1, $plal2 are all 'array'..
Anyone knows why ?


thx
Flamie

Posted: Wed Mar 03, 2004 11:09 pm
by EvilWalrus
Um, because you're fetching an array?

And, um, why the multiple queries? Just combine them all into one.

Posted: Wed Mar 03, 2004 11:11 pm
by Flamie
if its a text I'm fetching I do mysql_fetch_text ?
How do I combine them all in one ?
Sorry I'm a bit noobish :D
Thx for the help !

Posted: Thu Mar 04, 2004 1:22 am
by andre_c
you should select them all like this:

Code: Select all

$query = mysql_query("select clanid1, clanid, 
                 win_play1, win_play2 
                 los_play1, los_play2
               from games_rep 
              where id = '$pastevar'
          ") or die(mysql_error());

$results_array = mysql_fetch_array($query);

echo $results_array['clan_id1'];
echo $results_array['clan_id2'];
// and so forth