SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Threaded View

  1. #1
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    While loop printing too many times

    this is some code that's suppose to parse multiple page when getting data, but it's just printing it a bunch of times.
    can anyone see what the problem is?
    PHP Code:
    <?php
    $db_connect 
    mysql_connect (hostusernamepassword);
    $dbname "databasename";
      
    ///////////////////////////////////
     // Parse multiple pages section. //
    ///////////////////////////////////
    $count 1
    $numcols 3
    $limit 7;

    $sqlcount"SELECT id,username,email,dis_email,reg_date,url,icq,aim,yahoo,msn from 3dartisan_users";
    $sqlcount.=" WHERE is_admin=0 AND verify=1"

    $sql_countresult mysql_db_query($dbname$sqlcount$db_connect); 
    $totalrows mysql_num_rows($sql_countresult) or die(mysql_error()); 

    if(empty(
    $page)){ 
    $page 1


    $limitvalue $page*$limit-($limit); 
    $sql  "SELECT id,username,email,dis_email,reg_date,url,icq,aim,yahoo,msn from 3dartisan_users";
    $sql .= " WHERE is_admin=0 AND verify=1 LIMIT $limitvalue$limit"
    $sql_result mysql_db_query($dbname$sql$db_connect); 


    while (
    $row mysql_fetch_array($sql_result)){ 

    // This section houses the html and php that i use to print the memberlist. You can see this code at this link:
    // www.3dartisan.net/htmldata.txt

    <?

    echo 
    "<BR>"

    if(
    $page != 1) { 
    $pageprev$page 1
    echo 
    "<font color=\"#FFFFFF\" size=\"2\"><A HREF=\"$PHP_SELF?page=$pageprev\">";
    echo 
    "<b><< Prev</b></A></font><font color=\"#0000FF\" size=\"2\"> [</font>"
    // if page is not equal to one, prev goes to $page - 1 

    else { 
    echo 
    "<font color=\"#FFFFFF\" size=\"2\"><b> << Prev  </b></font><font color=\"#0000FF\" size=\"2\">[</font>";




    $numofpages $totalrows/$limit

    for(
    $i1$i $numofpages$i++) { 
    if(
    $page == $i) { 
    echo 
    "<font size=\"2\"> $i </font>"//make number navigation 

    else{ 
    echo 
    "<font size=\"2\"> <A HREF=\"$PHP_SELF?page=$i\">$i</font></A> "//make number navigation 



    if(
    $totalrows%$limit != 0) { 
    if(
    $page $numofpages) { 
    echo 
    "<font size=\"2\"> $i </font>"//make number navigation 

    else{ 
    echo 
    "<font size=\"2\"> <A HREF=\"$PHP_SELF?page=$i\">$i</font></A> "////if there is a remainder, add another page 





    if((
    $totalrows-($limit*$page)) > 0){ 
    $pagenext $page 1
    echo 
    "<font size=\"2\" color=\"#0000FF\">] </font><A HREF=\"$PHP_SELF?page=$pagenext\"><font size=\"2\"><b>Next >></b></A> "
    // if the totalrows - $limit * $page is > 0 (meaning there is a remainder), leave the next button. 
    } else {
    echo 
    "<font color=\"#0000FF\" size=\"2\">]</font><font color=\"#FFFFFF\" size=\"2\"> <b>Next >> </b></font>"; }

    mysql_free_result($sql_result);  
    mysql_close ($db_connect);

    if (
    $date_y==2001){
    $if_date "Copyright &copy; 2001";
    } else {
    $if_date "Copyright &copy; 2001-$date_y"; }

    ?>
    <br>
    <br>
    <font size="1" face="verdana" color="#FFFFFF">3dartisan.net and all of it's contents are <?php print "$if_date"?><br>
    All user user submitted work is &copy; it's respective author.</font>
    </center>
    </body>
    </html>
    Last edited by Defender1; Aug 22, 2001 at 16:01.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •