Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2012
    Posts
    44
    Thanks
    3
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,166
    Thanks
    23
    Thanked 600 Times in 599 Posts
    Since you are not getting any errors, is your $_GET['country'] a country in the db?

  • #3
    New Coder
    Join Date
    Oct 2012
    Posts
    44
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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

  • #4
    New Coder
    Join Date
    Oct 2012
    Posts
    44
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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'


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •