If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Posting Multi-dimension named arrays with a form

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-25-03, 09:29
darkness darkness is offline
Registered User
 
Join Date: Sep 2003
Posts: 1
Question Posting Multi-dimension named arrays with a form

I have an array which fetches from mysql, this is the array:

$results[$i] = array('studno' => $row[0], 'name' => $row[1], 'surname' => $row[2], 'cell' => $row[3], 'email' => $row[4], 'course' => $course, 'campus' => $campus, 'img' => $row[7]);

It goes on a results page viewing 5 results at a time, now i want to pass the array back to itself when a person hits next page so they can view say results 5-10, then again for 10-15 etc.

I have seen it mentioned that you can implode the array and assign it to a hidden input variable on the form, and then explode it back into an array. i have tried this but it does not come up with the correct information, just a whole lot of single charactered values for each item.

How would i be able to pass this array ?
Reply With Quote
  #2 (permalink)  
Old 09-30-03, 16:48
moku moku is offline
Registered User
 
Join Date: Sep 2003
Location: Wisconsin, USA
Posts: 34
php/html arrays

You can use arrays in html just by setting the input element's names to the array values.

For example, we have this array
$myarray = array('thing1'=>'value1', 'thing2'=>'value2');

to represent this in html you'd have:
<input type="hidden" name="htmlarray['thing1']" value="value1"/>
<input type="hidden" name="htmlarray['thing2']" value="value2"/>


Now when you want to read this back in on the page you submitted to, just do:
$myarray = $_POST['htmlarray'];

now $myarray in the second page is the same as the first! Piece of cake!

You can do this with multi-dimensional arrays too.
ala:
<input type="hidden" name="htmlarray['dim1key1']['dim2key1']" value="Value-For-Dimension1Key1-Dimension2key1""/>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On