Jump to content

Sorry me again!


emma57573

Recommended Posts

Im trying to ask if a mysql result that matches comes up more than once in the same session / for loop.

 

I was thinking something like this

$uid = $sub["uid"];

$uid > 2) 

 

But that doesnt make sence at all as its looking at the just the result.

I thought about counting an array but that wont work because I want to look at the results in the array and if they match I want to count them.

The results are in a for loop inside a session.

Link to comment
https://forums.phpfreaks.com/topic/113040-sorry-me-again/
Share on other sites

Sorry Im terrible at explaining myself  ;D

 

Its in the '///////////////Im stuck with this postage bit AGAIN:'

bit.

Im trying to ask if the user is from overseas AND the store offers postage world wide then offer worldwide shipping: THEN if the user has ordered more than one item from the same store then offer a combine shipping price on the second and addition items

$sub["uid"]

holds the stores id.

 

 

This is not the page where the script is held. The script is for the final checkout but it might give you a good idea of what im trying to do:

http://www.misi.me.uk/viewcart.php

 

Sorry for being such a novice  :-[ I do try and look these things up but I can never find what I need!

 

 

foreach ($contents as $id=>$qty) {


$sql = 'SELECT * FROM freetplclassified_products WHERE id = '.$id;
$result = $db->query($sql);
$rst = $result->fetch();
$rs_t=mysql_fetch_array(mysql_query("select * from freetplclassified_members where id=".$rst["uid"]));
$freetplq_img=mysql_fetch_array(mysql_query("select * from freetplclassified_images where  pid=".$rst["id"]));
  $subtotal = 0.00;


		extract($rst);
		$output[] = '<table width="90%" cellpadding="5" class="onepxtable" align="center"">';
		$output[] = '<tr>';
		$output[] = '<td colspan="3"><h2>Your <a href="http://www.misi.me.uk/store_info.php?id='.$rst["uid"].'">'.$rs_t["username"].' Order</a></h2></td>';
		$output[] = '</tr>';
		$output[] = '<tr>';


	    $output[] = '<td align="left"><a href="http://www.misi.me.uk/product_desc.php?id='.$id.'"><img src="http://www.misi.me.uk/uploadedimages/'.$freetplq_img["url"].'" width="75" height="75" border="0" class="onepxtable"></a></td>';
		$output[] = '<td align="left"><a href="http://www.misi.me.uk/product_desc.php?id='.$id.'">'.$product_name.'<br><br></td>';
		$output[] = '<td align="right">£'.$buy_price.'<br><br>Quantity: '.$qty.'';




///	Postage details	


		if (($rst["worldwide"]=="yes")&&($country!="UK")){

				$output[] = '<br><br>Overseas Postage: '.$worldwide_shipping.'';
		}




///////////////Im stuck with this postage bit AGAIN:



if (($rst["worldwide"]=="yes")&&($country!="UK")&&($sub["uid"] > 2) ){

		$output[] = '<br><br>Combined Overseas Postage: '.$worldwide_combine_shipping.'';



		}

	///////////////Im stuck with this postage bit AGAIN:	




		$output[] = '<br><br>Postage: '.$shipping_price.'</td></tr>';


			$subtotal += ($buy_price * $qty + $shipping_price);

	$output[] = '<tr><td colspan="3" align="right"><class="smlgrey">Sub total</class> £'.number_format($subtotal.$cents,2,'.','').'</td></tr>';

		$total += $buy_price * $qty + $shipping_price;
		$output[] = '</tr>';
		$output[] = '</table><br><br>';
	}
	$output[] = '</table>';
	$output[] = '<p>Total: <strong>£'.number_format($total.$sents,2,'.','').'</strong> <class="smlgrey" Excludes Postage</class></p>';
	$output[] = '<p>Please note Postage will be calculated on checkout</p>';
	$output[] = '<div><button type="submit">Update cart</button></div>';
	$output[] = '</form>';
} else {
	$output[] = '<p>You shopping cart is empty.</p>';
}
return join('',$output);

}



 

 

Link to comment
https://forums.phpfreaks.com/topic/113040-sorry-me-again/#findComment-580685
Share on other sites

OK The data wont be inserted to the database until the user hits confirm on this page although all the data comes from a database and is placced into a session but you gave me a big clue so I tried this feeling sure it would work:

	  $countuid = $rst["uid"];


///	Postage details	


		$worldwide = ($rst["worldwide"]=="yes")&&($country!="UK");



		$sub = 'SELECT * FROM '.$_SESSION["cart"].' WHERE uid=$countuid ORDER BY COUNT(*)';


		if ($worldwide&&($sub > 1)){

		$output[] = '<br><br>Combined Overseas Postage: '.$worldwide_combine_shipping.'';



		}

 

Im not sure why that wouldnt work: Im not getting any errors its just not working if I type in $sub = 1 insead then it works but uses combined postage for everything so its obviously not counting properly  :-\

Link to comment
https://forums.phpfreaks.com/topic/113040-sorry-me-again/#findComment-580729
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.