I have an incredibly complicated page that displays a drop down menu with data from a DB. The data is of various types, from different tables in my DB. For example sake, the drop down menu might list off a user’s favorite items. Some of them might be books, which have a certain structure, and some might be movies (diff structure).
I have several buttons that allow the user to move those items up and down in the list, remove them, rename them, etc.
I need to pass 2 values from the drop down menu with a form, an item ID and a type ID. The “remove” function would then remove the item matching that ID and type from the user’s favorite list.
here’s some code:
// Move Up Function (Form submits to self, passing in dropdownarray
if (isset($_GET['btnMoveUp'])) {
if (!isset($_GET['dropdownarray'])) {
$message .= '<font color="red">You must first choose a item to move</font><br /><hr>';
} else { // move the destination up
$dropdownarray = $_GET['dropdownarray'];
echo $dropdownarray['itemID'] .'<br />';
echo $dropdownarray['typeID'] .'<br />';
// move the item up //
}
// dropdown header
echo '<select style="width: 380px;" name="dropdownarray" size="' .$size .'">';
// inside my drop down menu
echo '<option value=' .$dropdownarray .'>';
echo 'STUFF THE USER SEES';
echo '</option>';
The two echo statements above print out the letter “A” and nothing else. They should print out 2 numbers, the first between 1 and 7000 (itemID) and the second should be 1 2 or 3.
TIA for any suggestions,
Ryan
[edit]
Forgot to add that the correct values are in the $dropdownarray before it is passed[/edit]
I had thought of doing it the way you posted, but I figured you could pass an array more easily.
// I setup my arrays like this:
// query and results
// while loop
$myArray['itemid'] = $result['item_id'];
$myArray['itemtype'] = $result['item_type'];
// then in my dropdown menu
<option value="$myArray">My Item</option>
// end drop down
// end while loop
Does this method not work because $myArray will be the same for every line in the drop down menu because it is reset for every step through the while loop? I’ll give your method a shot since that looks like it’ll work perfectly.
I have a question. I have 100 records, and divide it into 10 pages. So how to navigate to ?mode=view&page=4, then on the dropdown menu it will show number 4, like this: Page: [4]