Hi, I'm not sure if this is the correct forum, please let me know and forgive me if I am wrong. I have a small database I have built using php and mysql, it's just for practice to help me better understand the workings of the code. Anyway, I have data in my table and can display the table in a browser. What I'd really like to be able to do is display the information in the table using a web based form that resembles the input form used to input the data originally, and navigate through the records by pushing a navigation button. I have gone through tutorial after tutorial and read books and advice...I think I am really stuck
If anyone could help me...at least point me in the right direction I would be forever thankful.
Here is the code I am using to populate my table, if it helps.
<?php
//$conn = mysql_connect('localhost', 'root')or die(mysql_error());
include('connect.php');
$create = mysql_query("CREATE DATABASE IF NOT EXISTS db1") or die(mysql_error());
mysql_select_db ("db1");
?>
<form name ="form"method ="post" action ="form1.php">
<p>First Name: <input type ="text" name ="fname">
Last Name: <input type ="text"name ="lname"><br><br>
address: <input type="text" name ="address"><br><br>
address2: <input type="text" name ="address2" ><br><br>
City: <input type ="text" name ="city"><br><br>
State: <input type ="text" name ="state"><br><br>
Zip: <input type ="text" name ="zip"><br><br>
Phone:<input type ="text" name ="phone"><br><br>
Notes:<input type ="textarea" name ="notes">
</p>
<p> </p>
<p> </p>
<p> </p>
<p>Search: <input type ="text" name ="fname"> <br>
<br>
<input type ="hidden" name ="key">
<input type ="submit" name ="submit" value ="Query">
</p>
</form>
<?php
//create table
$testdb = 'CREATE TABLE IF NOT EXISTS testable(id int (11) NOT NULL auto_increment,
lname varchar(40) NOT NULL,
fname varchar(40) NOT NULL,
address varchar(40) NOT NULL,
address2 varchar(40) NOT NULL,
city varchar(15) NOT NULL,
state varchar(2) NOT NULL,
zip int(5) NOT NULL,
phone varchar(11) NOT NULL,
notes longtext NOT NULL,
PRIMARY KEY(id),
KEY testype(lname, fname))';
$result = mysql_query($testdb) or die(mysql_error());
$lname = $_POST['lname'];
$fname = $_POST['fname'];
$address = $_POST['address'];
$address2= $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$notes = $_POST['notes'];
//"$address", address,
$insert = "INSERT INTO testable( id, lname, fname, address, address2, city, state, zip, phone, notes)
VALUES(0, '$lname', '$fname', '$address', '$address2', '$city', '$state', '$zip', '$phone', '$notes' )";
$results =mysql_query($insert) or die ("Couldn't insert into database because: " .mysql_error());
if(mysql_affected_rows()==1)
{
echo "Success!";
}
else
{
echo "Failed" . mysql_error();
}
if($insert)
{
echo 'Data inserted successfully!';
}