Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-06-2012, 04:03 AM   PM User | #1
logepoge1
New Coder

 
Join Date: Oct 2012
Posts: 44
Thanks: 3
Thanked 0 Times in 0 Posts
logepoge1 is an unknown quantity at this point
No Results In PHP Table

Code:
<?php
	require('includes/header.php');
	
?>


<?php
	$sql = "SELECT customers.Country, customers.CompanyName, customers.ContactName, customers.Address, customers.City, customers.PostalCode, customers.Phone
	FROM customers
	WHERE customers.Country = '" . $_GET['country'] . "%';";
	
	$result = mysql_query($sql) or die(mysql_error());
	
echo "<table border='1'>
<tr>
<th>Company Name</th>
<th>Contact</th>
<th>Address</th>
<th>City</th>
<th>Postal Code</th>
<th>Phone Number</th>
</tr>";
while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['CompanyName'] . "</td>";
  echo "<td>" . $row['ContactName'] . "</td>";
  echo "<td>" . $row['Address'] . "</td>";
  echo "<td>" . $row['City'] . "</td>";
  echo "<td>" . $row['PostalCode'] . "</td>";
  echo "<td>" . $row['Phone'] . "</td>";
  }
echo "</table>";
		
?>

<?php
require('includes/footer.php'); 

?>
The table is blank,except for the column names, but the query runs fine in phpMyAdmin. What am I doing wrong?

Last edited by logepoge1; 12-06-2012 at 05:44 PM..
logepoge1 is offline   Reply With Quote
Old 12-06-2012, 03:31 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 362 Times in 361 Posts
sunfighter is on a distinguished road
Since you are not getting any errors, is your $_GET['country'] a country in the db?
sunfighter is offline   Reply With Quote
Old 12-06-2012, 05:10 PM   PM User | #3
logepoge1
New Coder

 
Join Date: Oct 2012
Posts: 44
Thanks: 3
Thanked 0 Times in 0 Posts
logepoge1 is an unknown quantity at this point
Quote:
Originally Posted by sunfighter View Post
Since you are not getting any errors, is your $_GET['country'] a country in the db?

As you can see it is submitting country but not getting it
logepoge1 is offline   Reply With Quote
Old 12-06-2012, 05:42 PM   PM User | #4
logepoge1
New Coder

 
Join Date: Oct 2012
Posts: 44
Thanks: 3
Thanked 0 Times in 0 Posts
logepoge1 is an unknown quantity at this point
I am going to mark this as resolved. I figured the problem. It was in the WHERE in the $sql statement. Instead of '=' it should have been 'LIKE'
logepoge1 is offline   Reply With Quote
Reply

Bookmarks

Tags
mysql, php, phpmyadmin, sql

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:59 AM.


Advertisement
Log in to turn off these ads.