Hi all,

I have a table called pets, here is a partial dump:
At this time this is all I am working with.

uid int(10) NOT NULL default '0',
    num_pet tinyint(1) NOT NULL default '1',

There are three steps to adding the pet into the db

Step 1 create the record, this is in create.php. And yes believe it or not
this does work.

$query_update = "INSERT INTO pets (uid) SELECT uid FROM users WHERE
$result = mysql_query($query_update)
                 or die("Unable to insert into the database");

Step 2 Check to see if there is already a pet record this is in process.php.

$query="SELECT  num_pet FROM pets WHERE uid={$session["uid"]}";
$ret = mysql_query($query);

// echo  the number in the db, it should = 1 until submit button clicked
echo $num_pet

$number_pet = $num_pet;

       if($number_pet == 0 ) {
       print ("Sorry you can't add another pet");
       }else{ this does all the updating of the record

<form action="petdata.php" method="post">
Click to continue<BR>
<INPUT TYPE="submit" VALUE="Submit" NAME="submit">

Step three update num_pet after submit is clicked, this is in petdata.php

$db = "update pets set num_pet = 0 where uid={$session["uid"]}";
   $ret = mysql_query($db) or die(db_error());

Now here is my question, If the submit button is clicked and num_pets is
updated to 0 and you try to add another record shouldn't this print- Sorry
you can't add another pet?

I am at a loss as to why it will keep adding records. Anyone want to take a
stab at it?


PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to