Im doing my uni project and basically I have a load of info in a db I want to retrieve in the website using php although I dont want to display it with a table as I have done the whole site in CSS/XHTML so far.
From the examples I have been given I can see how you echo out the html for the tabel and then display your data into it but liek I say how would I go about displaying the data properly the way I want without doing it the table way.
Do I just need to define a heap of CSS tags to style the output?
Heres an example of what I used in the past.
From the examples I have been given I can see how you echo out the html for the tabel and then display your data into it but liek I say how would I go about displaying the data properly the way I want without doing it the table way.
Do I just need to define a heap of CSS tags to style the output?
Heres an example of what I used in the past.
Code:
<?php
include "db.inc";
$searchResults =$_POST["searchProducts"];
$connection = mysql_connect($hostname, $username, $password) or die ("Unable to connect!");
mysql_select_db($databaseName) or die ("Unable to select database!");
$query = "SELECT * FROM items WHERE item_title like '$searchResults'";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
echo "<table cellpadding=10 border=1 width=600px>";
echo "<tr><td><a href='results.php?order=item_id&letter=$initialLetter'>ID</a></td>";
echo "<td><a href='results.php?order=item_title&letter=$initialLetter'>Name</a></td>";
echo "<td><a href='results.php?order=item_date&letter=$initialLetter'>Date</a></td>";
echo "<td><a href='results.php?order=item_price&letter=$initialLetter'>Price</a></td></tr>";
while($row = mysql_fetch_assoc($result)) {
echo "<tr>";
echo "<td>".$row['item_id']."</td>";
echo "<td>".$row['item_title']."</td>";
echo "<td>".$row['item_date']."</td>";
echo "<td>".$row['item_price']."</td>";
echo "<td>","<img src=".$row['item_picture'].">","</td>";
echo "</tr>";
}
echo "</table>";
}
else {
// no
// print status message
echo "No rows found!";
}
?>