SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2001
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    variables stored in mysql...

    I have a template system on my site.

    I created this function for retrieving them:
    Code:
    function showtemplate($templatename) {
        $gettemp_query=mysql_query("SELECT template FROM templates WHERE title='".addslashes($templatename)."'");
        $gettemp=mysql_fetch_array($gettemp_query);
        mysql_free_result($gettemp_query);
        $template=$gettemp[template];
        $template=str_replace("\"","\\\"",$template);
    
    return $template;
    }
    then, i have a template stored in my database with a variable in it. something like this:
    Code:
    <html>
    <body>
    <table border="1"><tr><td>
    $member_listing</td></tr></table>
    </body>
    </html>
    what i need to do is retrieve all member names out of the database and list them in the table using $member_listing.

    I tried to use the while() function but it just shows the last member in the database.

    can somebody help me?

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try something like this:

    PHP Code:
    $sql mysql_query("SELECT membername FROM members_table") or die(mysql_error()); 
    And then:
    PHP Code:
    while ( $result mysql_fetch_array($sql) ) {

        
    extract($result);

        
    $member_listing .= $membername;


    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


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
  •