arraysg2008
asked on
Want to be able to Add, Edit and Search in the same form using PHP and mySQL
I created a simple form with multiple buttons for this question, what I would like to do is when I press the Add button it takes the information from the three for inputs and adds it to a mySQL database. The Add is done, I am able to hit the Add button and it connects to my database and adds the fields in, the part I'm confused about is the Edit and Search buttons.
What I want to be able to do is type in a First Name or Last name or both and be able to hit search and the record populates into the input fields in the form, from there I would like to be able to edit this data and hit the Edit button and it writes the new information into that record. I am still learning PHP and SQL so please bear with me.
What I want to be able to do is type in a First Name or Last name or both and be able to hit search and the record populates into the input fields in the form, from there I would like to be able to edit this data and hit the Edit button and it writes the new information into that record. I am still learning PHP and SQL so please bear with me.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form action="form.php" method="post">
First Name: <input type="text" name="firstname" size="15"> <br>
Last Name: <input type="text" name="lastname" size="15"> <br>
Department: <input type="text" name="department" size="15"> <br>
<input type="submit" name="user" value="Add">
<input type="submit" name="user" value="Update">
<input type="submit" name="user" value="Search">
</form>
<?php
switch ($_POST['user']) {
case 'Add':
echo "Add";
break;
case 'Update':
echo "Updated";
break;
case 'Search':
echo "Search";
break;
}
?>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is perfect, thank you
The other way I could see you accomplishing this without the table is by getting crafty with some javascript, paging through your results with a forward/backward type control given multiple results.