Thanks for the comments,. I'm putting some code here to hopefully get an
idea of what is considered inefficient when dealing with mysql. I'm confused
because all I'm doing is collecting the data from a form and writing it to
the db. I have about 30 pages in the survey, so a script similar to this is
called after each page.


$connection = mysql_connect($host,$user,$password)
       or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
       or die ("Couldn't select database");

$intable = "tablename";

/* this is the duplicate check section */
$sql = "SELECT * FROM $intable WHERE datein = '$datein' AND itemID='$itemID'

$mysql_result = mysql_query($sql,$connection);
$num_rows = mysql_num_rows($mysql_result);

if ($num_rows == 0) {
/* insert if no dupes */
$query = "INSERT INTO itemsread (itemread,itemID,datein) VALUES
$result = mysql_query($query);
/* update if existing timestamp */
$query = "UPDATE $intable SET itemread='$itemread' WHERE datein='$datein'
AND itemID='$itemID' ";
$result = mysql_query($query);
} # end else

It seems pretty simple to me. What am I missing?

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to