Jump to content

Recommended Posts

I need some one help here, I am trying to make a select box with types of options.

 

The idea is firstly it loads up the items from the database into the list and below the items it has houses list (i do this using 2 while loops one after another).

 

Now in the value of the select box I have the ID of the house or item, as shown below:

 

<?php
$Get = mysql_query("SELECT ItemID,Name FROM item ORDER BY ItemID ASC")
Or die(mysql_error());
While($row = mysql_fetch_assoc($Get)){
$ItemID = $row['ItemID'];
$Name = $row['Name'];
?>
<option value="<?=$ItemID?>"><?=$Name?> - Item</option>
?>
}
?>

// REPEAT for house table
?>

 

But I need to also distinguish what type the option value is, weather it is a ItemID or a HouseID. So that I can do validatoin checks in the process page. But it be illogical to query both houses table and item table if I don't know if I am carrying a House ID or a ItemID first.

 

i need some way of adding a "Type" to the ID value.

Link to comment
https://forums.phpfreaks.com/topic/108243-help-adding-second-id-to-select-box/
Share on other sites

i'm not sure what the select boxes do, but there's probably a post method involved since they'd be attached to a form. When a user clicks a 'submit' button the $_POST variables will hold all the info from the select boxes.

If you're wanting to know which form was submitted then you can just ad a value to the submit button.

 

<form name='form1' method='post' action='processpage.php'>

<input type='submit' name='itemtable' />

</form>

 

then on the process page we do

 

if(isset($_POST['itemtable'])){

 

}

we now know which form was submitted. hope this helps.

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.