Hello again all,
I'm working on a form and ran into a wall (again) and can't seem to think through how to best code what i need (the logic side). I've begun by just sitting down and starting to code with the little knowledge i have of php but can't seem to get it right and am not sure i'm using the correct syntax...
The form is your basic contact form that collects contact information, but it also has a place for customers to input product information such as a quantity and dimensions (width and height). The form offers the visitor a chance to enter up to 7 different "products" and their quantity, width, and height.... here's that part of the form...
Code: <form name="myForm" action="<?php echo $_SERVER['PHP_SELF ']; ?>" method="POST">
<table width="600" cellspacing="2" cellpadding="1">
<tr>
<td>Quantity</td>
<td>Width</td>
<td>height</td>
</tr>
<tr>
<td><input type="text" name="qty1" /></td>
<td><input type="text" name="width1" /></td>
<td><input type="text" name="height1" /></td>
</tr>
<tr>
<td><input type="text" name="qty2" /></td>
<td><input type="text" name="width2" /></td>
<td><input type="text" name="height2" /></td>
</tr>
<tr>
<td><input type="text" name="qty3" /></td>
<td><input type="text" name="width3" /></td>
<td><input type="text" name="height3" /></td>
</tr>
<tr>
<td><input type="text" name="qty4" /></td>
<td><input type="text" name="width4" /></td>
<td><input type="text" name="height4" /></td>
</tr>
<tr>
<td><input type="text" name="qty5" /></td>
<td><input type="text" name="width5" /></td>
<td><input type="text" name="height5" /></td>
</tr>
<tr>
<td><input type="text" name="qty6" /></td>
<td><input type="text" name="width6" /></td>
<td><input type="text" name="height6" /></td>
</tr>
<tr>
<td><input type="text" name="qty7" /></td>
<td><input type="text" name="width7" /></td>
<td><input type="text" name="height7" /></td>
</tr>
</table>
</form>
... pretty simple stuff there...
I am having trouble though collecting the info from the form... the newbie in me (to php and programming in general) had me begin hard coding each variable like this...
Code: $qty1 = $_POST['qty1'];
$qty2 = $_POST['qty2'];
....
$width1 = $_POST['qty1'];
$width2 = $_POST['qty2'];
....
$height1 = $_POST['qty1'];
$height2 = $_POST['qty2'];
....
I thought that it might make more sense (and help me learn a little) to try and use a loop to create these variables.... is this good practice?
Here's what i came up with...
Code: for ($X=1;$X < sizeof($glass1)-1; $X++) {
// how's the syntax on the next line???
if($_POST['Qty'.$X]!=NULL ){
$glasspart1.="Part $Xn";
//below: can i use $qty$X like that?
$glass1 = array("QTY: $qty$X", "DIMENSIONS: $width$X X $height$X");
$glasspart1.= "$glass1[$X-1]n";
}
}
am i on the right track so far?
I still am having trouble validating the form (the logic) in order to only create arrays for the parts (1-7) that were filled in, but i can save that for another post :-)
thanks again all for any help or advice!!
sql error
I have been looking at this code for 20mins and can't work out what I am doing wrong. There is something wrong with my sql statement below is the error and the code. what I am trying to do is to edit
Help please - How to validate from 2 possible answers
Hi I hope somebody can help me with what will probably be really simple, I'm pulling my hair trying to get my head round it.I've got a contact form and I would like to add to it a couple of simple
PHP hyperlinks generator - HELP plz
HiI need some help to get this done using php:1 - I have few hyperlinks say 500 in format like:<a href="http://domaina.com/1.html"
Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :if (isset($_POST['sub1'])) { $id = $_POST['cscstest']; $qty = $_POST['cscsqty']; $id =
Cant display mysql data
Hey all,I am learning php and my first goal is to create a simple CMS. At the moment I am stuck on not being able to pull page names and their id`s from my DB and combine them into a list of links
simple php table loop
Hi all,I've the following code <?php // Create category options $query = "SELECT * FROM categories ORDER BY category ASC"; $result = mysql_query
how do i display data on a page from mysql
1 - do i use this code at the top of each of my page i wish to only alow access if there as been a sessionCode: <?phpinclude_once 'Connect.php';if (!is_authed()) { die ('You are not
Count on multidimensional array
Hi, i got an array as below:Array( => Array ( [2009-12-08] => 1 ) [1] => Array ( [2009-12-07] => 1 ) [2]
adding up might be solved tell us cheers.
i think i finally solved this anybody.last time i was getting the wrong results.Code: <?php// price of item.$price="100.00";//quenity of items.$quenity="7";// tax
Troubles with a spider class
I am building a spider that will crawl through random whitepages (eg. anywho.com, switchboard.com, whitepages.com, etc..) and collect the information on the people found there and throw it into a