Php help

Discussion in 'PHP' started by goppss, Feb 1, 2011.

  1. #1
    I have the following code which when pulled from the database in an ascending order (ASC) works perfectly, but when pulled in a DESC order a row from the database goes missing.

    Can anyone offer any pointers?

    <?php
    
    require_once "../connect_mysql.php";
    	
    $sql =  'SELECT linkurl, linklabel, writtenby, lastmodified, byphrase FROM newarchive WHERE id BETWEEN 1 AND 20 ORDER BY id ASC';
    	$result = mysqli_query($myConnection, $sql) or die (mysqli_error($myConnection));
    	
    	$row = mysqli_fetch_array($result) or die(mysql_error());
    	
    	mysqli_close($myConnection);
    ?>
    Code (markup):
    <
    ?php
    				$counter = 2;
    					
    				while ($row = mysqli_fetch_array( $result, $counter <= 1048576 )) {
    					echo "<div class='newstruc'><div class='bytitle'>";
    					echo '<a href="' . $row['linkurl'] . '">' . $row['linklabel'] . '</a><br />';
    					echo "</div>";
    					echo "<div class='byline'><span class='byline1'>";
    					echo "written by: ";
    					echo $row ['writtenby'];
    					echo "</span>";
    					echo " | ";
    					echo "<span class='byline2'>";
    					echo $row['lastmodified'];	
    					echo "</span></div>";
    					echo "<div class='byphrase'>";
    					echo $row ['byphrase'];
    					echo "</div></div>";
    					
    					$counter = $counter * 2;
    					}	
    					 
    					?>
    Code (markup):

     
    Last edited: Feb 1, 2011
    goppss, Feb 1, 2011 IP
  2. TimK

    TimK Peon

    Messages:
    51
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Does it encounter any errors while trying to pull using DESC?
     
    TimK, Feb 1, 2011 IP
  3. goppss

    goppss Peon

    Messages:
    66
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply. I'm not witnessing any errors.
     
    goppss, Feb 1, 2011 IP