Tabelle e variabili vuote
-
Ciao a tutti ecco il mio problema.
Ho un file php nel quale prendo i dati da mysql, setto la lingua con un cookie setto le variabili e attraverso un file .tpl visualizzo i risultati che sono cosi:
arance: 2 mandarini: 4 ananas: 5
pere: 3 mele: 6 banane: 7
noci: 4 mandorle: 9 prugne: 6Tanto arance che 2 sono variabili (cosi come tutte le altre)_nel senso che arance viene settata in base alla lingua di viusalizzazione.
Nel caso un valore sia zero ad esempio mandarini la tabella mi appare cosi:
arance: 2 mandarini: ananas: 5
pere: 3 mele: 6 banane: 7
noci: 4 mandorle: 9 prugne: 6Inserendo un ciclo if controllando il valore di mandarini e non passando la variabile mandarini mi appare cosi:
arance: 2 ananas: 5
pere: 3 mele: 6 banane: 7
noci: 4 mandorle: 9 prugne: 6Mentre io vorrei che mi apparisse cosi:
arance: 2 ananas: 5 pere: 3
mele: 6 banane: 7 noci: 4
mandorle: 9 prugne: 6Avete qualche dritta da darmi??
-
Puoi postarci il codice?
-
file php
if (isset($_GET['id']) && eregi('^[0-9]+$', $_GET['id'])) { $sql = 'SELECT title FROM ' . PROPERTIES_TABLE . ' WHERE approved = 1 AND id = ' . intval($_GET['id']) . ' LIMIT 1'; $r_title = $db->query ( $sql ); $f_title = $db->fetcharray ( $r_title ); } $f = $db->fetcharray( $r ); // Starting a new template $template = new Template; $tpl = implode ('', file( PATH . '/templates/' . $cookie_template . '/tpl/property_detailed.tpl' )); // Load listing short search results template $template->load ( $tpl ); // Make all values in the array 'n/a' if empty $f = array_map ( 'if_empty', $f); $template->set ( 'dimensions', $f['dimensions'] ); $template->set ( 'bathrooms', $f['bathrooms'] ); $template->set ( 'half_bathrooms', $f['half_bathrooms'] ); $template->set ( 'bedrooms', $f['bedrooms'] ); $template->set ( 'soggiorno', $f['soggiorno'] ); include ( PATH . '/templates/' . $cookie_template . '/footer.php' );file property_detailed.tpl
<tr> <td width="65%" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td width="32%"><b><font color="#DD6900">{@price}:</font></b></td> <td width="68%"><span class="price">{currency} {price} {@trattative_riservate}</span> </td> </tr> <tr> <td><b><font color="#DD6900">{@type2}:</font></b></td> <td>{type2}</td> </tr> <tr> <td><b><font color="#DD6900">{@type}:</font></b></td> <td>{type}</td> </tr> <tr> <td><b><font color="#DD6900">{@style}:</font></b></td> <td>{style}</td> </tr> <tr> <td><b><font color="#DD6900">{@year_built}:</font></b></td> <td>{year_built}</td> </tr> <tr> <td valign="top"><b><font color="#DD6900">{@location}:</font></b></td> <td>{address1} {address2} {city} {location} {zip}</td> </tr> <tr> <td valign="top"><b><font color="#DD6900">{@directions}:</font></b></td> <td>{directions}</td> </tr> </table> </td> </tr> <tr> <td><br><br> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td width="25%"><b><font color="#DD6900">{@bedrooms}:</font></b></td> <td width="25%">{bedrooms} </td> <td width="25%"><b><font color="#DD6900">{@soggiorno}:</font></b></td> <td width="25%"><? if (!empty($f['soggiorno'])) { ?> {soggiorno} <br> <? } ?></td> <td width="40%"><b><font color="#DD6900">{@half_bathrooms}:</font></b></td> <td width="25%">{half_bathrooms}</td> </tr> <tr> <td><b><font color="#DD6900">{@bathrooms}:</font></b></td> <td>{bathrooms}</td> <td><b><font color="#DD6900">{@lot_size}:</font></font></b></td> <td>{lot_size} </td> </tr> <tr> <td><b><font color="#DD6900">{@basement}:</font></b></td> <td>{basement}</td> <td><b><font color="#DD6900">{@dimensions}:</font></b></td> <td>{dimensions}</td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td><br><br> <table width="100%" border="0" cellspacing="0" cellpadding="2"> </table><br><br> </td> </tr> <tr> <td> <table cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td width="100%" style="border-top: 1px dotted #BABABA;"><br> </td> </tr> </table> </td> </tr> <tr> <td>{description}<br><br> </td> </tr> <tr> <td> </td> </tr> </table>
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi