Thursday, 12 September 2013

No output being displayed when passing values through Get

No output being displayed when passing values through Get

I have this piece of code, which should retrieve the value from the
database and then print in on the page, I have created links that will
pass value to the page and then I retrieve the value from GET and the
result should be printed, but is it happening? NO!, I am not getting any
errors on the page, rather I am getting nothing on the result page cos its
a blank page.
function retrieve($resul)
{
//$resul=mysql_query($qry);
if($resul)
{
echo '<table class="pos" cellspacing="10">' ;
echo '<tr>';
$x = 0;
while($result=@mysql_fetch_array($resul,MYSQL_ASSOC))
{
if($x<2)
{
echo '<td>' ;
echo '<div class="img-wrap"> <div style="300 px; font-size:15px;
text-align:center; background-color= "ff0066;">' ;
echo "<img src='{$result['image']}' alt='alternate text' width='220px'
height='200px' style='padding-bottom:1.0em;' >" ;
echo "<b>";
echo $result['company'] . " " . $result['model'] ;
echo "</b>" ;
echo "<br>";
echo $result['cpu'] ."/" . $result['ram'] ."/" . $result['HDD'];
echo "<br>";
echo "<b>" . $result['price'] ."<b>" ;
echo '</div>' ;
echo '</td>' ;
$x++;
}
else
{
echo '<td>' ;
echo '<div class="img-wrap"> <div style="300 px; font-size:15px;
text-align:center; background-color= "ff0066;">' ;
echo "<img src='{$result['image']}' alt='alternate text' width='220px'
height='200px' style='padding-bottom:1.0em;' >" ;
echo "<b>";
echo $result['company'] . " " . $result['model'] ;
echo "</b>" ;
echo "<br>";
echo $result['cpu'] ."/" . $result['ram'] ."/" . $result['HDD'];
echo "<br>";
echo "<b>" . $result['price'] ."<b>" ;
echo '</div>' ;
echo '</td>' ;
echo '</tr>' ;
echo '<tr>' ;
$x=0 ;
}
}
echo '</table>' ;
}
}
if ( isset($_GET['company'] ))
{
$company= $_GET['company'] ;
}
if(isset($_GET['range']))
{
$range= $_GET['range'] ;
}
if(isset($_GET['cpu']))
{
$cpu= $_GET['cpu'] ;
}
if(isset($_GET['lifestyle']))
{
$lifestyle= $_GET['lifestyle'] ;
}
if(isset($_GET['display']))
{
$display= $_GET['display'] ;
}
if(isset($_GET['ram']))
{
$ram= $_GET['ram'] ;
}
if(isset($_GET['HDD']))
{
$HDD= $_GET['HDD'] ;
}
if(!empty($company))
{
$qry = "SELECT * FROM LAPTOP WHERE company='$company' " ;
$resul=mysql_query($qry);
retrieve($resul) ;
}
if(!empty($cpu))
{
$qry= "SELECT * FROM LAPTOP WHERE cpu='$cpu' " ;
$resul=mysql_query($qry);
retrieve($resul) ;
}
if(!empty($lifestyle))
{
$qry= "SELECY * FROM LAPTOP WHERE lifestyle='$lifestyle' " ;
$resul=mysql_query($qry);
retrieve($resul) ;
}
if(!empty($display))
{
$qry= "SELECT * FROM LAPTOP WHERE display='$display'" ;
$resul=mysql_query($qry);
retrieve($resul) ;
}
if(!empty($ram))
{
$qry= "SELECT * FROM LAPTOP WHERE ram='$ram' " ;
$resul=mysql_query($qry);
retrieve($resul) ;
}
if(!empty($HDD))
{
$qry= "SELECT * FROM LAPTOP WHERE HDD='$HDD' " ;
$resul=mysql_query($qry);
retrieve($resul) ;
}
?>
The links on the previous page are like this
I have checked my table that if I am committing any errors in the
uppercase and lowercase thing but its perfectly fine cos I have stored all
the information in the table after converting it into lowercase. Has it
got something to do with the function retrieve()? PS: I will change the
functions to mysqli() once this script works Thanks in advance

No comments:

Post a Comment