Jump to content

Problem with if


cajun225

Recommended Posts

I am new to php and having a problem with this part of my code.  This is a access control using ranks.  If the ranks is lower then say 88 it should display the top part of this code and if the rank is = or higher then it show the lower part.  The problem Im have is it looks like the higher/lowrer rank part is working backwards and for the last part of the code it only displays the submit button and not the form.  Like I said im new to php and do not see the problem.  Can anyone help?

 


<?

// Start rank restrictions for Ladder removing

$s = mysql_query("SELECT * FROM cs_bio WHERE username = '$me'");
  while($m = mysql_fetch_array($s)) {
  $myid = $m['id'];
  }
  $sql = "SELECT * FROM `cs_team` WHERE `pid` = '$myid' AND `rank` >= '88'";
  $result = mysql_query($sql);
if(mysql_num_rows($result) == 0)
  {
  	?>
    <fieldset>
	 <legend>Ladders Joined:</legend>

<?

  $lq = mysql_query("SELECT * FROM cs_joined WHERE tid = '$qid'") or die (mysql_error());
  while($ly = mysql_fetch_assoc($lq)){
$ladder = $ly['laddername'];
$lid = $ly['lid'];	
$ladder1 = mysql_real_escape_string($ladder);
  $lr = mysql_query("SELECT * FROM cs_ladders WHERE id = '$lid'") or die (mysql_error());
  while($lt = mysql_fetch_assoc($lr)){
$mode = $lt['mode'];
  $format = $lt['format'];
$cid = $lt['console'];
  $w = mysql_query("SELECT * FROM cs_consoles WHERE id = '$cid'");
  while($e = mysql_fetch_array($w)) {
  $co = $e['console'];	
?>	
     
     <div class="myinfo"><? echo $ladder ?> - <? echo $mode ?> - <? echo $format ?> - <? echo $co ?></div>
<? }}} ?>

	</fieldset>	

	<?
}
else {
?>

  
  
  		

    <fieldset>
	 <legend>Ladders Joined:</legend>

<?
if($_POST['remove'] == 'quit this ladder')
{		 
  $in = "DELETE FROM cs_joined WHERE `tid` = '$qid' AND lid = '$_POST[bid]'";
  $res = mysql_query($in) OR die(mysql_error());

  $in = "UPDATE cs_ladders SET teams = teams - 1 WHERE id = '$_POST[bid]'";
  $res = mysql_query($in) OR die(mysql_error());	
echo "<meta http-equiv='refresh' content='0; url=teamcp.php?&id=$qid'>";		
}
  $lq2 = mysql_query("SELECT * FROM cs_joined WHERE tid = '$qid'") or die (mysql_error());
  while($ly = mysql_fetch_assoc($lq2)){
$ladder2 = $ly['laddername'];
$lid = $ly['lid'];	
$ladder12 = mysql_real_escape_string($ladder);
  $lr2 = mysql_query("SELECT * FROM cs_ladders WHERE id = '$lid'") or die (mysql_error());
  while($lt = mysql_fetch_assoc($lr2)){
$mode2 = $lt['mode'];
  $format = $lt['format'];
$cid2 = $lt['console'];
  $w2 = mysql_query("SELECT * FROM cs_consoles WHERE id = '$cid'");
  while($e = mysql_fetch_array($w2)) {
  $co2 = $e['console'];	
?>	
    <form name="form1" method="post" action="teamcp.php?&id=<?=$qid?>">	 
     <div class="myinfo"><input type="radio" class="chkbox" name="bid" value="<? echo $lid2 ?>"><? echo $ladder2 ?> - <? echo $mode2 ?> - <? echo $format2 ?> - <? echo $co2 ?></div>
<? }}} ?>
 	 <div class="update"><input type="submit" name="remove" value="quit this ladder"></div>
	 </form>
	</fieldset>	
	<? }
	// End rank restrictions for Ladder Removing


	 ?>	

Link to comment
https://forums.phpfreaks.com/topic/199592-problem-with-if/
Share on other sites

If the ranks is lower then say 88 it should display the top part of this code . . .

 

That contradicts this:

 

$sql = "SELECT * FROM `cs_team` WHERE `pid` = '$myid' AND `rank` >= '88'";  // should be < 88, yes? Also note that integers should not be quoted in a query string.

Link to comment
https://forums.phpfreaks.com/topic/199592-problem-with-if/#findComment-1047660
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.