Jump to content

passing an array


hyster

Recommended Posts

$seat_s is a $var that can have multiple values depending on a form in a previous page.

 

this code works fine as is, but i need to pass the array into a 3rd page. i have no idea how to do this from the code below.

 

ive tried passing the array straight into a _post then _get on the next page but that only holds the 1st value and not all of them.

 

suggestions please.... thanks

<?php
$seat_s = $_POST['seats'];

foreach($_POST['seats'] AS $seat) {

$rowId = substr($seat, 0, 1);

$columnId = substr($seat, 1);

echo $rowId . $columnId . ", ";	

}

?>

Link to comment
https://forums.phpfreaks.com/topic/227907-passing-an-array/
Share on other sites

I'd at least consider it. All you need to do is make sure you've called session_start() before any output has been sent, then you can use a $_SESSION var like any other variable.

 

<?php
session_start();
$_SESSION['post_data_array'] = $_POST['array_element'];
?>

 

Some other script . . .

<?php
session_start();
print_r($_SESSION['post_data_array']);
?>

Link to comment
https://forums.phpfreaks.com/topic/227907-passing-an-array/#findComment-1175198
Share on other sites

thanks. that passed and echo the array.

 

next problem is how do i get the output into a format i can use in a sql query?

atm the format is [1]=>value1 [2]=>value2 [13]=>value3

 

i tried echo $_SESSION['post_data_array[1]' put the value returns as array.

 

what i need is value1 value2 value3

Link to comment
https://forums.phpfreaks.com/topic/227907-passing-an-array/#findComment-1175215
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.