Jump to content

gongpex

Members
  • Posts

    360
  • Joined

  • Last visited

Posts posted by gongpex

  1. Hello everyone, Today I tried to upload my product using <input type="file" > and it shown like this (post-55622-0-95607400-1354281963_thumb.gif). 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. The for loop starts at a specific point in the array, and loops for a certain number
    A : Actually I rather don't understand with for each loop , but after you explain to me, I become understand. (Thanks)
    Which one do you want, do you want to show everything on every page?
    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 : data-lost.gifInformation : 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 : pagination.gif 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']); ???

    Instead of getting the data from a database you already have it in an array, you just need to figure out where to start in the array and how many to show.
    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 :

    you have a weird for loop that I asked you questions about that you didn't answer. I don't know what you're trying to do there
    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 : pagination-r.gifCode 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 : no_number.gif and the problem still same : Image 2 : problem-1.gif And I don't know why this is occurred : Image 3 : problem-2.gifThis 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 don't really understand what you're saying the problem is or what your questions are, but the code doesn't look right. I don't understand what you're trying to do here:
    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 : first.gif and this is my problem / question : Image 2 : problem.gif 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 expectation.gifMy 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
  9. 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

  10. 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

  11. You need to check if each product is in the order instead of checking if there are any products in the order at all.
    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
  12. Hello everyone, please see these images on bellow : first-step.gif When I click "BUY NOW", then I login into account it's successful to added to database. And this the result : before.gif But when I buy same or other product like this : sec-step.gif it's result like this : after.gif 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

  13. 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

  14. 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?

  15. 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 : step.jpgQ : 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

  16. 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

  17. 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__________________________________________________________________________________________

    I'm also trying to help you understand what your code is doing, it sounds like you don't understand it.
    OFFT : Please be patient to help me to understand. Thanks all for patience
×
×
  • Create New...