RE: [PHP] Building Dynamic Value list using ohp
| From: | Maxim Maletsky \(PHPBeginner.com\) | Date: | Wed, 26 Sep 2001 15:15:10 +0000 |
| Subject: | RE: [PHP] Building Dynamic Value list using ohp | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-68882@lists.php.net to get a copy of this message | ||
If you see no errors this might mean you have no records :-)
Maxim Maletsky
www.PHPBeginner.com
-----Original Message-----
From: Derek Mailer [mailto:derek.mailer@bipcontracts.com]
Sent: mercoledì 26 settembre 2001 17.14
To: George Pitcher
Cc: php-general@lists.php.net
Subject: Re: [PHP] Building Dynamic Value list using ohp
what's the error you're getting now?
if you aren't getting any error, but it just isn't working try something
like...(note that I haven't tested this code).
$drop_down_list = "<select name=\"select\">";
$link = mysql_connect ('localhost', '****', '****')
or die ("Could not select db");
mysql_select_db ('Heronsql')
or die ("Could not connect");
$query="select distinct HEI from heronuser";
$result = mysql_query ($query);
$num = mysql_num_rows($result);
for ($i = 0; $i < $num; $i++) {
$HEI = mysql_result($result, $i, "HEI");
$drop_down_list .= "<option
value=\"$HEI\">$HEI</option>";
}
mysql_close($link);
$drop_down_list .= "</select>";
echo "$drop_down_list";
Cheers the noo,
Derek
----- Original Message -----
From: "George Pitcher" <fmdev@yahoo.co.uk>
To: "Maxim Maletsky (PHPBeginner.com)" <php-general@phpbeginner.com>;
<php-general@lists.php.net>
Sent: Wednesday, September 26, 2001 3:42 PM
Subject: Re: [PHP] Building Dynamic Value list using ohp
> Thanks for everyone's help but this is still failing to work.
>
> Revised code is:
>
> <?php
> $link = mysql_connect ('localhost', '****', '****')
> or die ("Could not select db");
> mysql_select_db ('Heronsql')
> or die ("Could not connect");
> $query="select distinct HEI from heronuser";
> $result = mysql_query ($query); // I've also tried with ($query,
$link)
> if(mysql_num_rows($result)) {
> // show all HEIs as options in select form
> while($row = mysql_fetch_row($result))
> {
> print("<option
> value=\"{$row[0]}\">{$row[0]}</option>");
> }
> }
> mysql_close($link);
> ?>
>
> Any more suggestions (please)?
>
> George
> ----- Original Message -----
> From: "Maxim Maletsky (PHPBeginner.com)" <php-general@phpbeginner.com>
> To: "'George Pitcher'" <fmdev@yahoo.co.uk>;
> <php-general@lists.php.net>
> Sent: Wednesday, September 26, 2001 3:17 PM
> Subject: RE: [PHP] Building Dynamic Value list using ohp
>
>
>
> 1. this:
> print("<option value=\"$row[0]\">$row[0]</option>");
> should be this:
> print("<option value=\"{$row[0]}\">{$row[0]}</option>");
> or like this:
> echo '<option
> value="'.$row[0].'">'.$row[0].'</option>');
>
> The reason for it is that within double quote you can parse for
> 'simple' variables only (es: $var, not $var[]). Otherwise it gives you
> a parse error.
>
> 2. this:
> mysql_connect ('localhost', 'root', 'monty');
> better be this:
> mysql_connect ('localhost', '****', '****'); // for security
> reasons
> obviously, you don't wanna give the password our to the group, even so
> it is your local server (you might not be original with the password
> on production machines, no?)
>
>
> Hope it helps,
> Maxim Maletsky
>
> PHPBeginner.com
>
>
>
>
> -----Original Message-----
> From: George Pitcher [mailto:fmdev@yahoo.co.uk]
> Sent: mercoledì 26 settembre 2001 15.31
> To: php-general@lists.php.net
> Subject: [PHP] Building Dynamic Value list using ohp
>
>
> Hi all,
>
> I'm having a problem with dynamically building a value list.
>
> My code:
>
> <?php
> mysql_connect ('localhost', 'root', 'monty');
> mysql_select_db ('Heronsql');
> $query = ("select HEI from heronuser"); // LINE 22 on original
script
> $result = mysql_query($query, $mysql_link);
> if(mysql_num_rows($result)) {
> // show all HEIs as options in select form
> while($row = mysql_fetch_row($result))
> {
> print("<option value=\"$row[0]\">$row[0]</option>");
> }
> }
> ?>
>
> But this generates:
>
> "Parse error: parse error in c:\program files\apache
> group\apache\htdocs\bizflyers\login.php on line 22"
>
> Any suggestions?
>
> Regards
>
> George
>
>
>
> _________________________________________________________
>
> Do You Yahoo!?
>
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net To
> contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net To
> contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net To
> contact the list administrators, e-mail: php-list-admin@lists.php.net
>
************************************************************************
**********
This e-mail (and any attachment) is intended only for the attention of
the addressee(s). Its unauthorised use, disclosure, storage or copying
is not permitted. If you are not the intended recipient, please destroy
all copies and inform the sender by return e-mail.
This e-mail (whether you are the sender or the recipient) may be
monitored, recorded and retained by Business Information
Publications Limited (BiP). E-mail monitoring/ blocking software
may be used, and e-mail content may be read at any time.You
have a responsibility to ensure laws are not broken when composing
or forwarding e-mails and their contents.
************************************************************************
**********
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net To
contact the list administrators, e-mail: php-list-admin@lists.php.net