cluce Posted September 7, 2007 Share Posted September 7, 2007 CAn someone give me some guidance on how to code a customizable table to display on a web page. I am trying to create a web page just like this. http://www.kraftpower.com/equipment/index.php I am have an intermmediate skill level and my coding style is procedural. I cant think abstract enough for object oriented. I know most of it is SQL queries and HTML and php. But I am unclear on how to get it to display the parts like they do only one web page. The way I am thinking of invloves multiple pages and probably redundant code. I dont need anyone two write the code. I just need some ideas from anybody on how to write a page like this. I dont think it will be to difficult. And if someone has an example of something similar to what I am trying to accomplish. I can probably fiigure it out. Quote Link to comment https://forums.phpfreaks.com/topic/68395-solved-need-some-guidance-on-how-to-code-a-customizable-table/ Share on other sites More sharing options...
psylovibe Posted September 7, 2007 Share Posted September 7, 2007 table start tag while($row = mysql_fetch_assoc($result)) new table row tag for(i = 0; i < mysql_num_fields($result)) new table data . $row['i'] . end table data (with out 'i' just i) end table row tag table end tag Quote Link to comment https://forums.phpfreaks.com/topic/68395-solved-need-some-guidance-on-how-to-code-a-customizable-table/#findComment-343866 Share on other sites More sharing options...
cluce Posted September 7, 2007 Author Share Posted September 7, 2007 thanks for the quick reply but I solved it. I just took out the table border tags from the loop. and added like this......... $display_block .= "</table>"; Quote Link to comment https://forums.phpfreaks.com/topic/68395-solved-need-some-guidance-on-how-to-code-a-customizable-table/#findComment-343873 Share on other sites More sharing options...
cluce Posted September 7, 2007 Author Share Posted September 7, 2007 well I have my table straight but can someone please give me some guidance on how to set it up like this company's web page. I know I need some hyperlinks to execute queries but how do they display the results all on one page??? http://www.kraftpower.com/equipment/index.php I would like to have all the functionality their table has. instead of just having a simple display like I currently have I think I am on the right track. here is my current code.. <?php //connect to database include'db.php'; //get all data from table $sql = "SELECT * from products"; $result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli)); $display_block = "<p align = 'center'> <table border = '1' bordercolor = 'black' cellpadding= '0' cellspacing = '0'> <th bgcolor = 'orange'>Item Number</th> <th bgcolor = 'orange'>Manufacturer</th> <th bgcolor = 'orange'>Category</th> <th bgcolor = 'orange'>Description</th> <th bgcolor = 'orange'>Model</th> <th bgcolor = 'orange'>Quantity</th> <th bgcolor = 'orange'>Kw</th> <th bgcolor = 'orange'>Hours</th> <th bgcolor = 'orange'>Price</th>"; //if authorized, get the values while ($info = mysqli_fetch_array($result)) { $ItemNo = stripslashes($info['Item_No']); $Man = stripslashes($info['Manufacturer']); $Cat = stripslashes($info['Category']); $Des = stripslashes($info['Description']); $Model = stripslashes($info['Model']); $Qty = stripslashes($info['Qty']); $Kw = stripslashes($info['Kw']); $Hours = stripslashes($info['Hours']); $Price = stripslashes($info['Price']); //create display string $display_block .= " <tr> <td>".$ItemNo."</td><td>".$Man."</td><td>".$Cat."</td><td>".$Des."</td><td>".$Model."</td><td>".$Qty."</td><td>".$Kw."</td><td>".$Hours."</td><td>".$Price."</td> </tr>"; } $display_block .= "</table></p>"; //displays string with data echo "$display_block"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/68395-solved-need-some-guidance-on-how-to-code-a-customizable-table/#findComment-343890 Share on other sites More sharing options...
cluce Posted September 7, 2007 Author Share Posted September 7, 2007 Well, does anyone at least know of a link with an example that I can work from in creating this type of functionality???? Quote Link to comment https://forums.phpfreaks.com/topic/68395-solved-need-some-guidance-on-how-to-code-a-customizable-table/#findComment-343910 Share on other sites More sharing options...
tippy_102 Posted September 7, 2007 Share Posted September 7, 2007 That site used JavaScript to sort the table. Most likely, something very similar to this: http://briancaufield.com/index.php?title=Best_Table_Sort_Ever Quote Link to comment https://forums.phpfreaks.com/topic/68395-solved-need-some-guidance-on-how-to-code-a-customizable-table/#findComment-343964 Share on other sites More sharing options...
cluce Posted September 7, 2007 Author Share Posted September 7, 2007 That site used JavaScript to sort the table. Most likely, something very similar to this: http://briancaufield.com/index.php?title=Best_Table_Sort_Ever thanks a million!! Quote Link to comment https://forums.phpfreaks.com/topic/68395-solved-need-some-guidance-on-how-to-code-a-customizable-table/#findComment-343981 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.