jushiro Posted April 24, 2012 Share Posted April 24, 2012 I have a sql statement w/c suppose to output only those records w/c has a name of seller. But, it keeps showing all the records. <?php session_start(); if(isset($_SESSION['name']) || ($_SESSION['contact']) || ($_SESSION['address']) ) { ini_set('display_errors', 0); $name = $_SESSION['name']; $contact = $_SESSION['contact']; $address = $_SESSION['address']; ?> <div id="apDiv1"> <?php echo "Name : $name"; echo "</br>"; echo "Name : $contact"; echo "</br>"; echo "Name : $address"; ?> <div id="apDiv2"> <?php $host="localhost"; $username="root"; $password=""; $db_name="feedbackdb"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM Feedbacks WHERE Seller = $name"; $result=mysql_query($sql); echo "<table border=\"5\" width=\"600\" >"; echo "<tr><th>Feedbacks</th><th>From</th><th> To </th>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<tr><td>"; echo "" .$row['Feedback']."<br></td>"; echo "<td>".$row['From']."<br></td>"; echo "<td>".$row['Seller']."<br></td>"; echo "</tr>"; } } else { echo "<tr><td align=\"center\"> No Feedback</td></tr>"; } ?></div> </div> <?php } else { header("location:loginpage.php");; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/261525-coding-help-pls/ Share on other sites More sharing options...
wigwambam Posted April 24, 2012 Share Posted April 24, 2012 $sql="SELECT * FROM Feedbacks WHERE Seller = '$name'"; Quote Link to comment https://forums.phpfreaks.com/topic/261525-coding-help-pls/#findComment-1340056 Share on other sites More sharing options...
cpd Posted April 24, 2012 Share Posted April 24, 2012 You need to wrap strings in quotation marks as wigwambam has done in his correction. Quote Link to comment https://forums.phpfreaks.com/topic/261525-coding-help-pls/#findComment-1340075 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.