473,387 Members | 1,678 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,387 software developers and data experts.

using simultaneous arrays

I have a table with each column containing the following form objects -
combobox, hidden field, textarea, and tick box. I have created arrays from
each of these columns and now I wish to use the arrays altogether, taking
each array element in order to use in an sql statement
Does anyone know how to use arrays simultaneously
eg
Array1 - 1,2,3
Array2 - text1,text2,text3
Array3 - 31,56,34
Aray4- 1,1,0

used in a loop to populate the following SQLs
SQL="UPDATE mytable SET fieldA=Array2[0], fieldB=Array3[0], fieldC=Array4[0]
WHERE Index=Array1[0]"
SQL="UPDATE mytable SET fieldA=Array2[1], fieldB=Array3[1], fieldC=Array4[1]
WHERE Index=Array1[1]"
etc
for all the elements in the array

Ian
Jul 28 '06 #1
3 1412
Jay
Hi Ian

You could simply use a multidimensional array ;)

Like

$AllItems = array();

for($i = 0; $i < 10; ++$i)
{
$TestData = Array($i,$i*2,"Foo, ");
array_push($AllItems, $TestData );
}

Then you can access your array via $AllItems[ any valid index]

maybe this is what you want

Best regards

Jul 28 '06 #2
"Ian Davies" <ia********@virgin.netwrote:
I have a table with each column containing the following form objects -
combobox, hidden field, textarea, and tick box. I have created arrays from
each of these columns and now I wish to use the arrays altogether, taking
each array element in order to use in an sql statement
Does anyone know how to use arrays simultaneously
eg
Array1 - 1,2,3
Array2 - text1,text2,text3
Array3 - 31,56,34
Aray4- 1,1,0

used in a loop to populate the following SQLs
SQL="UPDATE mytable SET fieldA=Array2[0], fieldB=Array3[0], fieldC=Array4[0]
WHERE Index=Array1[0]"
SQL="UPDATE mytable SET fieldA=Array2[1], fieldB=Array3[1], fieldC=Array4[1]
WHERE Index=Array1[1]"
etc
for all the elements in the array
<?

for ($i = 0; $i < count($Array1); $i++)
{
$sql = "update mytable
set fieldA = {$Array2[$i]},
fieldB = {$Array3[$i]},
fieldC = {$Array4[$i]},
where Index = {$Array1[$i]}";
mysql_query($sql);
}

?>

miguel
--
Photos from 40 countries on 5 continents: http://travel.u.nu
Latest photos: Malaysia; Thailand; Singapore; Spain; Morocco
Airports of the world: http://airport.u.nu
Jul 28 '06 #3
cheers
thanks
That works fine
Ian
"Miguel Cruz" <sp**@admin.u.nuwrote in message
news:spam-16BC9D.00511229072006@localhost...
"Ian Davies" <ia********@virgin.netwrote:
I have a table with each column containing the following form objects -
combobox, hidden field, textarea, and tick box. I have created arrays
from
each of these columns and now I wish to use the arrays altogether,
taking
each array element in order to use in an sql statement
Does anyone know how to use arrays simultaneously
eg
Array1 - 1,2,3
Array2 - text1,text2,text3
Array3 - 31,56,34
Aray4- 1,1,0

used in a loop to populate the following SQLs
SQL="UPDATE mytable SET fieldA=Array2[0], fieldB=Array3[0],
fieldC=Array4[0]
WHERE Index=Array1[0]"
SQL="UPDATE mytable SET fieldA=Array2[1], fieldB=Array3[1],
fieldC=Array4[1]
WHERE Index=Array1[1]"
etc
for all the elements in the array

<?

for ($i = 0; $i < count($Array1); $i++)
{
$sql = "update mytable
set fieldA = {$Array2[$i]},
fieldB = {$Array3[$i]},
fieldC = {$Array4[$i]},
where Index = {$Array1[$i]}";
mysql_query($sql);
}

?>

miguel
--
Photos from 40 countries on 5 continents: http://travel.u.nu
Latest photos: Malaysia; Thailand; Singapore; Spain; Morocco
Airports of the world: http://airport.u.nu

Jul 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: M Lanham | last post by:
Has anyone had experience setting up Zend Studio Server Components in college environments where 100-200 developers may be hitting the debugging engine at the same time? Want to determine if the...
7
by: Irmen de Jong | last post by:
Hi, Things like Twisted, medusa, etc.... that claim to be able to support hundreds of concurrent connections because of the async I/O framework they're based on.... can someone give a few...
5
by: Dexter | last post by:
Hello all, I need all my developers work at a project simultaneous. How it is possible? I need a machine as web server? And how to configure the visual studio to all to work simultaneous? ...
12
by: Dan V. | last post by:
Since an ASP.NET/ADO.NET website is run on the server by a single "asp_net worker process", therefore doesn't that mean that even 50 simultaneous human users of the website would appear to the...
1
by: Simon | last post by:
Is there HTTP connection limit of 2 simultaneous connections in webservices? For example what hapens if you use webservices form ASP.NET web application? Presumably ASP.NET is webservices client to...
4
AnuSumesh
by: AnuSumesh | last post by:
Hi All, I want to avoid multiple simultaneous login to the site. The way it should work is If a person has logged in to the site from one machine and he is logging in to the portal from the...
1
by: Navigateur | last post by:
I need the ability to download more than one large file at the same time from the same php page. Is there a php function, core or 3rd party, that allows this, or is there another way of doing it? ...
1
by: bizt | last post by:
Hi, Im currently looking to move into using JSON for AJAX instead of returning from the server a string like the following: 12345{This is a text string{true I prefer objects because I dont...
4
by: raylopez99 | last post by:
Compound question: first, and this is not easy, if there's a way to detect multiple simultaneous key presses in C# let me know (in the below code, keys c and d being pressed simultaneously or...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.