SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  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 17:01.
    Defender's Designs
    I'm Getting Married!

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

  2. #2
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can't anybody help me?!?
    Defender's Designs
    I'm Getting Married!

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

  3. #3
    SitePoint Addict
    Join Date
    Jun 2001
    Location
    Malaysia
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's a very long list of code...

  4. #4
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yea, but the actual php is very little.
    from where it begins BEGIN LOOP DATA to where it says END DATA SECTION is just the html to be parsed in the loop.
    Defender's Designs
    I'm Getting Married!

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

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because you have the navigation link code inside your while() loop so its gonna print the navigation once for every record you have.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i was kinda thinking that. but when it wasn't, and i clicked next, it just printed the same page again...

    i'm never gonna get this to work...
    Defender's Designs
    I'm Getting Married!

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

  7. #7
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what the heck should i put in the while loop to make it parse the pages correctly?
    Defender's Designs
    I'm Getting Married!

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

  8. #8
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nm, fixed my problem.
    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
  •