Re: Challenge: MySql result to drop down box
- From: "Rik" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Thu, 13 Jul 2006 23:10:05 +0200
shubeer wrote:
Here's how I would have written the code to build the select box:
<?php
$res=mysql_query("SELECT DISTINCT job_name AS JOB_NAME FROM
oats_jobs_users_laborCode where user='$username' order by job_name")
or die('Query failed');
echo "<select name='jobname'><option SELECTED='SELECTED'>Choose
One</option>";
foreach($row as mysql_fetch_assoc($res)) {
echo "<option value='{$row[JOB_NAME]}'>{$row[JOB_NAME]}</option>";
}
echo "</select>";
Which will give an E_NOTICE error.
Use {$row['JOB_NAME']}.
also, make sure that the $username variable doesn't have a quote (')
in it or the query will fail
Yup, mysql_real_escape_string() it.
Grtz,
--
Rik Wasmus
.
- References:
- Challenge: MySql result to drop down box
- From: Jim S
- Re: Challenge: MySql result to drop down box
- From: Rik
- Re: Challenge: MySql result to drop down box
- From: Rik
- Re: Challenge: MySql result to drop down box
- From: Jim S
- Re: Challenge: MySql result to drop down box
- From: shubeer
- Challenge: MySql result to drop down box
- Prev by Date: Re: uploading a document and moving to a subfolder
- Next by Date: Re: Challenge: MySql result to drop down box
- Previous by thread: Re: Challenge: MySql result to drop down box
- Next by thread: Re: Challenge: MySql result to drop down box
- Index(es):
Relevant Pages
|