Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

more blank records

Status
Not open for further replies.

thumbelina

Programmer
Jun 4, 2001
58
CA
ok i have a table with the fields entryID(auto_increment), date, regularhours, othours, project. I have a form on which u can enter info into each field. I have it set up so that u can enter 5 records into the database at once. So that means in a line 3 text boxes and one drop down list, then 5 lines all the same in the form.when u hit the submit button it should send the info to the table. I have each query put into an if block so that it will only send info if there is info entered in the date text box. the if blocks look like this:
<?php if(!isset($dateone)) { ?>

<?php } else {
$database = databasename;
$sql = &quot;INSERT INTO EmployeeWork (entryID,workdate,reghrs,ot,project) VALUES ('','$dateone','$regularone','$otone','$projectone')&quot;;
$do = mysql($database,$sql) or die(&quot;failed to issue query&quot;);
}
?>
but the problem is that if there is info in one line of the form it will enter 4 blank records, but if i fill in all 5 lines in the form it just enters the 5 records properly. what am i doing wrong?? Thanks for your help.
 
I got it figured it out. I just had to alter the form of the if block. i used this instead.
<?php if($dateone != &quot;&quot;) {
$database = databasename;
$sql = &quot;INSERT INTO EmployeeWork (entryID,workdate,reghrs,ot,project) VALUES ('','$dateone','$regularone','$otone','$projectone')&quot;;
$do = mysql($database,$sql) or die(&quot;failed to issue query&quot;);} ?>

of all the bizarre things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top