Jump to content

[SOLVED] Calling nothing?


onthespot

Recommended Posts

Can anyone understand this problem? I am calling from a table in my database which works fine when I don't include a WHERE. However when I do, i get nothing back.

 

The php:

<?php


function show_league_image($type)
{
   $images = array ( 'league1' => 'first.jpg',
                     'league2' => 'second.jpg',
                     'league3' => 'third.jpg'
                   );

    if(array_key_exists($type, $images))
        return '<img src="images/awards/'.$images[$type].'" width="16" height="36" />';

    return false;
}

$res=mysql_query("SELECT * FROM ".TBL_AWARDS."  WHERE awarduser = '$awarduser2' ORDER BY awarddate");

while($row=mysql_fetch_assoc($res)){

$type=$row['awardtype'];
$awarduser=$row['awarduser'];
$awarduser2 = $_GET['user'];
echo show_league_image($type)

}
?>

 

This just won't work, however when I remove the WHERE, it will?

Link to comment
Share on other sites

Can anyone understand this problem? I am calling from a table in my database which works fine when I don't include a WHERE. However when I do, i get nothing back.

 

The php:

<?php


function show_league_image($type)
{
   $images = array ( 'league1' => 'first.jpg',
                     'league2' => 'second.jpg',
                     'league3' => 'third.jpg'
                   );

    if(array_key_exists($type, $images))
        return '<img src="images/awards/'.$images[$type].'" width="16" height="36" />';

    return false;
}

$res=mysql_query("SELECT * FROM ".TBL_AWARDS."  WHERE awarduser = '$awarduser2' ORDER BY awarddate");

while($row=mysql_fetch_assoc($res)){

$type=$row['awardtype'];
$awarduser=$row['awarduser'];
$awarduser2 = $_GET['user'];
echo show_league_image($type)

}
?>

 

This just won't work, however when I remove the WHERE, it will?

 

You specify $awarduser2 AFTER the query, so $awarduser2 is always blank in the query.

 

$awarduser2 = mysql_real_escape_string($_GET['user']);
$res=mysql_query("SELECT * FROM ".TBL_AWARDS."  WHERE awarduser = '$awarduser2' ORDER BY awarddate");

 

And remove

$awarduser2 = $_GET['user'];

from your while loop.

 

Edit - Also, don't bump your thread after only 20 minutes. Your thread will be gotten to eventually.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.