Jump to content

[SOLVED] need some guidance on how to code a customizable table


cluce

Recommended Posts

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.

 

 

 

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

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";

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.