You are here: Re: Challenge: MySql result to drop down box « All PHP « IT news, forums, messages
Re: Challenge: MySql result to drop down box

Posted by Norman Peelman on 07/13/06 23:35

"Jim S" <try@to.guess> wrote in message news:U7utg.17$OI5.7@fe07.lga...
> I think I have narrowed it down to the for loop causing the problem...
>
> 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.
> >
Try:

<?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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация