Re: Challenge: MySql result to drop down box
- From: "Norman Peelman" <npeelman@xxxxxxxxxx>
- Date: Thu, 13 Jul 2006 23:35:46 GMT
"Jim S" <try@xxxxxxxx> wrote in message news:U7utg.17$OI5.7@xxxxxxxxxxx
I think I have narrowed it down to the for loop causing the problem...Try:
Jim S wrote:
I have made the two changes you suggested but am still not receiving a
result set. Let me repost my modified code.
<?php
$res=mysql_query("SELECT DISTINCT job_name FROM
oats_jobs_users_laborCode where user='$username' order by job_name");
echo "<select name=jobname> <option default='default'>Choose
One</option>";
for ($i=0; $i <= mysql_num_rows(); $i++)
{
$row=mysql_fetch_assoc($res);
echo "<option value='$row[job_name]'>$row[job_name]</option>";
}
echo "</select>";
?>
or
<?php
$res=mysql_query("SELECT DISTINCT job_name FROM
oats_jobs_users_laborCode where user='$username' order by job_name");
echo "<select name=jobname> <option default='default'>Choose
One</option>";
while($row=mysql_fetch_assoc($res))
{
echo "<option value='$row[job_name]'>$row[job_name]</option>";
}
echo "</select>";
?>
also:
mysql_fetch_row($res) = [0] numerical indicies
mysql_fetch_assoc($res) = ['job_name'] alphanumeric indicies
mysql_fetch_array($res, type) where type is MYSQL_NUM ([0]), MYSQL_ASSOC
(['job_name']), or MYSQL_BOTH ([0] & ['job_name'])
Norm
.
- 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: Jim S
- Challenge: MySql result to drop down box
- Prev by Date: Re: PHP paypal integration
- Next by Date: Re: uploading a document and moving to a subfolder
- 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
|