how to make this code work?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tharindu96
    New Member
    • Jan 2012
    • 16

    how to make this code work?

    http://localhost/download.php?lt =a&sr=0&sp=9

    lt = letter(eg:- a,b)
    sr = start
    sp = stop
    Code:
       <?php
    	if(isset($_GET['lt'])){
    		$lt = $_GET['lt'];
    		if(isset($_GET['sr'])&&isset($_GET['sp'])){
    		$sr = $_GET['sr'];
    		$sp = $_GET['sp'];
    			if(!empty($lt)){
    				if(!empty($sr)&&!empty($sp)&&$sp!=9){
    					if(strlen($lt) == 1){
    						echo '<h2>'.strtoupper($lt).' Games</h2>';
    						$nquery = "SELECT * FROM `games` WHERE `flname` = '".$lt."' OR '".strtoupper($lt)."' ORDER BY `created` ASC LIMIT ".$sr." ".$sp."";
    						if($nquery_result = mysql_query($nquery)){
    							if($nquery_num = mysql_num_rows($nquery_result)){
    								while($nquery_r = mysql_fetch_assoc($nquery_result)){
    								$nquery = "SELECT * FROM `games` WHERE `flname` = '".$lt."' OR '".strtoupper($lt)."' ORDER BY `created` ASC LIMIT ".$sr." ".$sp."";
    								$nquery_result = mysql_query($nquery);
    								$nquery_r = mysql_fetch_assoc($nquery_result);
    								echo '<article>';
    								echo '<a href="game.php?id='.$nquery_r['id'].'"><div id="g_head">'.$nquery_r['name'].'</div></a><br>';
    								echo '<a href="game.php?id='.$nquery_r['id'].'"><img src="'.$nquery_r['image'].'" alt="'.$nquery_r['alt'].'" width = "150px"></a>';
    								echo '</article>';				
    								}
    								while($sp<$nquery_num){
    									$sr = $sr + 10; 
    								}
    							}else{
    								echo 'Ok2';
    							}
    						}else{
    							echo 'Ok3';	
    						}
    					}
    				}
    			}
    		}
    	}else{
    		echo '<h2>Latest Games</h2>';
    		$nquery = "SELECT * FROM `games` ORDER BY `created` DESC LIMIT 9";
    		if($nquery_run = mysql_query($nquery)){
    			while($nquery_result = mysql_fetch_assoc($nquery_run)){
    				echo '<article>';
    				echo '<a href="game.php?id='.$nquery_result['id'].'">'.$nquery_result['name'].'</a><br>';
    				echo '<a href="game.php?id='.$nquery_result['id'].'"><img src="'.$nquery_result['image'].'" alt="'.$nquery_result['alt'].'" width = "150px"/></a><br>';
    				echo '</article>';
    			}
    		}
    	}
    	?>
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    What is the code doing and what do you want the code to do instead?

    Comment

    Working...