Date: 12/21/00
- Next message: Tim Zickus: "Re: [PHP] Mixing eval() with include/require"
- Previous message: Juergen Hall: "[PHP] Re: Javascript in php"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Me again,
i make it more clear. I have two tables in the database.The first table is a shopping cart. The second are Details of domain registrations. Now i want to insert the of a form selection resulting array (which works fine) into the shopping cart, BUT JUST if this domain doesnt already exist in the details table NOR the in the shopping cart. So i have to take the arrray from the form and compare it with one row of table one and one row of table two and then (if the data doesnt exist insert it into the shopping cart (which is temp). Sorry about that much questions but its my 1. week on PHP :)
*********** REPLY SEPARATOR ***********
On 21/12/00 at 11:55 Cynic wrote:
>what about storing UNIQUE keys as needed in the database,
>inserting (without prior select), catching errno, and
>displaying 'this data already exists' if needed?
>
>At 11:40 21.12. 2000, Admin wrote the following:
>--------------------------------------------------------------
>>hi all,
>>
>>i have two arrays. The first one resulting from a selection of a form and the second one resulting from a row in mysql.
>>Now, how can i compare these two arrays and if there are no doubles insert them into mysql?
>>
>>//The first array. This is where it sucks as it doesnt compare this array with the second one.
>>mysql_connect("$DBHost","$DBUser","$DBPass");
>>mysql_select_db ("$DBName");
>>$result = mysql_query ("SELECT THISDATA FROM THISDATA
>> WHERE THISDATA = '$THISDATA");
>>($row = mysql_fetch_array($result));
>>if ($result == $THISDATA
>>{
>> print ("<b>Error:</b> THISDATA ALREADY EXISTS IN OUR DATABASE<b>");
>> print ("$THISDATA");
>> print ("</b> Go back and enter a new THISDATA.");
>> print ("<p>");
>> $verify = "bad";
>>}
>>else
>>{
>>
>>//This is the second array (resulting from a user selection)which will be inserted into mysql ONLY if the data from this arrays doesnt already exist in another table. Which means that i have to fetch just one row of a table and compare it with the one from the user.
>>mysql_connect("$DBHost","$DBUser","$DBPass");
>>mysql("$DBName","INSERT INTO shoppers VALUES ('$UID','$date','tempID')");
>>for($count = 0; $count < sizeof($MYARRAY); $count++)
>>{
>>mysql("$DBName","INSERT INTO basket VALUES
>>('$UID','$MYARRAY[$count]','2','$date','$BasketItem')");
>>Header("Location: viewBasket.php?UID=$UID");
>>}
>>}
>>
>>
>>//Thanks in advance
>------end of quote------
>
>
>
>____________________________________________________________
>Cynic:
>
>A member of a group of ancient Greek philosophers who taught
>that virtue constitutes happiness and that self control is
>the essential part of virtue.
>
>cynic <email protected>
_________________________________________________________
Do You Yahoo!?
Get your free <email protected> address at http://mail.yahoo.com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Tim Zickus: "Re: [PHP] Mixing eval() with include/require"
- Previous message: Juergen Hall: "[PHP] Re: Javascript in php"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

