Submit 2 Variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Submit 2 Variables

Post by SidewinderX »

Here is a piece of my code im working with

Code: Select all

$sql41 = "SELECT * FROM ".$prefix."_theme_authors ORDER BY author ASC";
$result41 = $db->sql_query($sql41);
echo "<form action='index.php' method='get'>
<select name='name'>";
while($row41 = $db->sql_fetchrow($result41)){
echo "<option value='".$row41['author']."'>".$row41['author']."</option>";
}
echo "</select>

<input type='submit' />
</form>";
this submits index.php?name=$author where $author is the author selected, however i want to submit $author and the $default_theme associated with the author so it would look like index.php?name=$author&t=$default_theme but i am unsure how to go about this...i tired

Code: Select all

echo "<option value='".$row41['author']."&t=".$row41['default_theme']."'>".$row41['author']."</option>";
but that didnt work....

I'd guess i have to have a hidden input but i dont know how to have the author I select from the menu associate itself with the default_theme it is pared with.

thank you.
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

Post by Nathaniel »

Probably the easiest way would be to seperate the two values with a character that is not allowed in either the author's name or the theme's name...

like "value="Joe.default_theme". Then explode() it on the '.'; the first element will be the author's name, the second, the theme.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

^ seems like the best idea. If not, try using javascript to set a hidden field when the select field is selected.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

If you added a default_theme like that you are getting more than the users input.
If you are adding in the default_theme into the html as you generate the form surely you can use the same process that gets that data to find the default_theme from an author server side.

What I'm saying is, you shouldn't need to do this, ordinarily anyway.
Post Reply