[Solved] Clean repeated fields in a form list
Posted: Fri Feb 20, 2009 8:27 pm
I got to know a bit of SQL, PHP and SMARTY in the last few days. My head is going mad.
I have created a tag {search_test} that send a request to the database:
Then the results are inserted into an html form, in a list:
I am getting a list of countries but many are repeated. I have tried to clean it with an {if} but I can't make it work.
Any idea?
I looking for something similar to
Your help is welcome
I have created a tag {search_test} that send a request to the database:
Code: Select all
include "config.php";
if(!($db = @mysql_connect($config['db_hostname'],$config['db_username'],$config['db_password']))) //connect to database
die("couldn't connect to the database.");
if(!@mysql_select_db($config['db_name'],$db)) // Select Database
die("database doesn't exist!");
$sql = "SELECT wc_tipo, wc_pais, wc_start, wc_trabajo FROM wc_test ORDER BY wc_nombre ASC";
// get all the products from the table
$res = mysql_query($sql);
$results = array();
while ($arow = mysql_fetch_array($res)) {
array_push($results, $arow);
}
$smarty->assign('s_tab',$results);
Code: Select all
<form action="get_results.php" method="post">
<p>choose a country:
<select name="Country">
{section name=idx loop=$s_tab}
echo "<option value="{$s_tab[idx].wc_pais}"> {$s_tab[idx].wc_pais}</option><br />";
{/if}
{/section}
</select></p>
Any idea?
I looking for something similar to
Code: Select all
{if $s_tab[idx].wc_pais. != $s_tab[idx+1].wc_pais}