hance2105 Posted July 10, 2013 Share Posted July 10, 2013 hello guys i have created the below codes. the first one is the mysql select statement which works fine when i echo. the second one is an html/css table i created. i am stuck to the point where i can merge both of them so that i get a nice display and the total price of the products are calculated in each column. the first code selects product name, retailer name and product price from 5 tables. using the echo codes i can display the records in columns. code for mysql select statement <?php session_start(); include('db_connect.php'); $username = $_SESSION['username']; $user = mysql_fetch_assoc(mysql_query("select user_id from tbllogin where username = '{$username}'")); $query = mysql_query("SELECT * FROM tblfav_ret a, tblretailer b, tblretprod c, tblproduct d, tblfavourites eWHERE a.ret_id = b.ret_idAND b.user_id = c.user_idAND c.prod_id = d.prod_idAND d.prod_id = e.prod_idAND a.user_id = '{$user['user_id']}'"); $num = mysql_num_rows($query); if($num>0){ echo "<center><table bgcolor='grey' width='80%' border=0>"; echo "<tr bgcolor='#CCCCCC'>";echo "<td><b><center>Name</td>";echo "<td><b><center>Retailer</td>";echo "<td><b><center>Price</td>";echo "</tr>"; while($row = mysql_fetch_assoc($query)){ extract($row); echo "<tr>"; echo "<td style='text-align: center;'>".$row['prod_name']."</td>"; echo "<td style='text-align: center;'>".$row['ret_name']."</td>";echo "<td style='text-align: center;'>".$row['prod_price']."</td>";echo "</tr>"; }echo "</table>";} ?> i further created this html/css table which displays smthng like this product name <retailer_name> <retailer_name> <retailer_name> <retailer_name> prod_1 price1 price2 price3 price4 prod_2 price1 price2 price3 price4 total <total_price> <total_price> <total_price> <total_price> <html> <body> <div id="myfavourites"> <table class="fav_tbl"> <thead> <tr> <th scope="col">Product</th> <th scope="col">Retailer 1</th> <th scope="col">Retailer 2</th> <th scope="col">Retailer 3</th> <th scope="col">Retailer 4</th> </tr> </thead> <tfoot> <tr> <th scope="row">Total per month</th> <td>Total 1</td> <td>Total 2</td> <td>Total 3</td> <td>Total 4</td> </tr> </tfoot> </table> </div> </body> </html> the help i need is to make the display in the html/css table and calculation of total price of products listed Link to comment https://forums.phpfreaks.com/topic/280032-displaying-mysql-select-records-in-html-css-table/ Share on other sites More sharing options...
hance2105 Posted July 27, 2013 Author Share Posted July 27, 2013 i sorted it out Link to comment https://forums.phpfreaks.com/topic/280032-displaying-mysql-select-records-in-html-css-table/#findComment-1442428 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.