Ho risolto così:
Codice PHP:
<?phpecho("<link rel='stylesheet' type='text/css' href='table.css'>");
//Retreive information from form
$kind=$_POST["kind"]; $position=$_POST["position"]; $size=$_POST["size"]; $price=$_POST["price"]; $event=$_POST["event"]; $weather=$_POST["weather"]; $name=$_POST["name"]; $pur_date=$_POST["pur_date"]; $color=$_POST["color"]; $where="1=1"; if (!empty($kind)){ $campi="kind"." "; $valorekind=$kind; $where=$where." AND kind="."'".$kind."'"; } if (!empty($position)){ $campi=$campi."position"." "; $valoreposition=$position; $where=$where." AND position="."'".$position."'"; } if (!empty($size)){ $campi=$campi."size"." "; $valoresize=$size; $where=$where." AND size="."'".$size."'"; } if (!empty($price)){ $campi=$campi."price"." "; $valoreprice=$price; $where=$where." AND price="."'".$price."'"; } if (!empty($event)){ $campi=$campi."event"." "; $valoreevent=$event; $where=$where." AND event="."'".$event."'"; } if (!empty($weather)){ $campi=$campi."weather"." "; $valoreweather=$weather; $where=$where." AND weather="."'".$weather."'"; } if (!empty($name)){ $campi=$campi."name"." "; $valorename=$name; $where=$where." AND name="."'".$name."'"; } if (!empty($pur_date)){ $campi=$campi."pur_date"." "; $valorepur_date=$pur_date; $where=$where." AND pur_date="."'".$pur_date."'"." AND "; } if (!empty($color)){ $campi=$campi."color"." "; $valorecolor=$color; $where=$where." AND color="."'".$color."'"; } $query= "SELECT *FROM clothes WHERE ".$where ; //$query= "SELECT ".$campi."FROM clothes WHERE ".$where ;//echo($query);//Connection $link = mysql_connect('localhost', 'idnob', 'Zenemecca5689'); if (!$link) { die('Could not connect: ' . mysql_error()); } //Select DB mysql_select_db(my_idnob) or die ("Error in selection database ".mysql_error());$result=mysql_query($query) or die (mysql_error());echo("<table>");echo(" <tr> <td>Name</td> <td>Kind</td> <td>Position</td> <td>Size</td> <td>Price</td> <td>Event</td> <td>Weather</td> <td>Purchase Date</td> <td>Color</td> <td>Image</td></tr>");
//if (empty($result)){echo ("No clothes for the specified details.");}//else{while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['kind'] . "</td>"; echo "<td>" . $row['position'] . "</td>"; echo "<td>" . $row['size'] . "</td>"; echo "<td>" . $row['price'] . "</td>"; // or group by position echo "<td>" . $row['event'] . "</td>"; // or left bottom, center middle, right top echo "<td>" . $row['weather'] . "</td>"; echo "<td>" . $row['pur_date'] . "</td>"; echo "<td>" . $row['color'] . "</td>"; echo "<td><img src='upload/" . $row['image'] . "' height='70' width='70' alt='".$row['name']."'></td>"; echo "</tr>"; } echo "</table>"; echo "</div>";//}
?>