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.
3rd part is where iam displaying the items. over all i am just running different query at bottom.
<div id = 'index_content_page_wrapper'>
/*** 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());
$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"<img src='http://localhost/E_COMMERCE/IMAGE/STORE_ITEMS_DB/$image_folder_name_db' width='150' height='150'/> <br/>";
echo"<p id='price'>Our Price $$price_db</p>";
if($count == 4) //3 cols
echo "</tr><tr>"; // Start a new row at 3 cols
$count = 0;
}//end of while loop
5 Months Ago
Related Article:Insert a new code in an existing php file?
is a PHP discussion thread by drelix01 that has 1 reply, was last updated 1 year ago and has been tagged with the keywords: insert, code, php, existing.
You need to learn ajax request,
html page sends request to server on any event with parameters,
there on server you must have some script to handle such request ,
the script will return you some output, that you can reflect on html page,
all this will not need to reload whole page, only part of page is updated.