PHP Batch Process? Is this Possible?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: PHP Batch Process? Is this Possible?

Post by phphelpme »

Hi there.

I can understand your thoughts and feelings regards this but as coders, they will not want to develop a system that is slightly backwards thinking in relation to how they code. It is called 'standards' and that is what the PHP language is fundamentally based around.

I wish you luck in your thoughts about your system and I hope you get what you want in the end. However, you will run into problems as we all extend our systems as inevitably our needs or desires find something else that could help us.

Best wishes.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: PHP Batch Process? Is this Possible?

Post by donny »

that being said. i can do most of it, i just don't know how to take information out of my database and have it ran through a processing page separately.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: PHP Batch Process? Is this Possible?

Post by donny »

i don't know where it came off as backwards by just explaining what i needed done. thanks for your input!
and thanks for helping out the new guy! I'm sure you didn't learn everything without some help! i only know very little and i wuldnt know any of it if it weren't for people like celauran that actually help people instead of talk down to them like your some php god or something. i am a young kid and this is what i chose to do my summer instead of drink and smoke cigarettes with the "Cool kids"
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: PHP Batch Process? Is this Possible?

Post by phphelpme »

Hi there.

Look into the 'select' statement for extracting information from a database and also 'loops' such as, 'for' and 'foreach'. You have a number of choices about how you want to store the information while it is being ran through another script. The information will be stored as an array from the database and the 'loop' will allow you to extract that information from the array into separate string variables to use as and when you please.

Best wishes.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: PHP Batch Process? Is this Possible?

Post by donny »

i hope somebody can still help me though, i liked this forum and was learning a lot here.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP Batch Process? Is this Possible?

Post by Celauran »

Here's the thing; you keep talking about running these orders through different 'scripts' but never actually explain what they do or what the differences between them are. I've been trying to help you come up with a process to automate this, to do exactly what you're describing, but as long as 'script' remains some black box there's little more I can do.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: PHP Batch Process? Is this Possible?

Post by donny »

its not possible to just use them the way they are? and just pass the data to them as if it were just me entering the information into a form?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP Batch Process? Is this Possible?

Post by Celauran »

They're separate pages that rely on POST data? Sure, that can be automated but you'd need to use cURL or something to send the POST data and that's messy and probably more work than just fixing the workflow into something more reasonable.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: PHP Batch Process? Is this Possible?

Post by donny »

i can fix the work flow myself but i wanted to have a page that shows all form data and then i can pick and chose when and which ones i want to be ran through the script. i don't want them all ran through it. i want to be able to pick and chose which ones are ran through it.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP Batch Process? Is this Possible?

Post by Celauran »

Yes, that's been clear from the beginning. That's not a problem.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: PHP Batch Process? Is this Possible?

Post by donny »

i didnt think it was going to require so much work and changing around. i thought there was something small that can be put together that takes info from a database and runs it through to a page as if it were a form sending data to it. and do it automatically for each row that i select to go through.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: PHP Batch Process? Is this Possible?

Post by donny »

Celauran wrote:They're separate pages that rely on POST data? Sure, that can be automated but you'd need to use cURL or something to send the POST data and that's messy and probably more work than just fixing the workflow into something more reasonable.

yes they rely on post data now because they're made for forms
i will change all the variables to get data from an array instead

i am going to come into the page with a multidimensional array that will look like this

Code: Select all

<?php 
$processthese = array( 
               array("ordernumber","formnumber","info1","info2","info3","info4","type"),
               array("ordernumber","formnumber","info1","info2","info3","info4","type"),
               array("ordernumber","formnumber","info1","info2","info3","info4","type"),
                                ); 
?> 
now i need to know how to setup a loop/foreach that will take each array in $processthese and put run them through a script separately... i am just going to use my current script the way it is now and instead of getting data from POST it'll be from this array.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP Batch Process? Is this Possible?

Post by Celauran »

Then it would just be as simple as

Code: Select all

<?php
foreach ($processthese as $order) {
    // do something here
    // reference $order instead of $_POST
}
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: PHP Batch Process? Is this Possible?

Post by donny »

ok thanks a lot.

i am trying to set up my multi dimensional array.
i will have my view orders page where i select orders i want to process.

it'll bring it to the next page which will create a multidimensional array

right now i am testing a bunch of stuff and for some reason i have 4 things in my array and the foreach i made that pulls data into arrays only does 3 of them.

Code: Select all

<?
error_reporting(E_ALL);
$selected = array(  "PH62W8" => "8482",
			     "PH62W8" => "7437",
		      	     "FRF856" => "5207",
			     "62R9PK" => "4696"
			  );
				
include 'dblogin.php';

foreach ($selected as $ordernumber => $formnumber) {
$query = "SELECT * FROM `rawdata` WHERE `ordernumber` = '$ordernumber' AND `formnumber` = '$formnumber'"; 
	 
$result = mysql_query($query) or die(mysql_error());


while($row = mysql_fetch_array($result)){
$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>";


                                                                                  }

?>

i manually wrote in the ordernumbers and formnumbers and they do exist in the database. i know this is not creating a multidimensional array but just a single array, i was testing stuff as i learn.

any idea why i am only getting 3 results? i double checked 100 times and i am calling for the right order and form numbers?

thanks a lot
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: PHP Batch Process? Is this Possible?

Post by donny »

i added 7 to the array and it only prints 4?
i don't know if its a coincidence but it only prints 1 for each order number, like 1 order number has 3 formnumbers . its only doing 1 formnumber for each ordernumber. i don't know if this is just a coincidence though.

edit. its no coincidence that is the problem. only doing 1 formnumber for each ordernumber
Last edited by donny on Thu Sep 04, 2014 10:30 am, edited 1 time in total.
Post Reply