Xtremer360 Posted December 14, 2010 Share Posted December 14, 2010 Not sure whether this belongs in php or javascript seeing as how it deals with both but we'll see what kind of responses I get. I have a dropdown that lists countries and their id from my database and then when the user selects one it sends a post parameter through jquery to a php process page where it matches up the countryid to all the arenas in a table and then here's wehre I'm stuck I already have a dropdown in form like so: <div class="field required"> <label for="arena">Arenas</label> <select class="dropdown" name="arenas" id="arenas" title="Arenas"> </select> <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span> </div> I'm not sure how I should send over the values if I should just pass over the entire dropdown box with the values or just send back the values. Any opinions? Quote Link to comment https://forums.phpfreaks.com/topic/221672-query-and-php/ Share on other sites More sharing options...
jdavidbakr Posted December 14, 2010 Share Posted December 14, 2010 I don Quote Link to comment https://forums.phpfreaks.com/topic/221672-query-and-php/#findComment-1147345 Share on other sites More sharing options...
Elridan Posted December 14, 2010 Share Posted December 14, 2010 I just did something similar where I just supplied the values. Quote Link to comment https://forums.phpfreaks.com/topic/221672-query-and-php/#findComment-1147347 Share on other sites More sharing options...
Xtremer360 Posted December 14, 2010 Author Share Posted December 14, 2010 Do you have somethign I can see to compare to and apply something that would work for me into my code. Quote Link to comment https://forums.phpfreaks.com/topic/221672-query-and-php/#findComment-1147351 Share on other sites More sharing options...
Elridan Posted December 15, 2010 Share Posted December 15, 2010 I hope I'm not leading you completely astray, and if I am I hope someone comes by and tells me how wrong I am and why. I'm not sure if this code would work, I haven't been working with PHP for very long, but this is what I thought about when you told me your problem: page.php?countryid=10 <? $countryid = $_GET['countryid']; $query = "select arena, arenaid from database where countryid = '".$countryid."'"; $result = mysql_query($query); $numrows = mysql_num_rows($result); $i = 0; while ($i < $numrows) { $arenano = $i+1; $arena = mysql_result($result, $i, "arena"); $arenaid = mysql_result($result, $i, "arenaid"); $slct = "arena".$arenano; $$slct = "<option value = '".$arenaid."'>".$arena."</option> "; $slcts .= ".arena".$arenano; $select = $$slcts."."; i++; } echo " <div class='field required'> <label for='arena'>Arenas</label> <select class='dropdown' name='arenas' id='arenas' title='Arenas'>" .$$select. "</select> <span class='required-icon tooltip' title='Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. '>Required</span> </div>"; ?> The code *should* get the arenas and generate a variable containing a select tag with each arena in it. It then creates another variable that contains all the option tags. Afterwords the variable is inserted between the select statement. Hopefully this works the way I think it does, and if not hopefully it at least gives you an idea of what you want to do. edited: modified code Quote Link to comment https://forums.phpfreaks.com/topic/221672-query-and-php/#findComment-1147863 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.