Oppure

Loading
19/05/10 22:59
samfisher88
Postato originariamente da antometal:

hai provato con:
...
for($n=0;$n<=$lim;$n++)
{
echo "<td>". $row[$n] . "</td>";
} 
...


funziona.. :D grazie mille!!! :k::k:
aaa
19/05/10 23:08
antometal
figurati :k:
aaa
22/07/10 13:18
chievovr
ciao ho letto questo post con interesse perchè sto realizzando una tabella HTML della Videoteca prendendo i dati da MySQL tramite PHP.
Ma sono in alto mare.

Mi potete aiutare? Vi do alcune info:
Tabella da 1500 record circa, 5-6 colonne
NUM TITOLO ANNO GENERE TRAMA (url) TRAILER (URL)
1 aaa 2010 avventura link link
2 bbb 2010 azione link link
999 ccc 2010 thriller link link

Dovrei stampare come sopra.

il mio php attuale che legge la tabella e realizza la query è:
[php]
<?php

require("config.php";);


$count_mess = @mysql_query("SELECT COUNT(NUM) FROM Videoteca";);

$res_count = @mysql_fetch_array($count_mess);

if ($res_count[0] == FALSE) {
echo "Nessun Titolo trovato nel database";
}
else
{
$tot_pages = ceil($res_count[0]/$msg_per_page);
$curr_page = (!$_GET['page']) ? 1 : (int)$_GET['page'];
$primo = ($curr_page - 1) * $msg_per_page;

$query = mysql_query("SELECT * FROM Videoteca ORDER BY TRANSLATEDTITLE LIMIT $primo,$msg_per_page";);

while($result = mysql_fetch_array($query)) {
echo " <strong>Titolo:</strong> " . $result['TRANSLATEDTITLE'] ;
echo " <strong>Anno:</strong> " . $result['YEAR'] ;
echo " <hr>\n";
} for($page = 1; $page <= $tot_pages; $page++) {

if($page == $curr_page) {

$pag .= "<strong>$page</strong> ";
}

else

{

$pag .= "<a href=\"?page=$page\">$page</a> ";
}

}

echo $pag . "<br>\n";
}

@mysql_close();
?>
[/php]

come notate c'è già la gestione della paginazione con numeri di pagina in basso. ogni pagina 20 record.

Ma ora non stampa come tabella ma come record.
Mi aiutate ad inserire il codice html dentro?

Grazie mille

Ultima modifica effettuata da chievovr 22/07/10 13:30
aaa
22/07/10 16:24
chievovr
Ciao ho trovato un'alternativa, ma perdo la paginazione.

<?php
define("DB_HOST", 'xxxxxxxxx'); 
define("DB", 'xxxxx');
define("DB_USER", 'xxxxxxx');
define("DB_PW", 'xxxxxx');

mysql_connect(DB_HOST, DB_USER, DB_PW);
mysql_select_db(DB);

$query="select * from Videoteca order by NUM";
$result= mysql_query($query);
$numfields = mysql_num_fields($result);

echo "<table>\n<tr>";
for ($i=0; $i < $numfields; $i++) 
  { 
   echo '<th>'.mysql_field_name($result, $i).'</th>'; 
   }
   echo "</tr>\n";
   
   while ($row = mysql_fetch_row($result)) 
  { 
   echo '<tr><td>'.implode($row,'</td><td>')."</td></tr>\n"; 
  }
echo "</table>\n";
  ?>
aaa