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
https://forums.phpfreaks.com/topic/165735-solved-calling-nothing/
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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.