Form elements and php with mysql problem
Posted: Fri Jun 06, 2003 11:58 am
I am trying to write a form that takes it's contents from various tables in a database so users can select items listed on the form and then post that form to me in an email with a list of the items selected. The database has the following tables: cameras, lenses, filters, grip, video and each table has the column values of ID, type and item, if I place the elements into a form called using the following script to populate the form (reduced code):
OK so the items are now in the form but how do these get passed on or rather how can I reference each item that is listed? as the number of items can be "more than" or "less than" 300 items depending on the number of items in each table. For example if I have a form with the users name, address and age then I can reference each of these items with a variable for $name, $address and $age but how can I do this when the items are numerous "possibly over 300" and taken from various MySQL database tables? I know some basic php so sending the results in the email is not a problem but when I got to this "referencing each item in the list" I became totally stumped.
Many thanks in advance for any replies
Code: Select all
<?php
//$list is the table , cameras, lenses etc.
$sql2="SELECT * FROM $list ORDER BY type, type, item";
while ($row = mysql_fetch_array($mysql_rental_result)) { // ---------- OPEN WHILE
$num == $num++;
if($list=="cameras") {
$CID = $row["CID"];
$type = $row["type"];
$item = $row["item"];
if($c==1) {
include "$path_tables"."inc_camorder_table1.htm"; // LOAD IF 1 TABLE ONLY
}
if($c>0) {
include "$path_tables"."inc_camorder_table2.htm"; // LOAD THE LAST TABLE
}
}
if($list=="lenses") {
$LID = $row["LID"];
$type = $row["type"];
$lens = $row["lens"];
$item = $row["item"];
if($c==1) {
include "$path_tables"."inc_lenorder_table1.htm"; // LOAD IF 1 TABLE ONLY
}
if($c>0) {
include "$path_tables"."inc_lenorder_table2.htm"; // LOAD THE LAST TABLE
}
}
if($list=="video_assist") {
$VID = $row["VID"];
$type = $row["type"];
$item = $row["item"];
if($c==1) {
include "$path_tables"."inc_vidorder_table1.htm"; // LOAD IF 1 TABLE ONLY
}
if($c>0) {
include "$path_tables"."inc_vidorder_table2.htm"; // LOAD THE LAST TABLE
}
}
$ud = ""; // Clear the ud variable
$c++;
}
?>Many thanks in advance for any replies