Quick question about checking form post variables / arrays

From: Date: Sun, 28 Jul 2002 03:57:12 +0000
Subject: Quick question about checking form post variables / arrays
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5476@lists.php.net to get a copy of this message
I've been trying to figure out how to do what I'll explain here, but with no success. If anyone can shed some light into this it would be very appreciated. Ok, so in HTML you can just name your form elements field[] and that field is turned into an array automatically on your PHP script. What I have been trying to do is the following: <select name="category[]" multiple size="3"> {section name="y" loop=$cats} <option value="{$cats[y].cat_id}">{$cats[y].cat_title}</option> {/section} </select> But if there is any information missing on the form, I make the same form appear again to the user, with the information already filled out. While I can easily just do the following for text fields: <input type="text" name="name" value="{$smarty.post.name}"> I don't know how to make the select box above have the appropriate options selected by default. How do I check if that {$cats[i].cat_id} is inside the $smaty.post.category variable in Smarty ? Joao -- João Prado Maia <jpm@phpbrasil.com> http://phpbrasil.com - php com um jeitinho brasileiro -- Precisando de consultoria em desenvolvimento para a Internet ? Impleo - http://impleo.net/?lang=br -- Leia mais sobre os nossos serviços e produtos http://impleo.net/products.php?lang=br

« previous php.smarty.general (#5476) next »