[PHP-DB] Re: Dropdown menus from DB query
this is where smarty templating is so cool using PEAR db php code $sql = 'select id, name from names order by name asc'; $smarty-assign('names',$db-getAssoc($sql)); template select name=name {html_options options=$names} /select Cole Ashcraft wrote: How would you create a drop down menu from a database query? I have figured how to do it with one field, but how could it be done with a system where the value is different than the displayed value (ie. numerical code as the value, name displayed)? Thanks, Cole -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Dropdown menus from DB query
hello. for my self, i hate to use \ beucase it gets me confuse all the time. my verison is echo option value =' .$array['code'].'.$array['name']./option; btw, you have a extra at the end of your code. echo option value=\.$array[code].\.$array[name]./option; * * ^extra Shahmat Bin Dahlan wrote: I think this is the line which is the cause of your coding woes... The quote () doesn't have any matching pair. There's one quote in front, but there's none at the back. echo select name=\dropdown\; * * - Original Message - From: Cole Ashcraft [EMAIL PROTECTED] Date: Friday, June 18, 2004 9:23 am Subject: Re: [PHP-DB] Dropdown menus from DB query Thanks. I think I can work from this. Just to let you know, it generatesa parse error ( I think its because of the quotes). Cole On Thu, 2004-06-17 at 18:09, Ng Hwee Hwee wrote: hmm... what about something like this?? echo select name=\dropdown\; $query = select code, name from table; $result = mysql_query($query); while($array = mysql_fetch_array($result)) { echo option value=\.$array[code].\.$array[name]./option; } echo /select; hth - Original Message - From: Cole Ashcraft [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, June 18, 2004 7:50 AM Subject: [PHP-DB] Dropdown menus from DB query How would you create a drop down menu from a database query? I have figured how to do it with one field, but how could it be done with a system where the value is different than the displayed value (ie. numerical code as the value, name displayed)? Thanks, Cole -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Dropdown menus from DB query
Smarty Templating? I've heard of that before, but can you tell me a little more about it? Is it built into PHP, or does it need to be installed separately? Thanks to everyone who helped me, Cole pete M wrote: this is where smarty templating is so cool using PEAR db php code $sql = 'select id, name from names order by name asc'; $smarty-assign('names',$db-getAssoc($sql)); template select name=name {html_options options=$names} /select Cole Ashcraft wrote: How would you create a drop down menu from a database query? I have figured how to do it with one field, but how could it be done with a system where the value is different than the displayed value (ie. numerical code as the value, name displayed)? Thanks, Cole -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Dropdown menus from DB query
No, the \ (backslash) tells PHP to echo the . This prevents PHP from thinking that the quote means the end of an echo statement. Cole Shahmat Bin Dahlan wrote: I think this is the line which is the cause of your coding woes... The quote () doesn't have any matching pair. There's one quote in front, but there's none at the back. echo select name=\dropdown\; * * - Original Message - From: Cole Ashcraft [EMAIL PROTECTED] Date: Friday, June 18, 2004 9:23 am Subject: Re: [PHP-DB] Dropdown menus from DB query Thanks. I think I can work from this. Just to let you know, it generatesa parse error ( I think its because of the quotes). Cole On Thu, 2004-06-17 at 18:09, Ng Hwee Hwee wrote: hmm... what about something like this?? echo select name=\dropdown\; $query = select code, name from table; $result = mysql_query($query); while($array = mysql_fetch_array($result)) { echo option value=\.$array[code].\.$array[name]./option; } echo /select; hth - Original Message - From: Cole Ashcraft [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, June 18, 2004 7:50 AM Subject: [PHP-DB] Dropdown menus from DB query How would you create a drop down menu from a database query? I have figured how to do it with one field, but how could it be done with a system where the value is different than the displayed value (ie. numerical code as the value, name displayed)? Thanks, Cole -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Dropdown menus from DB query
Actually is named a Scape Character Miguel Guirao Servicios Datacard www.SIASA.com.mx -Mensaje original- De: Cole Ashcraft [mailto:[EMAIL PROTECTED] Enviado el: Viernes, 18 de Junio de 2004 11:06 a.m. Para: [EMAIL PROTECTED] Asunto: Re: [PHP-DB] Dropdown menus from DB query No, the \ (backslash) tells PHP to echo the . This prevents PHP from thinking that the quote means the end of an echo statement. Cole Shahmat Bin Dahlan wrote: I think this is the line which is the cause of your coding woes... The quote () doesn't have any matching pair. There's one quote in front, but there's none at the back. echo select name=\dropdown\; * * - Original Message - From: Cole Ashcraft [EMAIL PROTECTED] Date: Friday, June 18, 2004 9:23 am Subject: Re: [PHP-DB] Dropdown menus from DB query Thanks. I think I can work from this. Just to let you know, it generatesa parse error ( I think its because of the quotes). Cole On Thu, 2004-06-17 at 18:09, Ng Hwee Hwee wrote: hmm... what about something like this?? echo select name=\dropdown\; $query = select code, name from table; $result = mysql_query($query); while($array = mysql_fetch_array($result)) { echo option value=\.$array[code].\.$array[name]./option; } echo /select; hth - Original Message - From: Cole Ashcraft [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, June 18, 2004 7:50 AM Subject: [PHP-DB] Dropdown menus from DB query How would you create a drop down menu from a database query? I have figured how to do it with one field, but how could it be done with a system where the value is different than the displayed value (ie. numerical code as the value, name displayed)? Thanks, Cole -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php