SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    at icosmoss.com I have separated our projects into "completed" and "pending". I already have made the script loading the data but how do I display the results now?

    I'm thinking of the echo tag...

    ------------------
    Matthias Hagemann

    Need some source code?
    icosmoss.com - The Open Source Community

  2. #2
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    A simple select statement can handle this.

    select * from projecttable where type='pending'

    Then your record set would only contain the appropriate records.

    ------------------
    Wayne Luke - Sitepoint Forums Administrator
    Digital Magician Magazine - MetaQuark Creations (Coming Soon)
    sitepoint@digitalmagician.com

    [This message has been edited by wluke (edited August 10, 2000).]

  3. #3
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Uhh, I'm already that far. Maybe I didn't explain it precisely. I would like to display the results in the HTML file using echo. Something like

    for every result
    {
    printf( "<td>data1</td><td>data2</td>");
    }

    It's just that I'm not sure with the code.

  4. #4
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DIMA: I'm 99% sure that this can be done, but you'll definetly need to be more specific...it would help if you would provide us with some of your code and point to where you think something is missing...



    ------------------
    Chris Bowyer chris@mycoding.com
    MyCoding.com: Visit for Launch Notification!
    DomainMailings.com: Who Says All The Good Ones Are Taken?
    MovieForums.com: Talk About Your Favorite Flicks!

  5. #5
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, here's the whole code (shortened):

    <?php

    // connect to the database server
    $connection = mysql_connect("localhost", "user", "pass") or die("Ooops! Couldn't make connection.");

    // selecting a database in mySQL
    $db = mysql_select_db("db", $connection) or die("Ooops! Couldn't select database.");

    // request the text of all the info
    $sql_result = mysql_query("SELECT author, language, date, title FROM table WHERE status = $status");

    // defining var of row
    while($row = mysql_fetch_array($sql_result))
    {
    // define vars
    $author = $row["author"];
    $language = $row["language"];
    $date = $row["date"];
    $title = $row["title"];
    }

    ?>

    All projects listed below are freely downloadable and ready for any changes. Before sending.......
    <BR><BR><BR>

    [ this is the place where the result should be shown ]
    [ just like http://www.icosmoss.com/pending.shtml ]


    I parse the var for $status in the URL before, so it knows what rows to show.


    [This message has been edited by DIMA (edited August 10, 2000).]

  6. #6
    SitePoint Zealot
    Join Date
    May 2000
    Location
    Eugene, OR
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    // defining var of row
    while($row = mysql_fetch_array($sql_result))
    {
    // define vars
    $author = $row["author"];
    $language = $row["language"];
    $date = $row["date"];
    $title = $row["title"];


    echo( "<tr><td>" . $title . "</td>" .
    "<td>" . $language . "</td>" .
    "<td>" . $author . "</td>" .
    "<td>" . $date . "</td></tr>");


    }
    ?>

    // And Put this stuff up above the database part

    All projects listed below are freely downloadable and ready for any changes. Before sending.......
    <BR>
    <table>


    Hope this helps,

    Adam



    ------------------
    Visit the Sitepoint Chat!
    http://www.sitepoint.com/forums/chat.php3

  7. #7
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks, it works just fine!

    To see the result just go to http://www.icosmoss.com/ and click on pending or completed projects.

    One more thing: is it possible to sort the listing by name?

    ------------------
    Matthias Hagemann - matt@icosmoss.com
    Need some source code?
    icosmoss.com - The Open Source Community

  8. #8
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Add an "ORDER BY" clause to your SQL statement.

    SELECT author, language, date, title FROM table WHERE status = $status ORDER BY title

    ------------------
    Wayne Luke - Sitepoint Forums Administrator
    Digital Magician Magazine - MetaQuark Creations (Coming Soon)
    sitepoint@digitalmagician.com

  9. #9
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks to you all! It works perfectly


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
  •