Jump to content

Script problem, cuts off results and won't work.


Mutley

Recommended Posts

Firstly, the script cuts off items where $unlock != 0, it seems to be stopping the loop continuing.

 

Secondly, it won't work if $unlock == "1000_bronze" for example, it won't perform the IF statement further down that echos "Locked".

 

	$sql  = "SELECT prod_id, slot, points, manufacture, name, description, stock, price, `unlock` FROM products WHERE slot = '$cat' AND grade=0 ORDER BY $orderby";
$result = mysql_query($sql);

if(mysql_num_rows($result)!=0) { // (3)

while(list($prod_id, $slot, $points, $manufacture, $name, $description, $stock, $price, $unlock) = mysql_fetch_row($result)) { // (4)
?>

  <tr>
  	<td><center><img src="images/products/<?=$prod_id?>.jpg" alt="<?=$name?>" border="1" /></center></td>
  	<td align="center">
	<b><?=$manufacture?><br /> <font style="color:#FF6600; font-size:larger;"><a name="<?=$prod_id?>"><?=$name?></a></font></b><br />
	<img src="images/manufactures/<?=$manufacture?>.gif" alt="<?=$manufacture?>" />
</td>
    <td style="background-color:#EAEAEA; padding:5px;"><?=$description?></td>
    <td align="center">
		<?
		if($stock < '3') {
		$status = "ff0000";
		} else {
		$status = "009933";
		}
			$result_qty = mysql_query("SELECT COUNT(*) AS qty_sold FROM own WHERE prod_id = '$prod_id'");
			while($row_qty = mysql_fetch_array( $result_qty ))
			{
				$qty_sold = $row_qty["qty_sold"];
			}

		//----------------------------------------
		// Check if the product is locked by achivement
		//----------------------------------------
			if($unlock != '0') {
				$result = mysql_query("SELECT '$unlock' AS `score` FROM achievements WHERE user_id = '$user_id'");
				while($row = mysql_fetch_array( $result ))
				{
					$score = $row["score"];
				}
			//----------------------------------------
			// Achievements Below
			//----------------------------------------
				if($unlock == "1000_bronze" && $score == "1000") {
					$unlocked == '1';
				} else { $unlocked == '0';}
				if($unlock == "1000_silver" && $score == "1000") {
					$unlocked == '1';
				} else { $unlocked == '0';}					
				if($unlock == "1000_gold" && $score == "1000") {
					$unlocked == '1';
				} else { $unlocked == '0';}
				if($unlock == "3_tourn" && $score == "3") {
					$unlocked == '1';
				} else { $unlocked == '0';}					
			} else {
				$unlocked == '1';
			}
		?>

		<font style="color:#<?=$status?>; font-size:larger;"><b><?=$stock?></b></font>
			<br />
		<font style="font-size:x-small">Qty Sold:<br /> <?=$qty_sold?></font>
</td>
    <td align="center"><b>£<?=$price?></b></td>
    <td align="center">
	<? if($unlocked == '0'){
			echo "Locked";
		}elseif($stock == '0') {
			echo "Out of Stock";
		}else{ // Disable buy button if no stock or achievement
	?>
			<form action="shop.php?cat=<?=$cat?>&buy=<?=$prod_id?>" method="post">
			<input type="submit" name="submit" value="Buy" />
			</form>
	<? }?>

 

Any advice greatly appreciated. :)

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.