Impaginare risultati
-
-
Sups
Dato che la query, cioè la richiesta al DB, è limitata ad un risultato (LIMIT 1), non è possibile ricavare più di una foto, di conseguenza è impossibile affiancarle.Eccomi, scuami il ritardo ma sono stata via
Ho provato ad eliminare "LIMIT 1" ma è tutto come prima :bho:
Anche perchè, se volessi limitare a un solo risultato, comunque dovrebbe mostrarmelo no? e invece nulla.
Come ti dicevo l'output della query ora è questoDebug di OUT Debug di OUT Debug di OUT Debug di OUT Debug di OUT Debug di OUT Debug di OUT Debug di OUT Debug di OUTNon capisco dov'è il problema. Con la pagina originale funzionante mi mostra tutto correttamente ma uno solo per riga, è così difficile mostrarne 3 per riga?

Aiutatemi ragazzi!!!

-
Sups
Il problema potrebbe essere nelle query che non restituiscono i giusti risultati, oppure nella struttura del codice html generato.
Potresti postere il codice html generato per vedere se è presente qualche traccia della tabella generata da $out.Ciao Sups,
in poche parole devo postarti tutto il codice della pagina?
Grazie! -
-
ti allego qui il codice che funziona con 1 solo risultato per riga....
il resto della pagina me lo faccio mandare e te lo allego domani (cioè oggi :D).... grazie ancora!
Sara<? // display results if($numitems > 0) { $link = mysql_connect($dbhost, $dbuser, $dbpass); $query .= " ORDER BY updated DESC LIMIT $startitem, $perpage"; //echo "$query<br><br>"; // TEST $result = mysql_db_query($dbname, $query, $link); $n = 1; while($data = mysql_fetch_array($result)) { // check to see if there is an image to display if($data[numimages]) { $query = "SELECT thumb FROM $dbimg WHERE ccode='$data[ccode]' ORDER BY id DESC LIMIT 1"; $image = mysql_db_query($dbname, $query, $link); $image = mysql_fetch_array($image); $thumb = "<img src='thumbs/$image[thumb]' border=0>"; } else { $thumb = "<img src='common/nophoto.gif' border=0>"; } if(!($n % 2)) { $bg = "class='fill_light'"; } else { $bg = ''; } echo " <td align='center' height=60><a class='link' href='scheda.php?ccode=$data[ccode]$linkstring' target='_blank'>$thumb</a><br> <a class='link' href='scheda.php?ccode=$data[ccode]$linkstring' target='_blank'><b><font size=2>$data[make]</font><br>$data[stereo]<br>$data[model]</b></a></td> <tr> <td height=1><!-- LINE --></td></tr>   "; $n++; } mysql_close($link); } else { echo "<tr><td class='text' height=100 colspan=6 align='center' valign='middle'> <font class='hint'>Sorry no result.</font><br> </td></tr>"; } ?> -
-
Quando dici che funziona con un risultato per riga, vuol dire che mostra le immagini in sequenza su di una colonna verticale?
Prova a commentare in questo modo e poi dimmi cosa e successo:echo " <td align='center' height=60><a class='link' href='scheda.php?ccode=$data[ccode]$linkstring' target='_blank'>$thumb</a><br> <a class='link' href='scheda.php?ccode=$data[ccode]$linkstring' target='_blank'><b><font size=2>$data[make]</font><br>$data[stereo]<br>$data[model]</b></a></td> <!-- <tr> --> <td height=1><!-- LINE --></td></tr>E' da notare anche la struttura html non è ben definita, ad esempio, se qui vine chiuso il tag TR: <td height=1><!-- LINE --></td></tr>, dove viene creato quello iniziale?
Ciao!
-
Ciao!
Eccomi qui. Grazie ancora per la tua gentilezza ed il tuo aiuto.
Ho commentato come hai scritto tu.
Non è cambiato nulla....
Ovvero, rispondendo all'altra tua domanda, tutti i risultati sono incolonnati, uno per riga, mostrando l'immagine e la descrizione da cliccare per aprire poi la scheda.
Aiutooooooooooooooooooooooooooo -
Strano che lo script che ti avevo proposto all'inizio non funzioni.
Prova a modificarlo in questo modo://Da inserire prima del WHILE $riga = 1; $out = ""; //... //Da sostituire al precedente ECHO nel ciclo WHILE if($riga == 1) $out .= "<tr>"; else if($riga >= 1) { $out .= " <td align='center' height=60> <a class='link' href='scheda.php?ccode=$data[ccode]$linkstring' target='_blank'>$thumb</a><br> <a class='link' href='result.php?ccode=$data[ccode]$linkstring' target='_blank'> <b><font size=2>$data[mk]</font><br>$data[str]<br>$data[mo]</b></a> </td>"; $riga++; } else if($riga == 3) { $out .= "</tr>"; $riga = 1; } //CONDIZIONE FONDAMENTALE: echo fuori dal ciclo WHILE //Dopo la graffa di chiusura. echo $out; -
Ancora grazie della tua gentilezza.... ma per mia manifesta incapacità..sto diventando matta

