so simple I can't figure it out!

Ok I know this is easy to do but I’m obviously making it harder than it is. So I have a page that returns the search results of a database and displays them in rows with alternating colors but my problem is I need a header above each column. I can get a header above each column I just can’t get it to line up above the correct column, here is the actual page, http://jemtechnv.com/portal/inventory/inventory_search.php so above each column I need the name of that column, so, ID Part Number Model Number Serial Number and so on, my issue is I can get the column names in there but they repeat with each new row and or they wont line up over the correct column.

Here is my php code:
[php]// Connect to server and select databse
mysql_connect("$host", “$username”, “$password”)or die(“cannot connect”);
mysql_select_db("$db_name")or die(“cannot select DB”);

$sql=“SELECT * FROM $tbl_name”;
$result=mysql_query($sql);

// Define $color=1
$color=“1”;

echo ‘

’;
while($rows=mysql_fetch_array($result)){

echo ‘

’;

// If $color==1 table row color = #FFC600
if($color==1){
echo "

";

// Set $color==2, for switching to other color
$color=“2”;
}

// When $color not equal 1, use this table row color
else {
echo "

";

// Set $color back to 1
$color=“1”;
}

}
echo ‘

ID Part Number Model Number Serial Number Manufacture Availability Quantity Condition Product Image
".$rows['id']." ".$rows['part_number']." ".$rows['model_number']." ".$rows['serial_number']." ".$rows['part_manufacture']." ".$rows['part_available']." ".$rows['part_quantity']." ".$rows['part_condition']." ".$rows['part_image']."
".$rows['id']." ".$rows['part_number']." ".$rows['model_number']." ".$rows['serial_number']." ".$rows['part_manufacture']." ".$rows['part_available']." ".$rows['part_quantity']." ".$rows['part_condition']." ".$rows['part_image']."
’;
mysql_close();
?>
[/php]

figured it out, didn’t notice I had my header inside my loop statement, moved it above it and now I have the one header above all my search results.

Sponsor our Newsletter | Privacy Policy | Terms of Service