Mutley Posted November 4, 2008 Share Posted November 4, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/131384-script-problem-cuts-off-results-and-wont-work/ Share on other sites More sharing options...
Maq Posted November 4, 2008 Share Posted November 4, 2008 You're comparing rather than assigning $unlocked. You also don't need single quotes. For example: $unlocked == '1'; } else { $unlocked == '0';} Should be: $unlocked = 1; } else { $unlocked = 0;} Quote Link to comment https://forums.phpfreaks.com/topic/131384-script-problem-cuts-off-results-and-wont-work/#findComment-682324 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.