Hi Cor,
Have you ever made a mail form in flash?
I am assuming you have. Pretty much same scenario.
Just break down myArray[i] into individual vars and send the variables
to the php file.
So with a while or for loop, gather all your variables and send away.
Opt 1.
for each set - myArray[0]
- send this set
return to for loop - myArray[1]
- send next set
... etc
Opt 2.
or gather all the individual variables and send all at once. if this
is your wish.
you will have to set something up on the php side to differentiate
between myArray[0]['id'] and myArray[1]['id'], etc.
3.
or you can send the array and break it up on the php side with a while
or for loop
var $ID_Array = array();
for () {
$ID_Array[i] = array();
$this->$ID_Array[i][0] = $_POST[id][0];
(This is not tested, FYI. just the basic gist)
When you use POST in flash, php will automatically fill $_POS[''] with
the flash form var.
then you just get your var out and put it in that function.
$post_id = $_POST['id'];
$post_name = $_POST['name'];
$post_description = $_POST['description'];
$database_query = $database->addDescription($post_id, $post_name,
$post_description);
if($database_query){ //True ? False
Success / fail code
other ...
}
I should mention that I use this stuff inside php classes. so $this->
has already been defined as the class your currently in.
Like the database class, $database->addDescription(); is called
outside the class. if it was called inside the database class file,
it would be $this->addDescription();. Also, the php file name thats
called from flash is database.php. etc, etc. FYI.
I would recommend setting up separate php files
- a process.php, this retrieves your variables from flash, makes sure
its not a bot, any verify codes checked here, etc
- then send it to your sessions.php for validation and set your errors
here to send back with.
- then send to your database.php for stripping, manipulation and
insertion.
to send back to flash, use die('Error example') for errors and use a
status listener in flash
to send results, use the return($result);
A search for php sessions example or php login example would get you a
workable sample code.
HTH,
Best,
Karl
On Sep 5, 2011, at 10:04 PM, Cor wrote:
Thanks Karl,
Yes, I know.
My problem is how to fetch my $_POST['VALUES'], which is the
multi-dimensional array:
myArray[0["id"]
myArray[0]["name"]
myArray[0]["description"]
myArray[1["id"]
myArray[1]["name"]
myArray[1]["description"]
myArray[2["id"]
myArray[2]["name"]
myArray[2]["description"]
etc.
Best regards,
Cor van Dooren
-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl
DeSaulniers
Sent: dinsdag 6 september 2011 3:54
To: Flash Coders List
Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash
to mySQL
with PHP
Hi Cor,
Assuming you know enough php to set up the file for connecting to your
database, you can insert into your database with the following
example.
function addDescription($id, $name, $description) {
//Escape any data being inserted
$id = mysql_real_escape_string($id);
$name = mysql_real_escape_string($name);
$description = mysql_real_escape_string($description);
$query = "INSERT INTO YOUR_TABLE_NAME_HERE VALUES ('".$id."','".
$name."','".description."')";
$_POST['VALUES'];
$result = mysql_query($query, YOUR_CONNECTION) or
die(mysql_error());
return $result; //Returns true or false if error }
HTH,
Best,
Karl
On Sep 5, 2011, at 2:04 PM, Cor wrote:
I have a editable datagrid which I fill from mySQL with PHP.
So far works good.
But when items are changed (edit, added, deleted), I want them to
save
the data in my mySQL database.
My values are in this multi-dimensional indexed array, which elements
all contain a associative array:
myArray[i]["id"]
myArray[i]["name"]
myArray[i]["description"]
So, can anyone tell/show me a apropriate way to pass this to PHP and
in the php-file how to INSERT or UPDATE this to mySQL?
TIA!
Best regards,
Cor van Dooren
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Karl DeSaulniers
Design Drumm
http://designdrumm.com
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Karl DeSaulniers
Design Drumm
http://designdrumm.com
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders