Jump to content

Named Arrays over multiple Pages


GrahamRB

Recommended Posts

Afternoon,

I am totally new to PHP - I trying to learn PHP via some books but not everything is covered.

 

I have created 3 pages - the first identifies some trucks and trailers which are selected by using a drop down box. The second holds a series of arrays containing the dimensional specifications of the trucks and trailers. In the third I am trying to take the truck id from page one and select the specs of that truck from page two.

 

My results so far in page three are I can identify the truck from page one by $truckid =$_POST method, etc the code I have used

 

<?php

$truckid = $_POST['language'];
$trailer1id = $_POST['language1'];
$trailer2id = $_POST['language2'];
$loadingregime = $_POST['ML'];
include "specs1.php"
?>
<html>
<head>
<title>Compartment Loading!</title>
</head>
<body>
<?php
  echo " Selected Truck is ".$truckid;
  echo " - Trailer1 is ".$trailer1id;
  echo " - Trailer2 is ".$trailer2id;
  echo "<BR>";
  echo " Selected Loading Regime is ".$loadingregime."<BR>";
$specs5 =& $truckid;
print $specs5;
?>
<form method="post" action="loading.php">
  <p>T1 Comp 1   <?php echo "SFL ".$specs5[0] ?> :
    <input type="text" name="T1C1" value = "6000">
  </p>

 

I have experience in VB and VBA, and understand my coding technique is poor - but I would seriously appreciate some help.

 

Many thanks

Link to comment
Share on other sites

I'm a little lost slightly on what the problem actually is - what's not happening that's supposed to be happening? I've a feeling we might need to see more code.

So basically the OP has 3 files, each with some form. I assume the files will be viewed in a row by the user. The posted code is the 3rd file. The OP wants to get some POST data from the first file, which sends POST data to the 2nd file. Now, the OP wants those POST data on the 3rd file as well. I suggested the use of sessions.

Link to comment
Share on other sites

Indeed, but the OP also stated: "My results so far in page three are I can identify the truck from page one by $truckid =$_POST method", which leads me to believe that they have indeed successfully re-posted the data - in which case i'm not sure what's happening incorrectly.

 

However, i do agree that sessions would probably be a better way to go. You might like to check out this tutorial, Graham: http://www.phpfreaks.com/tutorial/sessions-and-cookies-adding-state-to-a-stateless-protocol

Link to comment
Share on other sites

Many thanks Guys, I shall study the 'sessions method' and thanks for the link to the tutorial - I shall do.

 

To answer the question of why it did not work, I suspect it has to do with me trying to used a string variable ($truckid is say T101) from page one and then try and make it act as an array for page 3 ($specs5 =& $truckid) where I ask it to get the spec $specs5[0] (it would work perfectly if instead of using $specs5[0], I used $T101[0] - which is the array set in page two)

 

Hope that makes sence....

 

Again many thanks - more to learn

 

GRB

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.