Reply to Disallow duplicate entries...

Your name:

Reply:


Posted by sloane.irwin on 07/27/06 19:47

Hello,
I've just finished my first PHP/mySQL database and it's working great.
I can enter info, change info, and delete it with no problem, all
fields are working.

Unfortunately, people are starting to add duplicate items, which is
annoying me, as I have to go through and delete these duplicates. This
is fine right now when there's only 30 entries in it, but by the end of
the month there will be nearly 300 and that will be no fun to deal
with.

I know there is some code that I could add to search for both the
inventory number and the serial number to see if either still exists,
and if so, a button to see it or to cancel and go back.

Any ideas? My code for the db_insert.php file follows:

<html>
<body>
<?
require('db_login.php');
require('db_connect.php');

// the table you want to add to



$table = 'data';


// begin the query

$query = "INSERT INTO $table(";


// add fieldnames to insert

$query .= 'inventory' . ',';
$query .= 'date_entered' . ',';
$query .= 'first' . ',';
$query .= 'last' . ',';
$query .= 'serial' . ',';
$query .= 'city' . ',';
$query .= 'brand' . ',';
$query .= 'model' . ',';
$query .= 'email' . ',';
$query .= 'buy_date' . ',';
$query .= 'building' . ',';
$query .= 'room' . ',';
$query .= 'computer_name' . ',';
$query .= 'pri_user' . ',';
$query .= 'warranty' . ',';
$query .= 'vendor' . ',';
$query .= 'os' . ',';
$query .= 'processor' . ',';
$query .= 'memory' . ',';
$query .= 'hd' . ',';
$query .= 'drive1' . ',';
$query .= 'drive2' . ',';
$query .= 'drive3' . ',';
$query .= 'drive4' . ',';
$query .= 'bb_date' . ',';
$query .= 'comments' ;



// end fieldnames and begin values

$query = $query . ') VALUES(';


// get values from $_REQUEST

$query = $query . '"' . $_REQUEST['inventory'] . '", ';
$query = $query . '"' . $_REQUEST['date_entered'] . '", ';
$query = $query . '"' . $_REQUEST['first'] . '", ';
$query = $query . '"' . $_REQUEST['last'] . '", ';
$query = $query . '"' . $_REQUEST['serial'] . '", ';
$query = $query . '"' . $_REQUEST['city'] . '", ';
$query = $query . '"' . $_REQUEST['brand'] . '", ';
$query = $query . '"' . $_REQUEST['model'] . '", ';
$query = $query . '"' . $_REQUEST['email'] . '", ';
$query = $query . '"' . $_REQUEST['buy_date'] . '", ';
$query = $query . '"' . $_REQUEST['building'] . '", ';
$query = $query . '"' . $_REQUEST['room'] . '", ';
$query = $query . '"' . $_REQUEST['computer_name'] . '", ';
$query = $query . '"' . $_REQUEST['pri_user'] . '", ';
$query = $query . '"' . $_REQUEST['warranty'] . '", ';
$query = $query . '"' . $_REQUEST['vendor'] . '", ';
$query = $query . '"' . $_REQUEST['os'] . '", ';
$query = $query . '"' . $_REQUEST['processor'] . '", ';
$query = $query . '"' . $_REQUEST['memory'] . '", ';
$query = $query . '"' . $_REQUEST['hd'] . '", ';
$query = $query . '"' . $_REQUEST['drive1'] . '", ';
$query = $query . '"' . $_REQUEST['drive2'] . '", ';
$query = $query . '"' . $_REQUEST['drive3'] . '", ';
$query = $query . '"' . $_REQUEST['drive4'] . '", ';
$query = $query . '"' . $_REQUEST['bb_date'] . '", ';
$query = $query . '"' . $_REQUEST['comments'] . '"';


// end query

$query = $query . ')';


// run INSERT query

mysql_query($query, $db);

include('db_close.php');

?>

<script language="javascript">
<!--

location.href = 'display.php';

//-->
</script>
</body>
</html>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация