Yup Yup , you sure could.. Or you could also use while ($array_name=mysql_fetch_Array($result)) {..} but for some reason i always write at least a couple extra lines and use number of rows.. I guess it is because thats how i learned it first :))
Gurhan -----Original Message----- From: Nathan [mailto:[EMAIL PROTECTED]] Sent: Friday, March 15, 2002 6:31 PM To: Gurhan Ozen; mailing list; [EMAIL PROTECTED] Subject: Re: drop down list using php and mysql You could also bypass the num_rows entirely... <?php $query="select field from table"; $result=mysql_query($query) or exit(mysql_error()."<BR>".$query); echo '<select name="categories">'; for ($i=0; $row = mysql_fetch_assoc($result); $i++) { echo '<option>'.($row["field"]).''; } echo '</select>'; ?> # Nathan ----- Original Message ----- From: "Gurhan Ozen" <[EMAIL PROTECTED]> To: "mailing list" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, March 15, 2002 4:17 PM Subject: RE: drop down list using php and mysql A correction... for line has the greater sign wrong:) It has to be : for ($i=0; $numresult > $i; $i++) Sorry about that:) Gurhan -----Original Message----- From: Gurhan Ozen [mailto:[EMAIL PROTECTED]] Sent: Friday, March 15, 2002 6:01 PM To: mailing list; [EMAIL PROTECTED] Subject: RE: drop down list using php and mysql Hi, This type of qustion should be forwarded to PHP-DB list. Its adres is: [EMAIL PROTECTED] . As for the answer to your question.. IF you'd like to create a dynamic drop-down menu.. You can just just query the table for the options to be displayed and loop through the result set and print them on html .. For example: $query="select field from table"; $result=mysql_query($query); $numrows=mysql_num_rows($result); echo '<select name="categories">'; for ($i=0; $numresult < $i; $i++) { $row=mysql_fetch_array($result); echo '<option>'.($row["field"]).''; } Gurhan --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php