Jump to content

Help with two dimensional array


mpar612

Recommended Posts

I have the following form. This pulls all items for a database and

prints the following code for each item:

 

<tr>
<td height="21\" valign=\"top\"><b>
<input name = \"$itemId\" value=\"$value\" size=\"3\" /></td>
<td><font face=\"Times New Roman\" color=\"#990000\">$itemName </td>";

if($temperature == "Y") {
    echo "<td><select name=\"$itemId - temperature\">
          <option value=\"NA\">-- Select --</option>
          <option value=\"BR\">Blood-Rare</option>
          <option value=\"MR\">Medium-Rare</option>
          <option value=\"M\">Medium</option>
          <option value=\"MW\">Medium-Well</option>
          <option value=\"WD\">Well Done</option>
        </select></td>";
} else {

    echo "<td>N/A<input type=\"hidden\" name=\"$itemId - temperature\"
value=\"N/A\" /></td>";

}

echo "<td><b>$$total</b></td>
    </tr>";

$arr[] = $total;

}

 

I used the following code to populate an array and session variable so

the values can be used on a different page:

 

if(!empty($_POST)) {
    foreach($_POST as $key => $value) {
        if($key != "_submit_check" && $key != "button"  && $key != "0"
&& $key != "") {
              if(!empty($value)){
              $arr[$key] = $value;
            }
        }
    }

}

$_SESSION['order'] = $arr;

Is it possible to create a 2 dimensional array out of the form?  I

need to be able to print the contents of the form as the following:

 

$value - $itemName - $temperature - $total

 

Any thoughts would be greatly appreciated. I am new to using arrays in

this way.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/121221-help-with-two-dimensional-array/
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.