my code works fine but i feel i my structure of this code is not good. can any one help me out? i puted all code in one page.
so i have a page. this page is made up by 3 parts.
1st part is the header. in header i am connecting to database.
2nd part is the form. in form i have a html select. where user can pick "price: heigh to low", "price: low to heigh".
3rd part is where i am display the items. each item has a price. so if user pick "price: heigh to low" than height price item will be at top and low item will be at bottom.
---------------
male.php
1st part is simple just one line.
<?php include("../../INCLUDE/header.php");?>
2nd part is just html form
<form action='male.php' method='POST'>
<label>Order by:</label>
<select name="order_by">
<option value="heigh_low">price: height to low</option>
<option value="low_heigh">Price: Low to Heigh</option>
</select>
<button type="submit" name="male_button">go</button>
</form>
3rd part is where iam displaying the items. over all i am just running different query at bottom.
<?php
echo"
<div id = 'index_content_page_wrapper'>
<br/> <br/>
<table>
<tr'>
";
/*** display images ***/
//$user_name_c = $_COOKIE['username'];
if(isset($_POST['male_button'])) //if user hit submit button
{
$order_by_p = $_POST['order_by'];
if($order_by_p == 'heigh_low')
{
$male_query = mysql_query("SELECT * FROM item WHERE sub_category='Male_T-Shirts' ORDER BY price DESC LIMIT 8") or die(mysql_error());
}
}
else
{
$male_query = mysql_query("SELECT * FROM item WHERE sub_category='Male_T-Shirts' LIMIT 8");
}
$count = 0;
while($row = mysql_fetch_assoc($male_query))
{
$image_user_name_db = $row['image_user_name'];
$image_user_name_db = ucwords($image_user_name_db); // upper case begining of every word
$image_folder_name_db = $row['image_folder_name'];
$price_db = $row['price'];
$price_db = number_format($price_db, 2); //2 decimal. ex (1.0, 1)= 1.00
echo"<td >";
echo"<img src='http://localhost/E_COMMERCE/IMAGE/STORE_ITEMS_DB/$image_folder_name_db' width='150' height='150'/> <br/>";
echo"<p id='name'>$image_user_name_db</p>";
echo"<p id='price'>Our Price $$price_db</p>";
echo "</td>";
$count++;
if($count == 4) //3 cols
{
echo "</tr><tr>"; // Start a new row at 3 cols
$count = 0;
}
}//end of while loop
echo"
</tr>
</table></div>
";