Adding a new entry using PHP
| From: | Alistair Hayward | Date: | Thu, 08 Apr 2004 00:25:24 +0000 |
| Subject: | Adding a new entry using PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-182758@lists.php.net to get a copy of this message | ||
Hi,
I am an ASP user, now learning PHP.
When adding a record in ASP, I do this:
Recordset.AddNew
Field1 = whatever
RecordSet.Update
How is this done in PHP?
I have built a recordset using a query, and have all the information needed to go into the different fields, but how do I 'Edit' or 'AddNew' and 'Update'?
This is what I have:
<?php
unset($price);
$price = $_GET['Price'];
unset($id);
$id = $_GET['id'];
unset($partnumber);
$partnumber = $_GET['PartNumber'];
unset($disc);
$disc = $_GET['Disc'];
$link = mysql_connect('localhost', 'root', 'password');
if (!$link) {
echo "Couldn't make a connection!";
exit;
}
$db = mysql_select_db("order", $link);
if (!$db) {
echo "Couldn't select database!";
exit;
}
$sql= "SELECT * FROM tborder WHERE sid='session.sessionid'";
$result = mysql_query($sql);
$total_records = mysql_num_rows($result);
?>