Page 6 of 7
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 2:47 pm
by donny
when i print $ordercid this is what i get
Array
(
[2TNVS6] => Array
(
[0] => 828
)
)
Array
(
[2TNVS6] => Array
(
[0] => 828
[1] => 1214
)
)
Array
(
[2TNVS6] => Array
(
[0] => 828
[1] => 1214
[2] => 4690
)
)
Array
(
[2TNVS6] => Array
(
[0] => 828
[1] => 1214
[2] => 4690
)
[W2B368] => Array
(
[0] => 8211
)
)
is that what its supposed to look like?
i thought it shall look like this
Array
(
[2TNVS6] => Array
(
[0] => 828
[1] => 1214
[2] => 4690
)
[W2B368] => Array
(
[0] => 8211
)
)
which it does at the bottom, what is all the stuff before it?
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 2:51 pm
by Celauran
Which it does at the bottom of what? Where are you printing all this? Looks like you're printing from inside a loop while the array is still being built.
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 2:52 pm
by donny
at the bottom of that print i sent.
yes i was lol, i couldn't print it outside of the foreach/while? though it says unassigned
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 2:54 pm
by donny
nevermind i got it . its beautiful!
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 4:48 pm
by donny
now i need some help pulling the form info from the database. i am using the script that i used in the beginning, i need help adjusting it to call the new array out.
Code: Select all
<?php
include 'dblogin.php';
$select_list = $_POST['selected'];
foreach ($select_list as $key => $value) {
$select_list[$key] = "'" . $value . "'";
}
$list = implode(', ', $select_list);
$query = "SELECT `ordernumber`, `formnumber` FROM `rawdata` WHERE `ordernumber` IN ($list)";
$result = mysql_query($query) or die(mysql_error());
$ordercid = array();
while ($row = mysql_fetch_array($result)) {
$ordercid[$row['ordernumber']][] = $row['formnumber'];
}
foreach ($ordercid as $ordernumber => $CID) {
$query2 = "SELECT * FROM `rawdata` WHERE `ordernumber` = '$ordernumber' AND `formnumber` = '$CID'";
$result2 = mysql_query($query2) or die(mysql_error());
while($row2 = mysql_fetch_array($result2)){
$clientarray = array( "ordernumber" => $row['ordernumber'],
"formnumber" => $row['formnumber'],
"info1" => $row['info1'],
"info2" => $row['info2'],
"info3" => $row['info3'],
"info4" => $row['info4'],
"type" => $row['type']);
}
}
echo "Check box test<pre>" ;
print_r($clientarray);
echo "</pre>"
?>
thanks so much!
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 6:46 pm
by Celauran
Just FYI, if you ever find yourself running a query inside a loop. Stop. Thinking about the problem and about what you really need, because there's almost always a better way. In this case, I don't see a need for the second query at all. You're querying the same table, just grab all the data on the first pass.
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 6:54 pm
by donny
i can't get it on the first pass because its 2 different tables. if i get everything from raw data i will come up with multiple results since theres more than 1 of the same ordernumber on the raw data list. i have a orders table that has all the order numbers one time in them. thats the table i am using for the orders list because i have other information on that table like paid and status and stuff.
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 6:56 pm
by donny
actually never mind your right. very tired. been at this since last night!!!
how can i get all rows from the table into the query?
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 7:02 pm
by Celauran
Code: Select all
$query = "SELECT `ordernumber`, `form number`, `info1`, `info2`, `info3`, `info4`, `type` FROM `rawdata` WHERE `ordernumber` IN ($list)";
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 7:07 pm
by donny
actually i don't think i can do it this way...
i need to have all data separate for each formnumber. it would have to be a 3 dimensional array i guess
Array
(
[2TNVS6] => Array
(
[8028] => Array
(
[info1] => data
[info2] => data
[info3] => data
[info4] => data
(
[2031] => Array
(
[info1] => data
[info2] => data
[info3] => data
[info4] => data
(
[9450] => Array
(
[info1] => data
[info2] => data
[info3] => data
[info4] => data
(
)
[W2B368] => Array
(
[1203] => Array
(
[info1] => data
[info2] => data
[info3] => data
[info4] => data
(
[9984] => Array
(
[info1] => data
[info2] => data
[info3] => data
[info4] => data
(
)
[C0XM4B] => Array
(
[2393] => Array
(
[info1] => data
[info2] => data
[info3] => data
[info4] => data
(
)
)
ORDERNUMBER
FORMNUMBER
FORMDATA
FORMNUMBER
FORMDATA
ORDERNUMBER
FORMNUMBER
FORMDATA
etc
is this possible?
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 7:10 pm
by Celauran
Why a three dimensional array? Why couldn't you just operate on the rows directly? Barring that, why not just expand the current 2d array?
Which is to say
Code: Select all
$ordercid = array();
while ($row = mysql_fetch_array($result)) {
$ordercid[$row['ordernumber']][] = $row;
}
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 7:12 pm
by donny
i need to have all form data separately...
in my table i have
ordernumber formnumber data1 data2 data3
the same ordernumber can have multiple formnumbers because they submitted multiple forms for the same order
i need to have all information separate to pass through the foreach script seperartly.
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 7:13 pm
by Celauran
That in no way answers my second question.
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 7:14 pm
by donny
why can't i operate on the rows directly? i don't understand
Re: PHP Batch Process? Is this Possible?
Posted: Thu Sep 04, 2014 7:16 pm
by donny
ah i see. that will work