1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Rep Power
    Why won't my if statements work with mysql_query arrays? No matter what I seem to do, it refuses to return true. When I make echo call the value (after the if statement has been executed as false), it returns to me the value that should have made the if statement true! I would figure it was a type problem, but there is no typing in PHP. Anyone care to help me? Here's the code. (I've tried the evaluating values in quotes, without quotes, with single quotes, in variables, on top of pop while he was cleaning with a mop...)
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    mysql_connect (localhost, blar, blar);

    mysql_select_db (news);

    $result = mysql_query ("SELECT * FROM game_reviews order by id desc");

    echo("<font size="1" face="Verdana">Action:<br>");

    //populate action
    while($row = mysql_fetch_array($result)){
    if($row["genre"] == "action") {
    echo("<IMG SRC="blank.gif" height="1" width="20"><A HREF="{Grv}");
    echo("<font size="1" face="Verdana">Racing:<br>");
  2. #2
  3. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Enschede, The Netherlands
    Rep Power
    try this:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
    mysql_connect( host, user, pwd );
    mysql_select_db( database );
    $result = mysql_query( "SELECT * FROM table ORDER BY id DESC" );
    if ( $row = mysql_fetch_array( $result ) ) {
    do {
    if ( $row["genre"] == 'action' ) {
    print( "info" );
    while( $row = mysql_fetch_array( $result ) );
    else {
    print( "Result is empty" );

    You could do a second query to retrieve the different genre's first... (SELECT * FROM table GROUP BY genre ORDER BY genre) which returns the different genre's. While doing the do-while loop make another query (SELECT * FROM table WHERE genre=$genre) with $genre=$row["genre"]...

    The result would be something like:

    Game 1
    Game 2

    Game 3
    Game 4

    I hope this helps you.
    If you have any questions don't hesitate and let me know


Similar Threads

  1. php script won't work inside "cgi-local" directory
    By Volitics in forum PHP Development
    Replies: 5
    Last Post: April 26th, 2004, 10:50 PM
  2. Can View It At Work But Not At Home?
    By steral in forum DNS
    Replies: 4
    Last Post: February 17th, 2004, 07:45 AM
  3. Experienced undergrad senior ... freelance work wanted
    By carrja99 in forum Hire A Programmer
    Replies: 0
    Last Post: January 28th, 2004, 11:32 PM
  4. I'll pay someone $150 to do some PHP work for me!
    By Noah Neiman in forum Hire A Programmer
    Replies: 16
    Last Post: January 23rd, 2004, 03:15 AM
  5. I need some specific php work done for my website
    By Noah Neiman in forum Hire A Programmer
    Replies: 1
    Last Post: January 20th, 2004, 11:31 PM

IMN logo majestic logo threadwatch logo seochat tools logo