[RESOLVED] Members List
Results 1 to 4 of 4

Thread: [RESOLVED] Members List

  1. #1
    Member
    Join Date
    Apr 2012
    Posts
    33

    resolved [RESOLVED] Members List

    I am trying to make a list of members on my site, but none of the names show up on the page when I run the code. Here's the code:

    PHP Code:
    <?php
    session_start
    ();

    if (!
    $_SESSION["valid_user"])
    {
    // User not logged in, redirect to login page
    Header("Location: index.php");
    }

    ?>

    <html>
        <head>
            <title> Lego Comic </title>
            <link rel="stylesheet" type="text/css" href="style.css" />
            <style type="text/css">
    #Menu ul
    {
    list-style-type:none;
    margin-left: 100px;
    margin-right: 100px;
    padding:0;
    overflow:hidden;
    }
    #Menu li
    {
    float:left;
    }
    #Menu a:link, #Menu a:visited
    {
    display:block;
    width:204px;
    font-weight:bold;
    color:#FFFFFF;
    background-color:#06799f;
    text-align:center;
    padding:4px;
    text-decoration:none;
    text-transform:uppercase;
    border-width: medium
    border-style: ridge
    border-color: red
    }
    #Menu a:hover,a:active
    {
    background-color: red;
    }
    #Members ul
    {
    list-style-type:none;
    }

    </style>
        </head>

        <body>
            <center>
            
            <?php
            
    include "dbconfig.php";
            
    ?>
            
                <div id="Menu">
                <ul>
                <li><a href="mainsite.php" title="Home">Home</a></li>
                <li><a href="currentcomic.php" title="Current Comic">Current Comic</a></li>
                <li><a href="othercomics.php" title="Other Comics">Other Comics</a></li>
                <li><a href="games.php" title="Games">Games</a></li>
                <li><a href="members.php" title="Members">Members</a></li>
                </ul>
                </div>
                
                <h1> Lego Comic </h1>
                <h2> List of Members </h2>
                
                <div id="Members">
                <ul>
                
                <?php
                
                
    // SQL query
                
    $strSQL "SELECT * FROM Members ORDER BY 'username' DESC";

                
    // Execute the query (the recordset $rs contains the result)
                
    $rs mysql_query($strSQL);
        
                
    // Loop the recordset $rs
                
    while($row mysql_fetch_array($rs)) {

                   
    // Name of the person
                  
    $strName $row['username'];

                   
    // Create a link to person.php with the id-value in the URL
                   
    $strLink "<a href = 'person.php?id = " $row['id'] . "'>" $strNavn "</a>";
                    
                    
    // List link
                   
    echo "<li>" $strLink "</li>";

                  }
                
    ?>
                
                </ul>
                </div>
                
                <?php
            
    // Display logout link
            
    echo "<p> This page was last edited: " date("r"filemtime("members.php"));
            
    //This shows when the page was last edited
            
    ?>
            <p><a href="logout.php" title="Logout">Click Here To Logout!</a></p>
            
            </center>
        </body>
    </html>
    Any ideas? Also, I am following a tutorial, but cannot make sense of "$strNavn", which it told me to write. What is it?

  2. #2
    Senior Member Derokorian's Avatar
    Join Date
    Apr 2011
    Location
    Denver
    Posts
    1,782
    As suggested before you should have error_reporting set to E_ALL and display errors on. If it were you would be getting undefined variable $strNavn which I believe should be $strName but why do that at all? Why not just use $row['username'] like you did with the user's id?
    Sadly, nobody codes for anyone on this forum. People taste your dishes and tell you what is missing, but they don't cook for you. ~anoopmail
    I'd rather be a comma, then a full stop.
    User Authentication in PHP with MySQLi - Don't forget to mark threads resolved - MySQL(i) warning

  3. #3
    newbie php developer Damian_'s Avatar
    Join Date
    Jun 2011
    Location
    london
    Posts
    93
    try this http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php

    Your strNavn is not decalre anywhere

    could it be the name for your user?

    $strNavn = $row['name']; <---- like this aswell?

    we don't know until you give us more inform, what fields do you have in your database?

    And are there any errors to report?

  4. #4
    Member
    Join Date
    Apr 2012
    Posts
    33
    You solved it! Thank you! Man, I really should have noticed that one... it was supposed to be $strName.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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