On Fri, 23 Feb 2001 05:21, Claudia wrote:
> When selecting a value from a dynamically generated list box, the
> subsequent value passed to the table truncates when
> there is a blank in the string
>
> Here is the table structures (Mysql database)
>
> First table has variable course_name (varchar -- length 50)
> This database will be used to generate the dynamic list box for the
> course_name field.
> Second table has variable issue_course_name (varchar -- length50) and
> is the variable that stores the result of the selected
> course name in the dynamic list box.
>
> Here is the code that is currently truncating all characters after the
> space:
>
> td height="41" bgcolor="#FFFFFF"> ';
>
> $result = mysql_query("select course_name from coursebuild
> where course_status = \"in_test\"
> order by course_name asc");
>
> echo "<select name='issue_course_name' size=1>";
> echo "<option value=''> ----Select Course---- \n";
>
> if ($myrow = mysql_fetch_array($result))
> {
> do
> {
> echo "<option
> value=$myrow[course_name]>$myrow[course_name]</option>\n";
> }
> while ($myrow = mysql_fetch_array($result));
> echo "</select>";
>
> Insert statement
>
> $query = "insert into testissues ( issue_course_name)
> values ( '$issue_course_name') ";
> $mysql_result = mysql_query($query, $mysql_link);
IIRC the relevant standards require that values in tags be enclosed in
quotes if they [are likely to] contain spaces. So at minimum your OPTION
tags should look like:
echo "<option
value=\"$myrow[course_name]\">$myrow[course_name]</option>\n";
Having said that, you could handle this better if you have an
autoincrement field like course_id that uniquely defines each course_name
record - then you could use the course_id as the VALUE in the option tag;
you may have to do a lookup at the INSERT stage to get the value of
course_name.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]