Codice PHP:
function do_search($word, $tabella, $tabellafoto, $tabellaprodori, $perpagina, $pagina = 1, $campo1, $campo2, $campo3, $dato1, $dato2, $dato3, $dato4, $dato5, $dato6, $dato7, $dato8)
{
/*$this->querysearch = "SELECT * FROM ".$tabella.", ".$tabellafoto.", ".$tabellaprodori."
WHERE (".$tabella.".".$dato3." LIKE '%".$word."%'
OR ".$tabella.".".$dato6." LIKE '%".$word."%'
OR ".$tabella.".".$dato6." = '".$word."'
OR ".$tabella.".".$dato3." = '".$word."')
AND ( SELECT MAX(id_foto) WHERE ".$tabella.".".$dato1." = ".$tabellafoto.".".$dato1.")
AND (".$tabellaprodori.".".$dato2." = ".$tabella.".".$dato2.")";*/
$this->querysearche = "SELECT * FROM ".$tabella." WHERE ".$tabella.".".$campo1." LIKE '%".$word."%' OR ".$tabella.".".$campo2." LIKE '%".$word."%' OR ".$tabella.".".$campo2." = '".$word."' OR ".$tabella.".".$campo1." = '".$word."'";
$this->numrisultati = mysql_num_rows(mysql_query($this->querysearche, $this->cdb));
if($this->numrisultati < 1)
{
print("<div>Nessun prodotto corrisponde al testo inserito.
Forse hai inserito un testo troppo lungo.</div>");
}
else
{
$this->numeropagine = ceil($this->numerorisultati / $perpagina);
if($this->numrisultati <= $perpagina)
{
$this->querysearcha = mysql_query($this->querysearch, $this->cdb);
while($this->datocerca = mysql_fetch_array($this->querysearcha))
{
print("
<table width=\"100%\"><tr><td width=\"95\"><a href=\"index.php?go=prodotto&prodotto=".$this->datocerca[$dato1]."\"><img style=\"border: 1px #000000 solid;\" height=\"90\" width=\"150\" src=\"".$this->datocerca[$dato7]."\" /></a></td>
<td>
<div style=\"text-align: left;height:15px; width:100%\">
<a style=\"text-align: left;height:15px\" href=\"index.php?go=prodotto&prodotto=".$this->datocerca[$dato1]."\" class=\"l1\">".$this->datocerca[$dato8]." ".$this->datocerca[$dato3]."</a>
</div>
<div style=\"text-align: left;height:60px; width:100%\">
<div>".substr($this->datocerca[$dato6], 0, 300)."...</div>
</div>
<div style=\"height:15px\">
<div style=\"text-align: right;\"><span style=\"font-weight: bold;color: #F96300;\">Disponibilità:</span> ".PROZKommerce::show_disponibilita($this->datocerca[$dato5])."</div>
</div>
</td>
</tr>
</table>
");
}
}
else
{
$this->maxpage = $pagina * $perpagina;
$this->minpage = $this->maxpage - $perpagina;
$this->querysearchb = "SELECT * FROM ".$tabella.", ".$tabellafoto.", ".$tabellaprodori."
WHERE (".$tabella.".".$dato3." LIKE '%".$word."%'
OR ".$tabella.".".$dato6." LIKE '%".$word."%'
OR ".$tabella.".".$dato6." = '".$word."'
OR ".$tabella.".".$dato3." = '".$word."')
AND (".$tabella.".".$dato1." = ".$tabellafoto.".".$dato1."
AND ".$tabellaprodori.".".$dato2." = ".$tabella.".".$dato2.") LIMIT ".$this->minpage.", ".$this->maxpage."";
$this->querysearchc = mysql_query($this->querysearchb, $this->cdb);
while($this->datocerca = mysql_fetch_array($this->querysearchc))
{
print("
<table width=\"100%\"><tr><td width=\"95\"><a href=\"index.php?go=prodotto&prodotto=".$this->datocerca[$dato1]."\"><img style=\"border: 1px #000000 solid;\" height=\"90\" width=\"150\" src=\"".$this->datocerca[$dato7]."\" /></a></td>
<td>
<div style=\"text-align: left;height:15px; width:100%\">
<a style=\"text-align: left;height:15px\" href=\"index.php?go=prodotto&prodotto=".$this->datocerca[$dato1]."\" class=\"l1\">".$this->datocerca[$dato8]." ".$this->datocerca[$dato3]."</a>
</div>
<div style=\"text-align: left;height:60px; width:100%\">
<div>".substr($this->datocerca[$dato6], 0, 300)."...</div>
</div>
<div style=\"height:15px\">
<div style=\"text-align: right;\"><span style=\"font-weight: bold;color: #F96300;\">Disponibilità:</span> ".PROZKommerce::show_disponibilita($this->datocerca[$dato5])."</div>
</div>
</td>
</tr>
</table>
");
}
}
}
}