0

I am developing a form for a birdbreeders club. With this form people can order rings. On the page http://www.info-sec.nl/bodyringenbestelling.htm there are two forms. The second form people can place an order. There are 10 rows, but normally people do not use all 10. How can I prevent that also the rows that do not contain any data are added to the data base? I other words, what should I do if I e.g. sql4 is empty and I do not want the insertion to continue. It might be a very simple question, but I am a very very newbie

below is the beginning of the script I use:

<?php

$con = mysql_connect("lXX","XX","XX");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("infosec", $con);
  $sql="INSERT INTO kweker (naam, adres, postcode,woonplaats,telefoon,seclidnr,email,lidnb,kweeknr)
VALUES
('$_POST[naam]','$_POST[adres]','$_POST[postcode]','$_POST[woonplaats]','$_POST[telefoon]','$_POST[seclidnummer]','$_POST[email]','$_POST[lidnbvvja]','$_POST[kweeknummer]')";

$sql2="INSERT INTO bestelling (soort, ringmaat, volgnr, aantal, gekleurd, geannodiseerd, aluminium, rvs, bedrag)
VALUES
('$_POST[naamvogel1]','$_POST[maat1]','$_POST[volgnummer1]','$_POST[aantal1]','$_POST[gekl1]','$_POST[gekleurdgeanodiseerd1]','$_POST[aluminium1]','$_POST[rvs1]','$_POST[prijsvogel1]')";

$sql3="INSERT INTO bestelling (soort, ringmaat, volgnr, aantal, gekleurd, geannodiseerd, aluminium, rvs, bedrag)
VALUES
('$_POST[naamvogel2]','$_POST[maat2]','$_POST[volgnummer2]','$_POST[aantal2]','$_POST[gekl2]','$_POST[gekleurdgeanodiseerd2]','$_POST[aluminium2]','$_POST[rvs2]','$_POST[prijsvogel2]')";

$sql4="INSERT INTO bestelling (soort, ringmaat, volgnr, aantal, gekleurd, geannodiseerd, aluminium, rvs, bedrag)
VALUES
('$_POST[naamvogel3]','$_POST[maat3]','$_POST[volgnummer3]','$_POST[aantal3]','$_POST[gekl3]','$_POST[gekleurdgeanodiseerd3]','$_POST[aluminium3]','$_POST[rvs3]','$_POST[prijsvogel3]')";
2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Shanti C
0

Then first insert into table which fields you want...and then use update query to insert other fields by using any one id which we previously inserted..
provide your table with default entry(if int with 0,if varchar with no,if text dont specify any)..
Then you will get the task what you excatly want..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.