Mi dà questo errore "Parse error: syntax error, unexpected T_ELSE"Questo è il codice originario che funziona mettendo i risultati su una colonna sola....
Posso chiederti di mettere tu le modifiche nel posto giusto? So che ti chiedo troppo ma io non so più che pesci pigliare
<?   require 'prodotti/global.php'; require 'prodotti/config/config.php';         // create link string that will be attached to each vehicle link $linkstring = "&startitem=$startitem&startpage=$startpage&endpage=$endpage¤t=$current&category=$category&make=$make&model=$model&condition=$condition";   // get info from database $link = mysql_connect($dbhost, $dbuser, $dbpass); $query = "SELECT updated FROM $dbvin ORDER BY updated DESC"; $result = mysql_db_query($dbname, $query, $link); $result = mysql_fetch_array($result); //$date = date('l d M, Y \a\l\l\e\ \o\r\e g:i a', $result[updated]); $query = "SELECT COUNT(*) FROM $dbvin"; $result = mysql_db_query($dbname, $query, $link); $result = mysql_fetch_array($result); $count = $result[0]; $result = mysql_db_query($dbname, "SELECT email, phone FROM $dbcfg", $link); $contact = mysql_fetch_array($result); mysql_close($link); // build search query string if neccessary if($condition || $make || $model || $stock || $body || $fuel) { // build query string $query = "SELECT * FROM $dbvin WHERE"; if($condition) { $query .= " condition='$condition' AND"; } if($make) { $query .= " make='$make' AND"; } if($model) { $query .= " model='$model' AND"; } if($stock) { $query .= " stock='$stock' AND"; } if($body) { $query .= " body='$body' AND"; } if($fuel) { $query .= " fuel='$fuel'"; } // trim extra AND if neccessary if(substr($query, strlen($query)-4, 4) == ' AND') { $query = substr($query, 0, strlen($query)-4); } } else { $query = "SELECT * FROM $dbvin"; } // get number of results $link = mysql_connect($dbhost, $dbuser, $dbpass); $result = mysql_db_query($dbname, $query, $link); if(mysql_num_rows($result)) { $numitems = mysql_num_rows($result); } else { $numitems = 0; } mysql_close($link); ?> <html> <head> <title>prova</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="css/default.css" rel="stylesheet" type="text/css"> <script language='JavaScript' src='functions.js'></script> </head> <body> <table class='trim' width=770 border=0 bgcolor=white cellpadding=3 cellspacing=0> <tr> <td colspan=5> <table width='100%' border=0 cellpadding=0 cellspacing=0> <td><a class='link' href="javascript:history.back()"><img src='common/indietro.gif' border=0 align='absmiddle'> Indietro </a></td> </table> </td> </tr> <tr> <td width='100%' colspan=6> <table width='100%' border=0 cellpadding=0 cellspacing=0> <tr class='text'> <? if($numitems > 0) { $numpages = ceil($numitems / $perpage); // THE TOTAL NUMBER OF PAGES if(!$startitem) { $startitem = 0; } // FIGURE startitem AND enditem VALUES if($startitem + $perpage > $numitems) { $enditem = $numitems; } else { $enditem = $startitem + $perpage; } if(!$startpage) { $startpage = 1; } // FIGURE startpage VALUE if(!$endpage) { // FIGURE endpage VALUE if($numpages > $numlinks) { $endpage = $numlinks; } else { $endpage = $numpages; } } } else { //echo "<td align='center'>no results error GOES HERE?</td>"; } ?> </table> </td> </td> <td rowspan="21"> </td>         <tr class='fill'><td height=1 colspan=10><!-- LINE --></td></tr> <? // display results if($numitems > 0) { $link = mysql_connect($dbhost, $dbuser, $dbpass); $query .= " ORDER BY updated DESC LIMIT $startitem, $perpage"; //echo "$query<br><br>"; // TEST $result = mysql_db_query($dbname, $query, $link); $n = 1; while($data = mysql_fetch_array($result)) { // check to see if there is an image to display if($data[numimages]) { $query = "SELECT thumb FROM $dbimg WHERE ccode='$data[ccode]' ORDER BY id DESC LIMIT 1"; $image = mysql_db_query($dbname, $query, $link); $image = mysql_fetch_array($image); $thumb = "<img src='thumbs/$image[thumb]' border=0>"; } else { $thumb = "<img src='common/nophoto.gif' border=0>"; } if(!($n % 2)) { $bg = "class='fill_light'"; } else { $bg = ''; } echo " <td align='center' height=60><a class='link' href='scheda.php?ccode=$data[ccode]$linkstring' target='_blank'>$thumb</a><br> <a class='link' href='scheda.php?ccode=$data[ccode]$linkstring' target='_blank'><b><font size=2>$data[make]</font><br>$data[stereo]<br>$data[model]</b></a></td> <tr> <td height=1><!-- LINE --></td></tr>   "; $n++; } mysql_close($link); } else { echo "<tr><td class='text' height=100 colspan=6 align='center' valign='middle'> <font class='hint'>Sorry no result.</font><br> </td></tr>"; } ?>Se puoi mi faresti un piacere almeno cerco di capire dove cavolo sbaglio.
Grazie ancora di tutto -
-
-
-
-
Calma, calma! prova in questo modo:
//... <tr class='fill'><td height=1 colspan=10><!-- LINE --></td></tr> <table width='100%' border=0 cellpadding=0 cellspacing=0> <? // display results if($numitems > 0) { $link = mysql_connect($dbhost, $dbuser, $dbpass); $query .= " ORDER BY updated DESC LIMIT $startitem, $perpage"; //echo "$query<br><br>"; // TEST $result = mysql_db_query($dbname, $query, $link); $n = 1; $riga = 1; $out = ""; while($data = mysql_fetch_array($result)) { // check to see if there is an image to display if($data[numimages]) { $query = "SELECT thumb FROM $dbimg WHERE ccode='$data[ccode]' ORDER BY id DESC LIMIT 1"; $image = mysql_db_query($dbname, $query, $link); $image = mysql_fetch_array($image); $thumb = "<img src='thumbs/$image[thumb]' border=0>"; } else { $thumb = "<img src='common/nophoto.gif' border=0>"; } if(!($n % 2)) $bg = "class='fill_light'"; else $bg = ''; if($riga == 1) $out .= "<tr>"; if($riga >= 1) { $out .= "<td align='center' height=60> <a class='link' href='scheda.php?ccode=$data[ccode]$linkstring' target='_blank'>$thumb</a><br> <a class='link' href='scheda.php?ccode=$data[ccode]$linkstring' target='_blank'><b><font size=2>$data[make]</font><br> $data[stereo]<br>$data[model]</b></a></td>"; $riga++; } if($riga == 3) { $out .= "</tr>"; $riga = 1; } $n++; } mysql_close($link); echo $out; } else { echo "<tr><td class='text' height=100 colspan=6 align='center' valign='middle'> <font class='hint'>Sorry no result.</font><br></td></tr>"; } ?> </table> </table>Ciao!
-
Grande Sups!!!
Allora succede questo con il tuo codice:
Mi sballa tutto il layout ma lì è un discorso di tag di tabelle da aggiustare, poca roba... però finalmente mette più di un risultato per riga, 2 non 3 purtroppo.. però è già un passo vanti
Grazie! -
-
Sups
Per la tabulazione, prova a togliere la tabella che ho creato, all'inizio del codice che ho postato, mentre per le colonne metti questo:
if($riga == 4) oppure if($riga >3) al posto di if($riga == 3)
Ciao!
Ho messo if($riga == 4) e funziona
!
Adesso sistemo le tabelle...
Grazie ancora!
-
-
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