Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Variables
- $dbhost = "localhost";
- $dbuser = "root";
- $dbpass = "root";
- $dbname = "Clothes";
- $dberror1 = "Could not connect to database.";
- $dberror2 = "Could not select database.";
- $dberror3 = "Could not execute query.";
- $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ($dberror1);
- $select_db = mysql_select_db('Clothes') or die ($dberror2);
- echo "<table border='1'>
- <tr>
- <th>Brand</th>
- <th>Colour</th>
- <th>Fabric</th>
- <th>Pattern</th>
- <th>PurchaseDate</th>
- </tr>";
- $query = "SELECT b.Brand, c.Colour, f.Fabric, p.Pattern, d.Date
- FROM TSHIRTS AS t, Brands as b, Fabrics AS f, Patterns AS p,PurchaseDates as d, Colours as c
- WHERE b.ID=t.Brand
- AND c.ID=t.Colour
- AND p.ID=t.Pattern
- AND f.ID=t.Fabric
- AND d.ID=t.PurchaseDate
- ORDER BY PATTERN;";
- $fetch = mysql_query($query) or die($dberror3);
- while($row = mysql_fetch_assoc($fetch))
- {
- echo "<tr>";
- echo "<td>".$row['Brand']."</td>";
- echo "<td>".$row['Colour']."</td>";
- echo "<td>".$row['Fabric']."</td>";
- echo "<td>".$row['Pattern']."</td>";
- $date = new DateTime($row['PurchaseDate']);
- echo "<td>".$date->format('Y-m-d')."</td>";
- echo "<br>";
- echo "</tr>";
- }
- echo "</table>";
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement