Hello all. Well, I posted about search results and thanks for the help. I modify even more that it includes a select option next to the person's name. This is where I have the trouble.
Objective is the person that I search, I can click "select" on that person, and get even more information, such as postalcode, address, password, etc. Such attempts though, including gathering all 50 names after I click select, displaying nothing, etc. Not sure if I have to do another IF statement or not. 1st code is 100% fine, just for reference line 27 is where I added to ensure a button to customer_update. 2nd code i'm stumped. I just need guidance. Code only includes "firstName", since I don't want to make the code short here.
<?php
if(isset($_POST['submit'])) {
if(isset($_GET['go'])) {
if(preg_match("/^[A-za-z]+/", $_POST['lastName'])){
//connect
$db = mysql_connect("localhost", "kaviles", "0648637") or die ('I cannot connect to the database because: ' . mysql_error());
$mydb=mysql_select_db("kaviles_tech_support");
$name=$_POST['lastName'];
//
$sql = "SELECT * FROM customers WHERE lastName = '$name'";
$result = mysql_query($sql);
//INfomration getting DB
echo "<h1> Results </h1>";
echo "<table>";
echo "<tr> <th>Last Name</th> <th>First Name</th> <th>Email</th> <th>City</th> <th> </th> <th></th></tr>";
while ($row = mysql_fetch_array($result)){
$lastName = $row['lastName'];
$firstName = $row['firstName'];
$email = $row['email'];
$city = $row['city'];
echo '<form method="post" action="customer_update.php?customerID=$row[customerID]">';
echo "<tr> <td>".$row['lastName']."</td><td>".$row['firstName']."</td> <td>".$row['email']."</td> <td>".$row['city']."</td> <td>" . '<input type=' . 'submit' . ' value=' .'Select' .'>'. "</td><td></td></tr>";
echo "<label>" . ' ' . "</label>";
echo "</form>";
echo "</tr>";
}
echo "</table>";
}
}
}
else
{
echo "<p>Please input a valid name</p>";
}
?>
<?php
$db = mysql_connect("localhost", "username", "pw") or die ('I cannot connect to the database because: ' . mysql_error());
$mydb=mysql_select_db("db name");
$customerID=$_GET['customerID'];
$sql = "SELECT * FROM customers WHERE customerID =". $customerID."";
$result=mysql_query($sql);
while ($row = mysql_fetch_array($result)){
$firstName = $row['firstName'];
echo "<h1>View/Update Customer</h1>";
echo '<form action="index.php" method="post" id="customer">';
echo '<input type="hidden" name="action" value="update_customer" />';
echo '<label>First Name:</label>';
echo "<input type=" . 'text' ." name=". 'firstName' ." value=" .$row['firstName'];" ?> />";
echo' <br />';
echo '</form>';
echo '<p><a href="index.php?action=list_customers">Search Customers</a></p>';
}
?>
$sql = "SELECT * FROM customers WHERE customerID =". $customerID.""; is probably given me troubles me thinks, since if I delete "where" it'll just produce all results of first name.
Tried using IF, wasn't getting my results.
if(isset($_GET)){
$customerID=$_GET;
Anywho, any help is much appreciated.