hi i have a events script for users if the user submits a event then the event shows up fine but if they add another event it over rights the previous event how can i stop that where they can add more than one but maximum 4 as one time

my php process page is as follows:

$query = 'insert into events set etype = "'.$etype.'", edate = "'.$edate.'", region = "' .$region.'", pcode = "'.$pcode.'", town = "'.$town.'", title = "'.$title.'", advert ="' .$advert.'", ltm ="' .$ltm. '", user_id =' . $userid  ;

//echo $query ;

$insert = mysqli_query ( $conn,$query ) or die(mysqli_error($conn)) ;

if($insert)
{
    //echo "added" ;
    header("location: addedmeets.php");
    exit;   
}

and the database table is as follows:

CREATE TABLE IF NOT EXISTS events (
id int(11) NOT NULL AUTO_INCREMENT,
user_id int(11) NOT NULL,
etype varchar(50) NOT NULL,
edate varchar(50) NOT NULL,
region varchar(50) NOT NULL,
pcode varchar(50) NOT NULL,
town varchar(50) NOT NULL,
title varchar(255) NOT NULL,
advert text NOT NULL,
ltm varchar(50) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

any help would be much appreciated ty x

Huh, I'd completely forgotten about INSERT INTO ... SET :)
The code segment you've shown us should work fine (I can't see any errors anyway) so if you mean that the first INSERTION is completely replaced by the second in the database there must be something else going on. In particular there must be an UPDATE somewhere, or the first INSERT isn't getting called or is failing.
You mention a maximum of 4 records. What happens at reaching four? Are no more possible or is a previous one removed? You could have a logic error in that code.

How are you tracking the number of events being listed? @hericles mentioned update statment, you should show the full code for this script so we can see what is going on.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.