Mossman Posted December 14, 2007 Share Posted December 14, 2007 Hi, I have been reading previous threads on dynamic lists. I just want to populate a list with a field from a table. The code I am using is: echo "<select name='selectcompany'>"; echo "<option value=$row[ar_name]>$row[ar_name]</a></option>"; echo "</select>"; It is taking each record and putting the results in their own seperate lists rather than all in the same drop down list. I know it's probably something simple I'm not doing but I've tried other peoples solutions and it's not working for me. I'd appreciate any suggestions! Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 14, 2007 Share Posted December 14, 2007 post your while loop Quote Link to comment Share on other sites More sharing options...
corillo181 Posted December 14, 2007 Share Posted December 14, 2007 i don't understand your question. you have multiple company that you want to add to the select company drop down box? Quote Link to comment Share on other sites More sharing options...
Mossman Posted December 14, 2007 Author Share Posted December 14, 2007 it's looking like this: while ($row = mysql_fetch_assoc($result)) { echo "<form>"; echo "<select>"; echo "<option>" . $row['ar_name'] . "</option>"; echo "</select>"; echo "</form>"; }mysql_close($con); } Quote Link to comment Share on other sites More sharing options...
Mossman Posted December 14, 2007 Author Share Posted December 14, 2007 i don't understand your question. you have multiple company that you want to add to the select company drop down box? Yes that's right. So the user can choose a company from a drop down list. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 14, 2007 Share Posted December 14, 2007 should be echo "<form>"; echo "<select>"; while ($row = mysql_fetch_assoc($result)) { echo "<option>" . $row['ar_name'] . "</option>"; } echo "</select>"; echo "</form>"; Quote Link to comment Share on other sites More sharing options...
corillo181 Posted December 14, 2007 Share Posted December 14, 2007 echo "<form>"; echo "<select>"; while ($row = mysql_fetch_assoc($result)) { echo "<option>" . $row['ar_name'] . "</option>"; } echo "</select>"; echo "</form>";mysql_close($con); } i know you can tell the problem now. Quote Link to comment Share on other sites More sharing options...
Mossman Posted December 14, 2007 Author Share Posted December 14, 2007 Ah that seems to have done the trick! Thank's for the help! I'd chopped and changed it so much I was totally lost. Thanks guys. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted December 14, 2007 Share Posted December 14, 2007 no problem remember to click the solved button. Quote Link to comment 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.