hallo23>> prøv den her istedet.
<?
$offset = IntVal($offset);
$DBHOST = \"localhost\";
$DBUSER = \"\"; //Username
$DBPASS = \"\"; //password
$DB = \"\"; //Database
$tabella = \"\"; //table
$PAGESIZE=\"5\"; //number of records per page
$bg = \"gray\";
$bg1 = \"teal\";
$ColTab = \"#008000\";
$ColTabs = \"#008000\";
$site_logo = \"
http://www.snark.it/images/topics/occhisnark.gif\";$title = \"<font size=6>La più grande collezione di ricette d\'Italia</font><br><font size=4>In collaborazione con <a href=\\\"
http://www.snark.it\\\" target=\\\"_new\\\"><img src=\\\"
http://www.snark.it/images/topics/occhisnark.gif\\\" border=0 width=25 align=\\\"center\\\" height=25 alt=\\\"Gli amici di
www.snark.it\\\"></a></font>\";$CercaNelDb = \"Cerca le ricette\";
$ProssimiRisultati = \"prossime $PAGESIZE ricette --->\";
$RisultatiPrecedenti = \"<--- $PAGESIZE ricette precedenti\";
$thisrec = \"Questo record è tratto da: \";
error_reporting(256);
function NotAvailable($what = \"application\", $reason = \"\")
{
echo \"<HTML><HEAD><TITLE>Not available</TITLE></HEAD>
<BODY><H1>Si è verificato un problema!\"; echo $what; echo \"non è utilizzabile!!</H1>\";
if ($reason):
echo \"<P>Motivo: <TT>$reason</TT></P>\";
endif;
echo \"</BODY></HTML>\";
}
$CampiRisultati = array(
\"ID\",
\"nome\",
\"tipo\",
\"ingrprinc\",
\"persone\",
\"note\",
\"ingredienti\",
\"preparazione\"
);
// $EtichetteRisultati contains the labels for the genrated table: Be shure to have the same number of elements in $CampiRisultati and in $EtichetteRisultati
$EtichetteRisultati = array(
\"Numero Ricetta\",
\"Nome\",
\"Tipo\",
\"Ingrediente Principale\",
\"Persone\",
\"Note\",
\"Ingredienti\",
\"Preparazione\"
);
// $CampiRicerca Contains the fields you want to use for the search;
$CampiRicerca = array(
\"id\",
\"nome\",
\"tipo\",
\"ingrprinc\",
\"persone\",
\"note\",
\"ingredienti\",
\"preparazione\"
);
// $EtichetteRicerca contains the labels for the search form
$EtichetteRicerca = array(
\"Numero Ricetta\",
\"Nome\",
\"Tipo\",
\"Ingrediente Principale\",
\"Persone\",
\"Note\",
\"Ingredienti\",
\"Preparazione\"
);
if (!$stampa)
{
include(\"header.php\"); //THE HEADER FILE
echo \"<center>\\n<table border=0 cellpadding=1 cellspacing=0 width=100% bgcolor=000000><tr>\\n<td>\\n
<table border=0 cellpadding=8 cellspacing=0 width=100% bgcolor=FFFFFF>\\n<tr>\\n
<td align=left><font face=Arial,Helvetica size=3>\";
if (!mysql_connect($DBHOST, $DBUSER, $DBPASS)):
NotAvailable();
exit;
endif;
if (!mysql_select_db($DB)):
NotAvailable($DB, mysql_error());
exit;
endif;
if (!$cerca && !$segue):
$PAGESIZE=5;
echo\"<center> <font size=\\\"+2\\\">$title</font></center>\\n<p>\\n<form method=\\\"POST\\\" action=\\\"$PHP_SELF\\\">\\n
<table bordercolor=\\\"$ColTab\\\" bordercolorlight=\\\"$ColTab\\\" bordercolordark=\\\"$ColTab\\\" cellspacing=\\\"0\\\" cellpadding=\\\"4\\\" border=\\\"1\\\" width=\\\"400\\\">\";
for ($i = 0; $i <= count($CampiRicerca)-1; $i++)
{
echo \"<tr>\\n<td width =\\\"160\\\"><b>$EtichetteRicerca[$i]</B></TD>\\n
<td>
<select size=\\\"1\\\" name=\\\"exa[$i]\\\">
<option value=\\\"0\\\">simile a</option>
<option value=\\\"1\\\">uguale a</option>
</select>
</TD><td><input type=\\\"text\\\" name=nome[$i] size=\\\"30\\\"></TD><td>
<select size=\\\"1\\\" name=\\\"sn[$i]\\\">
<option value=\\\"1\\\">E</option>
<option value=\\\"0\\\">O</option>
</select></TD>\\n</tr>\\n\";
}
echo\"\\n</table>\\n <p>\\n
</p>\\n ordina per: <select size=\\\"1\\\" name=\\\"OrdinaPer\\\">\";
for ($x = 0; $x <= count($CampiRicerca)-1; $x++) {
echo \"<Option value=\\\"\".$CampiRicerca[$x].\"\\\">\".$EtichetteRicerca[$x].\"</Option>\";
}
echo \"</select>\\n<p>Numero di risultati per pagina
<input type=\\\"text\\\" name=\\\"PAGESIZE\\\" size=\\\"2\\\" value=\\\"5\\\"><p>
<input type=\\\"submit\\\" value=\\\"$CercaNelDb\\\" name=\\\"cerca\\\">\\n</form>\\n\";
/* Se viene fatta la ricerca si esegue questo pezzo di pagina!*/
else: //continua if (!$cerca && !$segue):
if($segue)
{
$SQL1=stripslashes($SQL1);
$SQL=$SQL1.\"ASC LIMIT $offset,$PAGESIZE\";
}
else {
for ($i = 0; $i <= count($CampiRisultati)-1; $i++)
{
$valo=$CampiRisultati[$i];
if ($nome[$i])
{
//$we.=\"$valo like \'%$nome[$i]%\' AND \";
$we.=\"$valo \";
if ($exa[$i])
{
$we.=\" = \'$nome[$i]\'\";
}
else
{
$we.=\" like \'%$nome[$i]%\'\";
}
if ($sn[$i])
{
$we.=\" AND \";
}
else
{
$we.=\" OR \";
}
}
}
if ((strpos(\"OR\",strrev($we))) < strrev(strpos(\"AND\",strrev($we))))
{
$elim=3;
}
else
{
$elim=4;
}
$whe = substr ($we,0,strlen($we)-$elim); //mi creo la condizione where
$TOT=\"SELECT * FROM $tabella WHERE $whe\";
$resulta = mysql_query($TOT);
$TOT=mysql_num_rows($resulta);
$SQL1=\"SELECT * FROM $tabella WHERE $whe ORDER BY $OrdinaPer \";
$SQL=$SQL1.\"ASC LIMIT $offset,$PAGESIZE\";
//echo $SQL1;
}//fine if di segue
$resulta = mysql_query($SQL);
if (!$resulta):
echo \"<center> <font size=+2>$title</font><p>
<h2>La query che hai fatto contiene degli errori!</h2>
</center><br>Per esempio potresti non aver compilato alcun campo<br>
Questa è l\'sitruzione sql: $SQL\";
exit;
endif;
if ($TOT>0)
{ //controllo che non restituisca zero record
echo \"<center> <font size=+2>$title</font>\\n<p>\\n <hr color=\\\"#0000FF\\\" width=30%>
<font size=+2>Record \".($offset+1).\" - \".($offset + $PAGESIZE).\" (di $TOT)</font>
<hr color=\\\"#0000FF\\\" width=30%></CENTER>\";
while ($row = mysql_fetch_array($resulta)):
$idi++;
echo\"<form method=\\\"POST\\\" action=\\\"$PHP_SELF\\\">
<center>
<table bordercolor=$ColTabs bordercolorlight=$ColTabs bordercolordark=$ColTabs cellspacing=\\\"0\\\" cellpadding=\\\"2\\\" border=\\\"1\\\" width=\\\"500\\\">\";
for ($i = 0; $i <= count($CampiRisultati)-1; $i++)
{
$val=$row[$CampiRisultati[$i]];
if ($val)
{
echo \"<tr><td width =\\\"170\\\"><b>$EtichetteRisultati[$i]</B></TD>
<td>\".nl2br($val).\"<input type=\\\"hidden\\\" name=\\\"stmp[$i]\\\" value=\\\"\".$val.\"\\\">
</TD></tr>\\n\";}}
echo\" <tr><td colspan =\\\"2\\\" bgcolor=\\\"teal\\\"><center>
<input type=submit value=\\\"Stampa questo record\\\" name=\\\"stampa\\\"></TD>
</table> <center><hr color=\\\"#0000FF\\\" width=30%></CENTER>
</form>\";
endwhile;
}
else
{
echo \"<center> <font size=+2>$title</font><p><h2>La query che hai fatto ha restituito zero elementi!</h2>
<br>(questa è l\'istruzione SQL: $SQL)!!</center>\";
}
endif; //fine controllo zero record
$offsetmin = $offset;
echo \" <table border=\\\"0\\\" width=\\\"100%\\\"> <tr> <td width=\\\"50%\\\">\";
if ($offsetmin >= $PAGESIZE):
$offsetmin -= $PAGESIZE;
echo\" <form method=\\\"POST\\\" action=\\\"$PHP_SELF\\\">
<input type=\\\"hidden\\\" value=\\\"$offset\\\" name=\\\"offset\\\">
<input type=\\\"hidden\\\" value=\\\"$PAGESIZE\\\" name=\\\"PAGESIZE\\\">
<input type=\\\"hidden\\\" value=\\\"$SQL1\\\" name=\\\"SQL1\\\">
<input type=\\\"hidden\\\" value=\\\"$offsetmin\\\" name=\\\"offset\\\">
<input type=\\\"hidden\\\" value=\\\"$TOT\\\" name=\\\"TOT\\\">
<input type=\\\"submit\\\" value=\\\"$RisultatiPrecedenti\\\" name=\\\"segue\\\">
</FORM>\";
endif;
echo \"</td><td width=\\\"50%\\\" ALIGN=\\\"RIGHT\\\" > \";
if ($offset+$PAGESIZE < $TOT):
$offset += $PAGESIZE;
echo\" <form method=\\\"POST\\\" action=\\\"$PHP_SELF\\\">
<input type=\\\"hidden\\\" value=\\\"$offset\\\" name=\\\"offset\\\">
<input type=\\\"hidden\\\" value=\\\"$SQL1\\\" name=\\\"SQL1\\\">
<input type=\\\"hidden\\\" value=\\\"$PAGESIZE\\\" name=\\\"PAGESIZE\\\">
<input type=\\\"hidden\\\" value=\\\"$offset\\\" name=\\\"offset\\\">
<input type=\\\"hidden\\\" value=\\\"$TOT\\\" name=\\\"TOT\\\">
<input type=\\\"submit\\\" value=\\\"$ProssimiRisultati\\\" name=\\\"segue\\\">
</FORM>\";
endif;//fine offset+tot
echo\"<font size=-2>Questo database è stato realizzato con il contributo degli amici di <a href=\\\"
http://www.snark.it/\\\" target=\\\"_new\\\">
www.snark.it</a>, che ringraziamo per la cortesia e per il lavoro svolto!
</font></td> </tr> </tablE>\";
echo \"</td></tr></table>
</td></tr></table>
</center>\";
include(\"footer.php\"); //INCLUDE THE FOOTER FILE
mysql_free_result($resulta);
}
else
{
echo\"
<html>
<head><title>$title</title></head>
<body bgcolor=\\\"#FFFFFF\\\" text=\\\"#000000\\\">
<table border=0><tr><td>
<table border=0 width=640 cellpadding=0 cellspacing=1 bgcolor=\\\"#000000\\\"><tr><td>
<table border=0 width=640 cellpadding=20 cellspacing=1 bgcolor=\\\"#FFFFFF\\\"><tr><td>
<center>
<img src=\\\"$site_logo\\\" border=0 alt=\\\"\\\"><br><br>
<font face=\\\"verdana,arial\\\" size=\\\"+2\\\">
<b>$title</b><br>
<font size=1><br><br>
</center><font size=2>
<center>
<table cellspacing=\\\"2\\\" cellpadding=\\\"4\\\" border=\\\"0\\\" width=\\\"640\\\">\";
for ($i = 0; $i <= count($CampiRisultati)-1; $i++)
{
if ($stmp[$i]):
echo \"<tr><td width =\\\"170\\\"><b>$EtichetteRisultati[$i]</B></TD>
<td>\".stripslashes(nl2br($stmp[$i])).\"</TD>
</tr>\\n\";
endif;
}
echo\"</table> </CENTER>
</td></tr></table>
</td></tr></table>
<br><br>
<center>
<font face=\\\"verdana,arial\\\" size=2>
$thisrec $title<br>
</td></tr></table>
</body>
</html>\";
}
?>