Jump to content

[SOLVED] Database-populated dropdown sends truncated variable - why?


Recommended Posts

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>";

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.

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.

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 =)

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)

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.