I am trying to retrieve some information from database but I guess I am doing something wrong because I am only able to retrieve half info not full. Please let me know where i am wrong
In Below code there are two SQL statements 1st) $sql and 2nd) $result. I have problem in $sql statement.
UPDATE- QUESTION HAS BEEN SOLVED.SEE Below for answer
<?php
include "head.html";
echo '</div>';
$search_id = $_GET["id"];
$dbhost = 'localhost';
$dbuser = 'lemonwork';
$dbpass = 'lemonwork@2014';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
$sql = 'SELECT * FROM lemontable where STORE_ID=';
$val=" AND (DESCRIPTION=%'Toy'% OR TITLE=%'TOY'% OR Category=%'TOY'%)";
$sql=$sql.$search_id.$val;
$result='SELECT STORE_LOGO, Lemon_COUNT FROM lemoncount where STORE_ID=';
$result=$result.$search_id;
mysql_select_db('lemondata');
$retval = mysql_query( $sql, $conn );
$retval1=mysql_query($result, $conn);
$x=0;
if ($result) {
$row1 = mysql_fetch_assoc($retval1);
echo'<div style="text-align: center;">';
echo'<img src="'.$row1['STORE_LOGO'].'"style="display: block; margin-left: auto; margin-right: auto;">';
echo 'Total Coupons: '.$row1['COUPON_COUNT'].'<br/>';
echo'</div>';
}
if(! $retval ) {
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
echo "<table>";
echo '<tr><th><a href="'.$row["LINK"].'"><img src="'.$row1["STORE_LOGO"].'"></th>';
echo "<td style='padding-left: 6px !important;'><a href='".$row['LINK']."'><h1>".$row["title"]. "</h1></a>";
echo "<br/><strong>By</strong> ".$row["STORE_NAME"]."<br/><strong>Expire on:</strong> ".$row["Dates"]."<br/><strong>Category:</strong> ".$row["Category"]."<br/><strong>work:</strong> ".$row["work"]."<br/><strong>DESCRIPTION:</strong> ".$row["DESCRIPTION"]."<b style='color:Blue'> Read More"."<hr></td></tr>";
}
echo '</table>';
mysql_close($conn);
?>