0
 //case for database search
case "Search":
if(isset($firstname, $lastname)){
mysql_select_db("webuser23", $dbc);
$result = "SELECT * FROM customers WHERE firstname='.$firstname.' ";
mysql_query($dbc);

echo "<table border='1'>";
echo "<tr>";
echo "<th>Firstname</th>";
echo "<th>Lastname</th>";
echo "<th>Phone</th>";
echo "<th>Address</th>";
echo "<th>City</th>";
echo "<th>State</th>";
echo "<th>Zip</th>";

echo "</tr>";

while($row = mysql_fetch_array($result))
    {
echo "<tr>";
  echo "<td>" . $row['firstname'] . "</td>";
  echo "<td>" . $row['lastname'] . "</td>";
  echo "<td>" . $row['phone'] . "</td>";
  echo "<td>" . $row['address'] . "</td>";
  echo "<td>" . $row['city'] . "</td>";
  echo "<td>" . $row['state'] . "</td>";
  echo "<td>" . $row['zip'] . "</td>";
  echo "</tr>";
echo "</table>";
    }
    if (!mysql_query($result, $dbc))
  {
  die('Error: ' . mysql_error());
  }

mysql_close($dbc);
}
  break;

//I only see the table headers, but i cannot see the row with database values. Please help.

2
Contributors
2
Replies
29
Views
4 Years
Discussion Span
Last Post by Edwinner
3

Change line 5 and 6:

$query = "SELECT * FROM customers WHERE firstname = '$firstname'";
$result = mysql_query($query);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.