cclark40 Posted November 11, 2008 Share Posted November 11, 2008 Hi Folks, I have a problem with the script below. It simply populates a dropdown box as part of a larger form with data from a database and sends it to the submit page where it updates the database. The data populates fine but when it sends to the submit page it truncates the data so only the first word of the variable gets sent. Most of the entries are a single word so work fine but a few have 2 or 3 words separated by a space so "Williamstown" is fine but "Horsham Kalimna Park" just becomes "Horsham". Can anyone see what the problem is? $result2 = mysql_query("SELECT id, clubname FROM clubs"); echo "<select name='tournamentvenue2update'><option></option>"; while($club_list2=mysql_fetch_array($result2)) { echo '<option value='.$club_list2[clubname].'>'.$club_list2[clubname].'</option>'; } echo "</select>"; Quote Link to comment https://forums.phpfreaks.com/topic/132350-solved-database-populated-dropdown-sends-truncated-variable-why/ Share on other sites More sharing options...
DarkWater Posted November 11, 2008 Share Posted November 11, 2008 You aren't putting " " around the text in the value attribute of the option tag. Just look at the generated source code to see what I mean. Quote Link to comment https://forums.phpfreaks.com/topic/132350-solved-database-populated-dropdown-sends-truncated-variable-why/#findComment-688111 Share on other sites More sharing options...
premiso Posted November 11, 2008 Share Posted November 11, 2008 edit, just noticed the <option value= does not have " surrounding the data. That is the issue. Thank Darkwater for that =P A side not: you should surround clubname with single or double quotes so it is note taken as a constant. Quote Link to comment https://forums.phpfreaks.com/topic/132350-solved-database-populated-dropdown-sends-truncated-variable-why/#findComment-688112 Share on other sites More sharing options...
DarkWater Posted November 11, 2008 Share Posted November 11, 2008 Where is the submit page portion? Also you should surround clubname with single or double quotes so it is not taken as a constant. The submit page part isn't important; it's just the generation of the dropdown that's causing problems. And yes, array key should enclosed in quotation marks unless they are integers. Quote Link to comment https://forums.phpfreaks.com/topic/132350-solved-database-populated-dropdown-sends-truncated-variable-why/#findComment-688114 Share on other sites More sharing options...
premiso Posted November 11, 2008 Share Posted November 11, 2008 Where is the submit page portion? Also you should surround clubname with single or double quotes so it is not taken as a constant. The submit page part isn't important; it's just the generation of the dropdown that's causing problems. And yes, array key should enclosed in quotation marks unless they are integers. Yea just saw that, notice the edit above =) Quote Link to comment https://forums.phpfreaks.com/topic/132350-solved-database-populated-dropdown-sends-truncated-variable-why/#findComment-688115 Share on other sites More sharing options...
cclark40 Posted November 12, 2008 Author Share Posted November 12, 2008 So are we simply saying it should read....? $result2 = mysql_query("SELECT id, clubname FROM clubs"); echo "<select name='tournamentvenue2update'><option></option>"; while($club_list2=mysql_fetch_array($result2)) { echo "<option value='.$club_list2[clubname].'>'.$club_list2[clubname].'</option>"; } echo "</select>"; Amazing that it worked at all!!! Thanks guys - I'll try it out later (at work at the moment and this is a home project) Quote Link to comment https://forums.phpfreaks.com/topic/132350-solved-database-populated-dropdown-sends-truncated-variable-why/#findComment-688207 Share on other sites More sharing options...
DarkWater Posted November 12, 2008 Share Posted November 12, 2008 No, you still did it wrong. =/ echo '<option value="' . $club_list2['clubname'] . '">' . $club_list2['clubname'] . '</option>'; Quote Link to comment https://forums.phpfreaks.com/topic/132350-solved-database-populated-dropdown-sends-truncated-variable-why/#findComment-688209 Share on other sites More sharing options...
cclark40 Posted November 12, 2008 Author Share Posted November 12, 2008 OK I see. For some reason I couln't see the earlier code snippet ??? Thanks so much - You guys are amazing!!! Quote Link to comment https://forums.phpfreaks.com/topic/132350-solved-database-populated-dropdown-sends-truncated-variable-why/#findComment-688228 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.