473,386 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

$_POST Help

5
Ok, I'm having a really tough time getting this to work the way I want.

Page One

[PHP]
<? while ($row = mysql_fetch_array($result)){ ?>

<tr>

<td><input type="text" name="lots[]" size="13" maxlength="12" value=""></td>

<td><input type="checkbox" name="tanks[]" value="<? echo("$row[serial]"); ?>"></td>

</tr>

<? } ?>

[/PHP]


Page Two
[PHP]
<?
$howmany = count($_POST['tanks']);
if ($howmany > 0){
foreach($_POST['tanks'] as $serial => $tank){
//Whatever
}
}
?>
[/PHP]

Yay, page two works fine.

BUT, What I really want to do is Make it so that I can make an SQL query with both the lot and serial on page two.

Such as $query = SELECT * FROM 'whatever' WHERE lot = lots[] and tank = tanks[]

And, I have absolutely no idea how to go about doing this.

Does that make much sense? Please let me know if I need to clarify anything. I'm really confused and very new to this.
Apr 23 '07 #1
2 1175
code green
1,726 Expert 1GB
The foreach loop is a shorthand convenient format of the for loop. Do not forget what is behind it.

$tanks = $_POST['tanks'];
$lots = $_POST['lots'];

for($c=0;$c<sizeof($lots);$c++){
$lot = $lots[$c];
$lot = $lots[$c];

as $serial => $tank){
//Whatever
}
}
?>

Such as $query = SELECT * FROM 'whatever' WHERE lot = lots[] and tank = tanks[]
Apr 25 '07 #2
code green
1,726 Expert 1GB
Ignore last. False submission

[PHP]$tanks = $_POST['tanks'];
$lots = $_POST['lots'];

for($c=0;$c<sizeof($lots);$c++){

$query = "SELECT * FROM 'whatever'
WHERE lot = $lots[$c] AND tank = $tanks[$c]";
}[/PHP]
You may need curly brackets around the array variables in the SELECT string
Apr 25 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Kevin | last post by:
I am having problems in my php code. I am relatively new to php but I know some basics. This is the problem: when i try to echo some information that is typed into form back to the screen i...
10
by: arun.kumar.varma | last post by:
Hi, I'm learning PHP and prepared a simple login form. validate.php does the validation and it was behaving erratically. So, I did var_dump of $_POST variable and it's NULL. Did I miss anything...
4
by: Leszek | last post by:
Hi. I have a problem with a form. There are some select dropdown lists for($i=0;$i<=$nrooms;$i++) { echo "<option value=\"$i\""; if($_POST]==$i){ // $k is incremented in other loop
7
by: Dynamo | last post by:
I am using values stored an $_POST array to display records from a table before asking the user if he is sure he wants to delete them. If the user confirms then the records are deleted. Without...
6
by: comp.lang.php | last post by:
I have no idea why this is happening and I need someone to explain this to me at the simplest level absolutely possible (pretend I'm a 10-year old and explain it that way, please!) This class...
6
by: admin | last post by:
Hi, I have a mysql box that has a private network ip. The old developer was running our web server on this machine but the company since retired the box and it is in a closet, still running, but...
9
by: lovinlazio9 | last post by:
I've just started messing around with PHP and believe it or not its extremely frustrating haha. Anyway, I wanted to make a simple input form that would display the info after submitting it... The...
3
by: scabman | last post by:
Working on upgrading a site and after moving everything onto a test server (localhost) things started to get real buggy. Went through and checked all my links and everything comes up fine, but it...
12
by: Todd Michels | last post by:
Hi all, I am trying to send data from a form and insert it into a MSSQL DB. When I submit the data I get: Warning: mssql_query() : message: The name "Todd" is not permitted in this context....
2
by: keeps21 | last post by:
I have a script that recieves an id number via the address bar when a link is clicked. ie . index.php?id=1 if the link was for the story whose ID is 1. My script checks if a user is logged in,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.