Buongiorno a tutti, cerco di spiegare nel miglior modo possibile qual'è il mio problema. In una pagina index avrei necessità che all'apertura lo script controlli nel db i campi con la data del giorno in corso e li visualizzi, come fossero gli impegni del giorno diciamo. Ho fatto centinaia di tentativi ma non c'è verso, il massimo che riesco a visualizzare è una tabella con le celle vuote. Incollo qui il codice della pagina "incriminata" e di seguito il contenuto del file sql con cui ho generato la tabella. Spero qualcuno mi possa aiutare, sto fondendo. Ringrazio anticipatamente tutti quelli che vorranno rispondere e mi scuso per il fastidio.
Contenuto del file sql
-- --------------------------------------------------------
--
-- Struttura della tabella `noleggio`
--
CREATE TABLE noleggio (
id int(11) NOT NULL auto_increment,
nome varchar(128) NOT NULL default '',
cognome varchar(128) NOT NULL default '',
email varchar(128) NOT NULL default '',
luogo varchar(128) NOT NULL default '',
extra text NOT NULL,
note text NOT NULL,
telefono varchar(128) NOT NULL default '',
data date NOT NULL default '0000-00-00',
oranoleggio varchar(128) NOT NULL default '',
auto1 tinyint(4) NOT NULL default '0',
auto2 tinyint(4) NOT NULL default '0',
auto3 tinyint(4) NOT NULL default '0',
auto4 tinyint(4) NOT NULL default '0',
auto5 tinyint(4) NOT NULL default '0',
PRIMARY KEY (id));
Grazie ancora a tutti.
PHP:
<?php
// richiamo il file di configurazione
require 'config.php';
// richiamo lo script responsabile della connessione a MySQL
require 'connect.php';
// preparo la query
$query = "SELECT * FROM noleggio WHERE data = CURDATE()";
// invio la query
$result = mysql_query($query);
// controllo l'esito
if (!$result) {
die("Errore nella query $query: " . mysql_error());
}
$auto1_arr = array(' ','Si','No');
$auto2_arr = array(' ','Si','No');
$auto3_arr = array(' ','Si','No');
$auto4_arr = array(' ','Si','No');
$auto5_arr = array(' ','Si','No');
echo '
<table width="1024" border="1" align="center">
<tr>
<th>Nome</th>
<th>Cognome</th>
<th>Email</th>
<th>Telefono</th>
<th>Data</th>
<th>Ora</th>
<th>Luogo</th>
<th>Auto1</th>
<th>Auto2</th>
<th>Auto3</th>
<th>Auto4</th>
<th>Auto5</th>
<th>Extra</th>
<th>Note</th>
</tr>';
while ($row = mysql_fetch_assoc($result)) {
$nome = htmlentities($row['nome']);
$cognome = htmlentities($row['cognome']);
$email = htmlentities($row['email']);
$telefono = htmlentities($row['telefono']);
$data = htmlentities($row['data']);
$oranoleggio = htmlentities($row['oranoleggio']);
$luogo = htmlentities($row['luogo']);
$extra = htmlentities($row['extra']);
$note = htmlentities($row['note']);
$nome = nl2br($nome);
$cognome = nl2br($cognome);
$email = nl2br($email);
$luogo = nl2br($luogo);
$extra = nl2br($extra);
$note = nl2br($note);
if(!$nome) $nome = ' ';
if(!$cognome) $cognome = ' ';
if(!$email) $email = ' ';
if(!$luogo) $luogo = ' ';
if(!$extra) $extra = ' ';
if(!$note) $note = ' ';
$auto1 = $auto1_arr[$row['auto1']];
$auto2 = $auto2_arr[$row['auto2']];
$auto3 = $auto3_arr[$row['auto3']];
$auto4 = $auto4_arr[$row['auto4']];
$auto5 = $auto5_arr[$row['auto5']];
echo "<tr>
<td>$nome</td>
<td>$cognome</td>
<td>$email</td>
<td>$telefono</td>
<td>$data</td>
<td>$oranoleggio</td>
<td>$luogo</td>
<td>$auto1</td>
<td>$auto2</td>
<td>$auto3</td>
<td>$auto4</td>
<td>$auto5</td>
<td>$extra</td>
<td>$note</td>
</tr>";
}
echo '</table>';
// libero la memoria di PHP occupata dai record estratti con la SELECT
mysql_free_result($result);
// chiudo la connessione a MySQL
mysql_close();
?>
Contenuto del file sql
-- --------------------------------------------------------
--
-- Struttura della tabella `noleggio`
--
CREATE TABLE noleggio (
id int(11) NOT NULL auto_increment,
nome varchar(128) NOT NULL default '',
cognome varchar(128) NOT NULL default '',
email varchar(128) NOT NULL default '',
luogo varchar(128) NOT NULL default '',
extra text NOT NULL,
note text NOT NULL,
telefono varchar(128) NOT NULL default '',
data date NOT NULL default '0000-00-00',
oranoleggio varchar(128) NOT NULL default '',
auto1 tinyint(4) NOT NULL default '0',
auto2 tinyint(4) NOT NULL default '0',
auto3 tinyint(4) NOT NULL default '0',
auto4 tinyint(4) NOT NULL default '0',
auto5 tinyint(4) NOT NULL default '0',
PRIMARY KEY (id));
Grazie ancora a tutti.