Jump to content

gongpex

Members
  • Posts

    360
  • Joined

  • Last visited

Everything posted by gongpex

  1. Hello everyone, Today I tried to upload my product using <input type="file" > and it shown like this (). This my code : Form code <form enctype="multipart/form-data" name="register" id="register" action="?pg=product-upload" method="post" class="content"><input type="file" class="inpt-fm" name="b_img" id="b_img"/></form> Destination Code $b_img = $_POST['b_img'];$path = $_FILES['b_img']['name'];copy($b_img,"../temp/$path"); Q : what's mistake on my code? please told me, Thanks
  2. Hello everyone, when user disable javascript of course javascript would be off. But please see this site : http://tympanus.net/Development/CircularContentCarousel/. if you disable javascript on your browser it cause image untidy (show all). Point : How to make so that when user disable javascript, it still can be show image though the slide can't working (please see : http://intershop.com and don't forget to disable javascript on your browser). please help me Thanks
  3. A : Actually I rather don't understand with for each loop , but after you explain to me, I become understand. (Thanks) A : I want to display 2 order / product on every page. I don't know from where I must start to put $i value, so that can be display data using for loop. In short , I don't know how to change for each loop (my old code on code 2) to for loop. That's my point.... Please help me Thanks
  4. Hello Today I had try create code to display data using this code : Code 1 : if($_SESSION['cart']&&!$_SESSION['m_user']) {$page = mysql_real_escape_string($_GET['page']);$total_pages = count($_SESSION['cart']);$limit = 2;if($page){ $start = ($page - 1) * $limit;}else{ $start = 0; } $max_page = $start + $limit; if ($page == 0){$page = 1;}$prev = $page - 1;$next = $page + 1; $lastpage = ceil($total_pages/$limit);$LastPagem1 = $lastpage - 1; $paginate = '';if($lastpage > 1){ $paginate .= "<div class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='?p=basket&page=$prev'>previous</a>"; }else{ $paginate.= "<span class='disabled'>previous</span>"; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='?p=basket&page=$counter'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='?p=basket&page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='?p=basket&page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='?p=basket&page=$lastpage'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='?p=basket&page=1'>1</a>"; $paginate.= "<a href='?p=basket&page=2'>2</a>"; $paginate.= "..."; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='?p=basket&page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='?p=basket&page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='?p=basket&page=$lastpage'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a href='?p=basket&page=1'>1</a>"; $paginate.= "<a href='?p=basket&page=2'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='?p=basket&page=$counter'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a href='?p=basket&page=$next'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</div>"; }// paginationecho $paginate; Code 2 : $total_order = count($_SESSION['cart']); echo"<div class=\"b_title\"> <div align=\"center\"><b>Your total order on basket : <font color=\"#000066\">$total_order</font></b></div> </div>"; foreach($_SESSION['cart'] as $product_id => $quantity) { //get the name, description and price from the database - this will depend on your database implementation. //use sprintf to make sure that $product_id is inserted into the query as a number - to prevent SQL injection $sql = sprintf("SELECT p_id, p_title, p_price, p_image FROM product WHERE p_id = %d;", $product_id); $result = mysql_query($sql); //Only display the row if there is a product (though there should always be as we have already checked) if(mysql_num_rows($result) > 0) { list($p_id, $p_title, $p_price, $p_image) = mysql_fetch_row($result); $line_cost = $p_price * $quantity; //work out the line cost $total = $total + $line_cost; //add to the total cost $product = array(); $product[0] = $p_id; $product[1] = $p_title; $product[2] = $p_price; $product[3] = $p_image; for($i=$start;$i<$max_page;$i++){ echo" <div class=\"b_content\"> <form method=\"post\" action=\"?p=basket&action=change&id=".$product[0][$i]."\"> <div class=\"b_img\"><img src=\"product/".$product[3][$i]."\" width=\"105px\" height=\"152px\" border=\"1\"/></div> <div class=\"b_detail\"> <div class=\"b_columnL\">Book Name : </div> <div class=\"b_columnR\"><b>".$product[1][$i]."</b></div> <div class=\"b_columnL\">Price Per Book : </div> <div class=\"b_columnR\">".$product[2][$i]."</div> <div class=\"b_columnL\">Total Item : </div> <div class=\"b_columnR\"><input type=\"text\" name=\"qty\" style=\"width:20px;text-align:center;border:1px solid #000066;\" maxlength=\"3\" value=\"$quantity\" /></div> <div class=\"b_columnL\">Total Price : </div> <div class=\"b_columnR\">USD $line_cost</div> <div class=\"b_columnL\"><a href=\"basket.php?action=remove&id=$p_id\">Delete</a></div> <div class=\"b_columnR\"><input type=\"submit\" value=\"RECALCULATE\" /></div> </div> </form> </div>"; } } } //show the total $checkout ="<div align=\"left\" style=\"float:left\"><a href=\"?p=basket\">Back to shop</a></div><div align=\"right\" style=\"float:right\"><a href=\"?p=pass\">Checkout</a></div>"; echo "<div class=\"checkout\" style=\"float:left;padding-left:24px;\"><a href=\"basket.php?action=empty\">Empty Order</a></div> <div class=\"checkout\">Total that must be pay : USD <b>$total</b> <hr size=\"1\" color=\"#000000\" />$checkout</div>";}else if(!$_SESSION['m_user']){echo "<div class=\"b_title\" style=\"color:#000099\"><b>You have no item in your basket cart</b></div>";} Code on above result : Information : Code 1 : to display pagination link number.Code 2 : to display data this my code before modify : $total_order = count($_SESSION['cart']); echo"<div class=\"b_title\"> <div align=\"center\"><b>Your total order on basket : <font color=\"#000066\">$total_order</font></b></div> </div>"; foreach($_SESSION['cart'] as $product_id => $quantity) { //get the name, description and price from the database - this will depend on your database implementation. //use sprintf to make sure that $product_id is inserted into the query as a number - to prevent SQL injection $sql = sprintf("SELECT p_id, p_title, p_price, p_image FROM product WHERE p_id = %d;", $product_id); $result = mysql_query($sql); //Only display the row if there is a product (though there should always be as we have already checked) if(mysql_num_rows($result) > 0) { list($p_id, $p_title, $p_price, $p_image) = mysql_fetch_row($result); $line_cost = $p_price * $quantity; //work out the line cost $total = $total + $line_cost; //add to the total cost echo" <div class=\"b_content\"> <form method=\"post\" action=\"?p=basket&action=change&id=$p_id\"> <div class=\"b_img\"><img src=\"product/$p_image\" width=\"105px\" height=\"152px\" border=\"1\"/></div> <div class=\"b_detail\"> <div class=\"b_columnL\">Book Name : </div> <div class=\"b_columnR\"><b>$p_title</b></div> <div class=\"b_columnL\">Price Per Book : </div> <div class=\"b_columnR\">$p_price</div> <div class=\"b_columnL\">Total Item : </div> <div class=\"b_columnR\"><input type=\"text\" name=\"qty\" style=\"width:20px;text-align:center;border:1px solid #000066;\" maxlength=\"3\" value=\"$quantity\" /></div> <div class=\"b_columnL\">Total Price : </div> <div class=\"b_columnR\">USD $line_cost</div> <div class=\"b_columnL\"><a href=\"basket.php?action=remove&id=$p_id\">Delete</a></div> <div class=\"b_columnR\"><input type=\"submit\" value=\"RECALCULATE\" /></div> </div> </form> </div>"; } } } //show the total $checkout ="<div align=\"left\" style=\"float:left\"><a href=\"?p=basket\">Back to shop</a></div><div align=\"right\" style=\"float:right\"><a href=\"?p=pass\">Checkout</a></div>"; echo "<div class=\"checkout\" style=\"float:left;padding-left:24px;\"><a href=\"basket.php?action=empty\">Empty Order</a></div> <div class=\"checkout\">Total that must be pay : USD <b>$total</b> <hr size=\"1\" color=\"#000000\" />$checkout</div>";}else if(!$_SESSION['m_user']){echo "<div class=\"b_title\" style=\"color:#000099\"><b>You have no item in your basket cart</b></div>";} Note : code that was modified only code 2. my problem : Should I change foreach($_SESSION['cart'] as $product_id=>$quantity) become for($i=$start;$i<$max_page;$i++) or I must using both? Q : What I must do now? please help me Thanks
  5. Hi , Today I had try to combine code and this is the result : And these the code : Code 1 : <?$page = mysql_real_escape_string($_GET['page']);$total_pages = count($_SESSION['cart']);$limit = 2;if($page){ $start = ($page - 1) * $limit;}else{ $start = 0; } if ($page == 0){$page = 1;}$prev = $page - 1;$next = $page + 1; $lastpage = ceil($total_pages/$limit);$LastPagem1 = $lastpage - 1; $paginate = ''; Code 2 : if($lastpage > 1){ $paginate .= "<div class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='?p=basket&page=$prev'>previous</a>"; }else{ $paginate.= "<span class='disabled'>previous</span>"; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='?p=basket&page=$counter'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='?p=basket&page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='?p=basket&page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='?p=basket&page=$lastpage'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='?p=basket&page=1'>1</a>"; $paginate.= "<a href='?p=basket&page=2'>2</a>"; $paginate.= "..."; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='?p=basket&page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='?p=basket&page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='?p=basket&page=$lastpage'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a href='?p=basket&page=1'>1</a>"; $paginate.= "<a href='?p=basket&page=2'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='?p=basket&page=$counter'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a href='?p=basket&page=$next'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</div>"; }echo $total_pages.' Results';// paginationecho $paginate;?> Code 3 : if($_SESSION['cart']&&!$_SESSION['m_user']) { $total_order = count($_SESSION['cart']); echo"<div class=\"b_title\"> <div align=\"center\"><b>Your total order on basket : <font color=\"#000066\">$total_order</font></b></div> </div>"; foreach($_SESSION['cart'] as $product_id => $quantity) { //get the name, description and price from the database - this will depend on your database implementation. //use sprintf to make sure that $product_id is inserted into the query as a number - to prevent SQL injection $sql = sprintf("SELECT p_id, p_title, p_price, p_image FROM product WHERE p_id = %d;", $product_id); $result = mysql_query($sql); //Only display the row if there is a product (though there should always be as we have already checked) if(mysql_num_rows($result) > 0) { list($p_id, $p_title, $p_price, $p_image) = mysql_fetch_row($result); $line_cost = $p_price * $quantity; //work out the line cost $total = $total + $line_cost; //add to the total cost echo" <div class=\"b_content\"> <form method=\"post\" action=\"?p=basket&action=change&id=$product_id\"> <div class=\"b_img\"><img src=\"product/$p_image\" width=\"105px\" height=\"152px\" border=\"1\"/></div> <div class=\"b_detail\"> <div class=\"b_columnL\">Book Name : </div> <div class=\"b_columnR\"><b>$p_title</b></div> <div class=\"b_columnL\">Price Per Book : </div> <div class=\"b_columnR\">$p_price</div> <div class=\"b_columnL\">Total Item : </div> <div class=\"b_columnR\"><input type=\"text\" name=\"qty\" style=\"width:20px;text-align:center;border:1px solid #000066;\" maxlength=\"3\" value=\"$quantity\" /></div> <div class=\"b_columnL\">Total Price : </div> <div class=\"b_columnR\">USD $line_cost</div> <div class=\"b_columnL\"><a href=\"basket.php?action=remove&id=$product_id\">Delete</a></div> <div class=\"b_columnR\"><input type=\"submit\" value=\"RECALCULATE\" /></div> </div> </form> </div>"; } } //show the total $checkout ="<div align=\"left\" style=\"float:left\"><a href=\"?p=basket\">Back to shop</a></div><div align=\"right\" style=\"float:right\"><a href=\"?p=pass\">Checkout</a></div>"; echo "<div class=\"checkout\" style=\"float:left;padding-left:24px;\"><a href=\"basket.php?action=empty\">Empty Order</a></div> <div class=\"checkout\">Total that must be pay : USD <b>$total</b> <hr size=\"1\" color=\"#000000\" />$checkout</div>";}else if(!$_SESSION['m_user']){echo "<div class=\"b_title\" style=\"color:#000099\"><b>You have no item in your basket cart</b></div>";} Code 1 : contains data that I had calculated, (I try to figure out data using count, I'm not sure if this correct).Code 2 : code to display link numberCode 3 : code to display data from order session $ITEMS_PER_PAGE = 3; $page = $_GET['page']; //for our example. it is equal to 2$start = ($page - 1) * $ITEMS_PER_PAGE; //would be 3$end = $start + ($ITEMS_PER_PAGE - 1); //would be 5 for($i = $start; $i <= $end; $i++){ if($_SESSION['cart'][$i]){ //show this item on the page }} I don't understand with $ITEMS_PER_PAGE = 3; if on my case this is should be using count like this : $ITEMS_PER_PAGE = count($_SESSION['cart']); ??? I rather not understand, please give me example. please give some hint on my code. Thanks
  6. Before I continue my post I need to clarification : I think I had give you answer on post 3 , please see : My code that contains loop function , purpose to create link navigation (2) or more (based on total order). And this is my problem. So, I create for loop function is for to create pagination.______________________________________________________________________________________________________________________ Today I found tutorial about pagination from : http://papermashup.com/demos/php-pagination/ I try it's work but there is some part that become my problem : CODE I : <?phpinclude('connect.php');[font="helvetica, arial, sans-serif"]$tableName="p_order";$targetpage = "index.php";$limit = 2; $query = "SELECT COUNT(*) as num FROM $tableName";$total_pages = mysql_fetch_array(mysql_query($query));$total_pages = $total_pages[num]; $stages = 3;$page = mysql_real_escape_string($_GET['page']);if($page){ $start = ($page - 1) * $limit;}else{ $start = 0; } CODE II : // Get page data$query1 = "SELECT * FROM $tableName LIMIT $start, $limit";$result = mysql_query($query1); // Initial page num setupif ($page == 0){$page = 1;}$prev = $page - 1;$next = $page + 1; $lastpage = ceil($total_pages/$limit);$LastPagem1 = $lastpage - 1; $paginate = ''; CODE III : if($lastpage > 1){ $paginate .= "<div class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='$targetpage?page=$prev'>previous</a>"; }else{ $paginate.= "<span class='disabled'>previous</span>"; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a href='$targetpage?page=$next'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</div>"; }echo $total_pages.' Results';// paginationecho $paginate;?> CODE IV : <?php while($row = mysql_fetch_array($result)) { echo '<li>'.$row['o_title'].'</li>'; } ?> I understand the mean of this code, Code I : contains database that have data to display as total,Code II : contains database that have data to display on browser and it using limit (on sql taq) and $limit to control how many item to show per page,Code III : Code to display pagination number , like this picture : Code IV : code to display item / contents, like this image. Note : Code on above deliberately I divided,so that it's not painful to be read My problem is : All code and tutorial on above using database to make limit , of course it's using mysql_query("SELECT * FROM $tableName LIMIT $start, $limit"). How to make it ,so that if I using session the data from session can be displayed appropriate with limit that determined and can be combined with my session code on below? In short how to divide data from session My code to display session order is like this : if($_SESSION['cart']&&!$_SESSION['m_user']) { $total_order = count($_SESSION['cart']); echo"<div class=\"b_title\"> <div align=\"center\"><b>Your total order on basket : <font color=\"#000066\">$total_order</font></b></div> </div>"; foreach($_SESSION['cart'] as $product_id => $quantity) { //get the name, description and price from the database - this will depend on your database implementation. //use sprintf to make sure that $product_id is inserted into the query as a number - to prevent SQL injection $sql = sprintf("SELECT p_id, p_title, p_price, p_image FROM product WHERE p_id = %d;", $product_id); $result = mysql_query($sql); //Only display the row if there is a product (though there should always be as we have already checked) if(mysql_num_rows($result) > 0) { list($p_id, $p_title, $p_price, $p_image) = mysql_fetch_row($result); $line_cost = $p_price * $quantity; //work out the line cost $total = $total + $line_cost; //add to the total cost echo" <div class=\"b_content\"> <form method=\"post\" action=\"?p=basket&action=change&id=$product_id\"> <div class=\"b_img\"><img src=\"product/$p_image\" width=\"105px\" height=\"152px\" border=\"1\"/></div> <div class=\"b_detail\"> <div class=\"b_columnL\">Book Name : </div> <div class=\"b_columnR\"><b>$p_title</b></div> <div class=\"b_columnL\">Price Per Book : </div> <div class=\"b_columnR\">$p_price</div> <div class=\"b_columnL\">Total Item : </div> <div class=\"b_columnR\"><input type=\"text\" name=\"qty\" style=\"width:20px;text-align:center;border:1px solid #000066;\" maxlength=\"3\" value=\"$quantity\" /></div> <div class=\"b_columnL\">Total Price : </div> <div class=\"b_columnR\">USD $line_cost</div> <div class=\"b_columnL\"><a href=\"basket.php?action=remove&id=$product_id\">Delete</a></div> <div class=\"b_columnR\"><input type=\"submit\" value=\"RECALCULATE\" /></div> </div> </form> </div>"; } } //show the total $checkout ="<div align=\"left\" style=\"float:left\"><a href=\"?p=basket\">Back to shop</a></div><div align=\"right\" style=\"float:right\"><a href=\"?p=pass\">Checkout</a></div>"; echo "<div class=\"checkout\" style=\"float:left;padding-left:24px;\"><a href=\"basket.php?action=empty\">Empty Order</a></div> <div class=\"checkout\">Total that must be pay : USD <b>$total</b> <hr size=\"1\" color=\"#000000\" />$checkout</div>";}else if(!$_SESSION['m_user']){echo "<div class=\"b_title\" style=\"color:#000099\"><b>You have no item in your basket cart</b></div>";}else{include("application-basket.php");} please help me Thanks_______________________________________________________________________________________________ OFF : Is in your place covered by snow?
  7. I had try but it's not successful and this is the result : Image I : and the problem still same : Image 2 : And I don't know why this is occurred : Image 3 : This is my code : <?php$product_id = $_GET[id]; //the product id from the URL$action = $_GET[action]; //the action from the URL?><div class="title">BASKET ORDER</div><div class="pr_page" style="border-bottom:1px solid black;">Order Page </div> <div class="pr_number" style="border-bottom:1px solid black;float:left;width:472px"> <? $total_order = count($_SESSION['cart']); if(!$_SESSION['m_user']){ $op = 1; for($w=0;$w<$total_order;$w+=3){ if($total_order>3){ echo"<div class=\"cart_num\"><a href=\"?p=basket&o=$w&ot=$total_order\">$op</a></div>"; $op++; }else{ echo"<div class=\"cart_num\"><a href=\"?p=basket&o=0&ot=$total_order\">1</a></div>"; } } } $x=$o+3; if($o==""||$o==0||preg_match("/[a-z]/",$o)){ $o=0; } if($total_order<=3){ $y=$total_order; }else{ $y=$x; } ?> </div><?$qty = $_POST[qty];//if there is an product_id and that product_id doesn't exist display an error messageif($product_id && !productExists($product_id)) { die("Error. Product Doesn't Exist");}switch($action) { //decide what to do case "add": $_SESSION['cart'][$product_id]++; //add one to the quantity of the product with id $product_id break; case "remove": unset($_SESSION['cart'][$product_id]); break; case "empty": unset($_SESSION['cart']); //unset the whole cart, i.e. empty the cart. break; case "change": $_SESSION['cart'][$product_id]=+$qty; if(preg_match("/[.]/",$qty)){$_SESSION['cart'][$product_id]=+1;} if($_SESSION['cart'][$product_id] == 0){unset($_SESSION['cart'][$product_id]);} break; }if($_SESSION['cart']&&!$_SESSION['m_user']) { $total_order = count($_SESSION['cart']); echo"<div class=\"b_title\"> <div align=\"center\"><b>Your total order on basket : <font color=\"#000066\">$total_order</font></b></div> </div>"; foreach($_SESSION['cart'] as $product_id => $quantity) { //get the name, description and price from the database - this will depend on your database implementation. //use sprintf to make sure that $product_id is inserted into the query as a number - to prevent SQL injection $sql = sprintf("SELECT p_id, p_title, p_price, p_image FROM product WHERE p_id = %d;", $product_id); $result = mysql_query($sql); //Only display the row if there is a product (though there should always be as we have already checked) if(mysql_num_rows($result) > 0) { list($p_id, $p_title, $p_price, $p_image) = mysql_fetch_row($result); $line_cost = $p_price * $quantity; //work out the line cost $total = $total + $line_cost; //add to the total cost echo" <div class=\"b_content\"> <form method=\"post\" action=\"?p=basket&action=change&id=$product_id\"> <div class=\"b_img\"><img src=\"product/$p_image\" width=\"105px\" height=\"152px\" border=\"1\"/></div> <div class=\"b_detail\"> <div class=\"b_columnL\">Book Name : </div> <div class=\"b_columnR\"><b>$p_title</b></div> <div class=\"b_columnL\">Price Per Book : </div> <div class=\"b_columnR\">$p_price</div> <div class=\"b_columnL\">Total Item : </div> <div class=\"b_columnR\"><input type=\"text\" name=\"qty\" style=\"width:20px;text-align:center;border:1px solid #000066;\" maxlength=\"3\" value=\"$quantity\" /></div> <div class=\"b_columnL\">Total Price : </div> <div class=\"b_columnR\">USD $line_cost</div> <div class=\"b_columnL\"><a href=\"basket.php?action=remove&id=$product_id\">Delete</a></div> <div class=\"b_columnR\"><input type=\"submit\" value=\"RECALCULATE\" /></div> </div> </form> </div>"; } } //show the total $checkout ="<div align=\"left\" style=\"float:left\"><a href=\"?p=basket\">Back to shop</a></div><div align=\"right\" style=\"float:right\"><a href=\"?p=pass\">Checkout</a></div>"; echo "<div class=\"checkout\" style=\"float:left;padding-left:24px;\"><a href=\"basket.php?action=empty\">Empty Order</a></div> <div class=\"checkout\">Total that must be pay : USD <b>$total</b> <hr size=\"1\" color=\"#000000\" />$checkout</div>";}else if(!$_SESSION['m_user']){echo "<div class=\"b_title\" style=\"color:#000099\"><b>You have no item in your basket cart</b></div>";}else{include("application-basket.php");}//function to check if a product existsfunction productExists($product_id) { //use sprintf to make sure that $product_id is inserted into the query as a number - to prevent SQL injection $sql = sprintf("SELECT * FROM product WHERE p_id = %d;", $product_id); return mysql_num_rows(mysql_query($sql)) > 0;}?> Q : What's mistake on my code? Note : pagination tutorial that I found on google using database to display their data, I still didn't found if using SESSION. please help me Thanks
  8. I heard rumor if people hate or dislike IE because they hate or dislike with Microsoft Windows , is that true? If so, why they hate or dislike Microsoft Windows? but thanks for reply.
  9. Probably I need to attach images. This is image on normal on my temporary site (http://secondbook.onlinewebshop.net/), and this occurs if user buy product as much as 3 : Image 1 : and this is my problem / question : Image 2 : The next order displayed on same page (1), and this occurs if user buy product more than 3. Q : How to make it so that it shown like this : Image 3 My point / target is : create navigation link page, so that , if user buy product more than 3 , link 2 appear on Order Page (like image 3 on above). And the next product will be shown on page 2, and if user click link number 1 it's back to previous page (like image 1 on above) and page 2 not disappear and otherwise.In short, after page contains 3 product., the next link navigation appear (regularly). My code that contains loop function , purpose to create link navigation (2) or more (based on total order). And this is my problem. please help me Thanks
  10. so , in other word actually , people who using internet explorer , because they reluctant to install and using other browser? thanks.....
  11. Hello everyone, please visit my temporary site : http://secondbook.onlinewebshop.net/ please try to buy product more than 3 , at least 4 product. I don't know how to say it because I don't know the name, when you buy product it will shown number "1" on Order page column. But if you buy product more than 3 , the product still keep shown into bellow and page number not added on order page column. Q : How to make it , so that it will be shown "2" on Order page column and the product that ordered displayed at page 2 , if product that ordered are more than 3? Note : this is using session not using database to display it. Q : what the name of this number link? this is my code : this code to display the navigation number link. <?php$total_order = count($_SESSION['cart']);if(!$_SESSION['m_user']){$op = 1;for($w=0;$w<$total_order;$w+=3){if($total_order>3){ $num_link = "<div class=\"cart_num\"><a href=\"?p=basket&o=$w&ot=$total_order\">$op</a></div>";}else{ $num_link = "<div class=\"cart_num\"><a href=\"?p=basket&o=0&ot=$total_order\">1</a></div>";}}echo"<div class=\"pr_page\" style=\"border-bottom:1px solid black;\">Order Page </div> <div class=\"pr_number\" style=\"border-bottom:1px solid black;float:left;width:472px\"> $num_link </div>"; $op++;}?> this code to display order <?$qty = $_POST[qty];//if there is an product_id and that product_id doesn't exist display an error messageif($product_id && !productExists($product_id)) { die("Error. Product Doesn't Exist");}switch($action) { //decide what to do case "add": $_SESSION['cart'][$product_id]++; break; case "remove":unset($_SESSION['cart'][$product_id]); break; case "empty": unset($_SESSION['cart']); break; case "change": $_SESSION['cart'][$product_id]=+$qty; if(preg_match("/[.]/",$qty)){$_SESSION['cart'][$product_id]=+1;} if($_SESSION['cart'][$product_id] == 0){unset($_SESSION['cart'][$product_id]);} break; }if($_SESSION['cart']&&!$_SESSION['m_user']) { $total_order = count($_SESSION['cart']); echo"<div class=\"b_title\"> <div align=\"center\"><b>Your total order on basket : <font color=\"#000066\">$total_order</font></b></div> </div>"; foreach($_SESSION['cart'] as $product_id => $quantity) { $sql = sprintf("SELECT p_id, p_title, p_price, p_image FROM product WHERE p_id = %d;", $product_id); $result = mysql_query($sql); //Only display the row if there is a product (though there should always be as we have already checked) if(mysql_num_rows($result) > 0) { list($p_id, $p_title, $p_price, $p_image) = mysql_fetch_row($result); $line_cost = $p_price * $quantity; //work out the line cost $total = $total + $line_cost; //add to the total cost echo" <div class=\"b_content\"> <form method=\"post\" action=\"?p=basket&action=change&id=$product_id\"> <div class=\"b_img\"><img src=\"product/$p_image\" width=\"105px\" height=\"152px\" border=\"1\"/></div> <div class=\"b_detail\"> <div class=\"b_columnL\">Book Name : </div> <div class=\"b_columnR\"><b>$p_title</b></div> <div class=\"b_columnL\">Price Per Book : </div> <div class=\"b_columnR\">$p_price</div> <div class=\"b_columnL\">Total Item : </div> <div class=\"b_columnR\"><input type=\"text\" name=\"qty\" style=\"width:20px;text-align:center;border:1px solid #000066;\" maxlength=\"3\" value=\"$quantity\" /></div> <div class=\"b_columnL\">Total Price : </div> <div class=\"b_columnR\">USD $line_cost</div> <div class=\"b_columnL\"><a href=\"basket.php?action=remove&id=$product_id\">Delete</a></div> <div class=\"b_columnR\"><input type=\"submit\" value=\"RECALCULATE\" /></div> </div> </form> </div>"; } } $checkout ="<div align=\"left\" style=\"float:left\"><a href=\"?p=basket\">Back to shop</a></div><div align=\"right\" style=\"float:right\"><a href=\"?p=pass\">Checkout</a></div>"; echo "<div class=\"checkout\" style=\"float:left;padding-left:24px;\"><a href=\"basket.php?action=empty\">Empty Order</a></div> <div class=\"checkout\">Total that must be pay : USD <b>$total</b> <hr size=\"1\" color=\"#000000\" />$checkout</div>";}else if(!$_SESSION['m_user']){echo "<div class=\"b_title\"><b>You have no item in your basket cart</b></div>";}else{include("application-basket.php");}//function to check if a product existsfunction productExists($product_id) { //use sprintf to make sure that $product_id is inserted into the query as a number - to prevent SQL injection $sql = sprintf("SELECT * FROM product WHERE p_id = %d;", $product_id); return mysql_num_rows(mysql_query($sql)) > 0;}?> please help me Thanks
  12. Hello everyone, Why people dislike with internet explorer(IE) , but why IE still become as one of most popular browser? (whereas much people dislike with it) source : http://w3schools.com/browsers/default.asp please answer me Thanks
  13. Hello everyone, 10 minutes ago I tried to access this forum, but it shown like this : Fatal error: Class 'IPSDebug' not found in /home/w3school/public_html/admin/sources/base/ipsRegistry.php on line 489, Q : what happened on this forum? someone tell me , please thanks
  14. I think I need to check my code, yesterday I found some code that wrong.____________________________________________________________________________ off : your photo on avatar is in your home or other place like your office or etc? thanks
  15. Yes of course, but I don't know how to check it, if I using : mysql_query("select * from order where o_user='$m_user'and o_status='O' and p_id='$product code'"); note : $product code just an example. it can only check once, Q : how about product that ordered by user on account if the product more than 1? please help me Thanks
  16. Hello everyone, please see these images on bellow : When I click "BUY NOW", then I login into account it's successful to added to database. And this the result : But when I buy same or other product like this : it's result like this : it cause the product quantity and total price became 0 and sadly the new product cannot be added. and this my code : if($_SESSION['cart']) { $show_order = mysql_query("select * from order where o_user='$m_user'and o_status='O'"); $order_all = mysql_num_rows($show_order); foreach($_SESSION['cart'] as $product_id => $quantity) { $sql = sprintf("SELECT p_id, p_title, p_price, p_image FROM product WHERE p_id = %d;", $product_id); $result = mysql_query($sql); if(mysql_num_rows($result) > 0 && $order_all == 0 && $_SESSION['m_user']) { list($p_id, $p_title, $p_price, $p_img) = mysql_fetch_row($result); $line_cost = $p_price * $quantity; $total = $total + $line_cost; mysql_query("insert into order(pid,o_user,o_title,o_img,o_price,o_qty,o_total) values ('$p_id','$m_user','$p_title','$p_img','$p_price','$quantity','$line_cost')"); } else if(mysql_num_rows($result) > 0 && $order_all !== 0){ mysql_query("update order set o_qty ='$quantity',o_total='$line_cost' where o_user='$m_user' and o_status='O'"); } }} E : I know the cause of change the price and quantity into 0 and the new product can't be added because this code: if(mysql_num_rows($result) > 0 && $order_all == 0 && $_SESSION['m_user']) { list($p_id, $p_title, $p_price, $p_img) = mysql_fetch_row($result); $line_cost = $p_price * $quantity; $total = $total + $line_cost; mysql_query("insert into order(pid,o_user,o_title,o_img,o_price,o_qty,o_total) values ('$p_id','$m_user','$p_title','$p_img','$p_price','$quantity','$line_cost')"); } else if(mysql_num_rows($result) > 0 && $order_all !== 0){ mysql_query("update order set o_qty ='$quantity',o_total='$line_cost' where o_user='$m_user' and o_status='O'"); } Q : But how to fix this code, in short how to create sql/mysql code so that : Case1 : if the product not exist on user account / database , it will do : mysql_query("insert into order(pid,o_user,o_title,o_img,o_price,o_qty,o_total) values ('$p_id','$m_user','$p_title','$p_img','$p_price','$quantity','$line_cost')"); so that when user buy new product it can be added though user has buy some product before. and Case2 : if the product already exist on user account / database , it will do : mysql_query("update order set o_qty ='$quantity',o_total='$line_cost' where o_user='$m_user' and o_status='O'"); so that when user buy same product it can be change the quantity and total price, based on product that user had buy before. ?? Important : I buy product when in condition not login in other word as anonymous, and this image shown after I logged as user. so, image on above displayed based on database not on session. please help me...... Thanks
  17. Hi everyone, I think there is misunderstand here, please come to this site : http://demo.shop-scr.../free/index.php When I click one of the link (exmp : Price list) it's result : http://demo.shop-scr...?show_price=yes on address bar. When I debug on firefox it's using : <a class="menu" href="index.php?show_price=yes">Price list</a> Q : how to make file so that it can be shown like page on above using <a href> taq? please answer Thanks___________________________________________________________________________________ S : piyombombombe aling alang aling alang
  18. Hi, This tutorial is new? Because I didn't found it before thanks for reply_______________________________________- off : where do you come from?
  19. I don't understand with page using like this index.php?shopping=ok on address bar, I had try to create page like this : index.php then shopping.php and on <form> on actiion I wrote like this : index.php?shopping=ok but it won't show anything, Q : what my mistake?_______________________________________________________________________________ OFF : I had read the topic ZendCon on general, what the mean of this?
  20. Hi, I rather don't understand with this taq : foreach($_SESSION['product'] as $key=>$value) especially at : $key=>$value can you explain to me? Thanks
  21. Hello everyone, I think all of you understand if on index.php we use include taqs so that when user open another link for example : shop it will show like this on address bar : index.php?page=shop. Of course to show it I need to make file like this content_shop.php. But if I create file like this , when I using session_start() the session won't work. for example : If I buy product on page content_product.php and product shown to content_basket.php Therefore I create basket.php or buy.php so that the session and header can be works. please see this image : Q : Actually can I using session , if index.php file using include taq ?(directly on form action="index.php?page=basket" not basket.php at content_product.php please see on image above) N : header taqs same too won't work if I use it on content_product.php or etc please help me Thanks_______________________________________________________________________________________________ N : This question still have correlation with my previous post
  22. please see my new topic on file page for session, because this is maybe my root problem Thanks for reply
  23. Q : This is only 1 file or more than 1 file (can I separate this code become 2 file)? (for exmp : buy.php and cart.php) please help me Thanks
  24. Hello everyone Please come to my site, This is my site : http://secondbook.onlinewebshop.net/ Please click "BUY NOW" for every products twice or more, This is my question Q : How to make so that it show product only once and the quantity of product would be increase when user click on "BUY NOW" more than once? Q2 : How to create so that when user click "DEL" it will delete only at the product appropriate with user intent? please help me Thanks________________________________________________________________________________________________________ Note : if you need something please tell me, I will be tried to provide it for you , thanks
  25. Hi all, Thanks for answer, maybe I need to upload my site on temporary server, then I will show it on you all, If I already upload my site , I will post here again. Thanks everyone__________________________________________________________________________________________ OFFT : Please be patient to help me to understand. Thanks all for patience
×
×
  • Create New...