SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Location
    montreal, quebec, canada
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i've managed to code so that the records in my "proj" table are diplayed the way i want, but i would like the page to display something simple like "End of Files" when all are printed. i'm assuming a "while - else" loop would be applicable here, but none of my attempts work.

    Here is the code as i have it presently:
    <?php

    $result = mysql_query("SELECT * FROM proj",$dbcnx);

    printf("<font size='-1' face='Arial, Helvetica, sans-serif'><P><b>Project: %s<br></b></font>\n", mysql_result($result,0,"name"));
    printf("<font size='-1' face='Arial, Helvetica, sans-serif'>Project Complete: %s<br></font>\n", mysql_result($result,0,"projcomplete"));
    printf("<font size='-1' face='Arial, Helvetica, sans-serif'>Pages Complete: %s<br></font>\n", mysql_result($result,0,"pagecomplete"));
    printf("<font size='-1' face='Arial, Helvetica, sans-serif'>Database: %s<br></font>\n", mysql_result($result,0,"db"));
    printf("<font size='-1' face='Arial, Helvetica, sans-serif'>Updated: %s<br></font></p>\n", mysql_result($result,0,"updated"));

    ?>

    anyone have the input to tweat it to do what i want?
    thanks all.


  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Location
    montreal, quebec, canada
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    P.S. if anyone knows if there is a "cleaner way to do the above code, please lete me know. i have the feeling it could be smaller and more efficient.

  3. #3
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cleaner? I'd take this part: "<font size='-1' face='Arial, Helvetica, sans-serif'>" and I'd stick in a variable

    $textformatting = "("<font size='-1' face='Arial, Helvetica, sans-serif'>"

    Might work...



    ------------------
    Chris Bowyer - Programmer in Training
    MyCoding.com: Join our mailing list for launch notification!
    "I'm not an insomniac, I'm a web designer."

  4. #4
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    tinyitn,

    I suggest you read Part 4 of my series, "Building aDatabase-Driven Website using PHP and MySQL": Publishing MySQL Data on the Web. Specifically, the section entitled Handling SELECT Result Sets has the answers you need.

    Displaying result sets using while loops is covered in detail, with several examples for you to work from. If you still need help after reading that, let me know and I'll post some code.


    ------------------
    -Kevin Yank.
    http://www.SitePoint.com/
    Helping Small Business Grow Online!


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
  •