Alright I have a MYSQL database with data for Clients. I am displaying this Client info on a HTML Table. I want the last 2 Table Cells to have EDIT and DELETE Functions. I am almost there I just need a final solution to linking them together and getting them to talk.
http://www.daniweb.com/web-development/php/threads/111269 This was a good post but he was getting the URL from MYSQL I just want modify.php and then the id.
Here is my HTML Table Page (Its a WIP)
<html>
<head>
<title>Vipre Database</title>
<meta http-equiv="content-type" content="text/html; charset=uf-8" />
<style type="text/css">
lable { display: block; }
</style>
<script src="sorttable.js"></script>
</head>
<body>
<a href="addclient.php">Add Client</a>
<?php
include_once 'resources/init.php';
$query="SELECT * FROM Client";
$result=mysql_query($query);
mysql_close();
?>
<?php
//Table starting tag and header cells
echo "<table class='sortable' border='1' cellspacing='5' cellpadding='5'><tr><th>First Name</th><th>Last Name</th><th>Email</th><th>Invoice #</th><th>Windows Key</th><th>Windows Type</th><th>VIPRE Type</th><th>User Count</th><th>Year Count</th><th>Start Date</th><th>Expire Date</th><th>Vipre Key</th><th>Edit Client</th></tr>";
while($row = mysql_fetch_array($result)){
//Display the results in differnt Cells
echo "<tr><td>" . $row['firstname'] . "</th><td>" . $row['lastname'] . "</td><td>" . $row['email'] . "</td><td>" . $row['invoice'] . "</td><td>" . $row['wink'] . "</td><td>" . $row['wint'] . "</td><td>" . $row['vtype'] . "</td><td>" . $row['usera'] . "</td><td>" . $row['yeara'] . "</td><td>" . $row['sdate'] . "</td><td>" . $row['edate'] . "</td><td>" . $row['viprek'] . "</td><td><a href=\"modify.php?id=" . $row['id'] . "Edit</a>" . "</td></tr>";
}
echo "</table>";
?>
</body>
</html>
Here is my Edit Page
<?php
include 'init.php';
if (isset ($_POST['submit'])) {
$q = "SELECT * FROM Client WHERE id = $_GET[id]";
$result = mysql_query($q);
$client = mysql_fetch_array($result);
}
?>
<a href="index.php">Back To List</a>
<form action="insert.php" method="post">
First Name: <input type="text" name="firstname" value="<?php echo $client['firstname']; ?>" />
Last Name: <input type="text" name="lastname" />
<br>
<br>
Email: <input type="text" name="email" />
<br>
<br>
Invoice #:<input type="text" name="invoice" maxlength="5" size="5" />
<br>
<br>
<br>
<br>
Windows Key:<input type="text" name="wink" maxlength="24" size="24" />
Windows Type:<input type="text" name="wint" maxlength="24" size="24" />
<br>
<br>
<br>
<br>
VIPRE Type:<input type="text" name="vtype" maxlength="3" size="3" />
User Count:<input type="text" name="usera" maxlength="3" size="3" />
Year Count:<input type="text" name="yeara" maxlength="3" size="3" />
<br>
<br>
Start Date:<input type="text" name="sdate" maxlength="10" size="10" />
Expire Date:<input type="text" name="edate" maxlength="10" size="10" />
<br>
<br>
VIPRE Key: <input type="text" name="viprek" maxlength="24" size="24" />
<br>
<br>
<br>
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>" />
<input type="submit" />
</form>
<?php
if(isset($_POST["submit"])) {
$u = "UPDATE Client SET `firstname`='$_POST[firstname]' WHERE id = $_POST[id]";
mysql_query($u) or die (mysql_error());
echo "User has been modified!";
header("Location: index.php");
} else {
}
?>