Weird...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Weird...

Post 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
User avatar
EvilWalrus
Site Admin
Posts: 209
Joined: Thu Apr 18, 2002 3:21 pm
Location: Springmont, PA USA

Post by EvilWalrus »

Um, because you're fetching an array?

And, um, why the multiple queries? Just combine them all into one.
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Post 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 !
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post 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
Post Reply