PHP Login System with Admin Features

Would you like to react to this message? Create an account in a few clicks or log in to continue.
PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


3 posters

    database.php function

    mbrad
    mbrad


    Number of posts : 42
    Registration date : 2009-02-19

    database.php function Empty database.php function

    Post  mbrad Tue Apr 13, 2010 2:01 pm

    Thanks for taking the time to read my question.

    I am making a new page, and want to run a function that runs a query, then loops through the results, building a string. I then want to print or echo that string back on the page I'm making.

    The page I'm making is called Stats.php
    Code:

    <td><select>
    <option selected="selected">Select</option>

    <?php
    echo $database->TeamList;

     ?>
    </select>
    </td>



    The function in my database.php is:
    Code:

    //This is at the top of the page with the rest of the variables
    var $TeamList;        //List of Teams in the DB


    //last function on page
      function ListOfTeams(){
            $q="SELECT `TeamName` FROM `p_p` GROUP BY `TeamName` ORDER BY `TeamName`;";
          $results= $this->query($q);
          $x=0;
          $this->TeamList = 55;
          while ($row = mysql_fetch_assoc($results)) {
             foreach($row as $value){
                $x++;
                if(strlen($this->TeamList==0)) {
                   $this->TeamList = "<option value='" . $value . "'>" . $value . "</option>\n";
                }
                else {
                   $this->TeamList = $this->TeamList . "<option value='" . $value . "'>" . $value . "</option>\n";
                }
             }
          }
      }

    This code returns nothing, not even an error. I cannot figure out what I'm doing wrong.

    I've tested the query in phpMyAdmin and it returns the results that I want it to.

    I'm logged in, and there is a session created for the user (used a bit of code from main.php to prove it to myself. it shows Logged In)

    Thanks,

    Brad
    Linchpin311
    Linchpin311


    Number of posts : 220
    Age : 38
    Localisation : Long Island
    Registration date : 2007-05-14

    database.php function Empty Re: database.php function

    Post  Linchpin311 Wed Apr 14, 2010 10:37 pm

    im not seeing a return statement in your function. are you planning on accessing $database->TeamList from somewhere in your script? if not, how are you planning on fetching your desired result?
    mbrad
    mbrad


    Number of posts : 42
    Registration date : 2009-02-19

    database.php function Empty Re: database.php function

    Post  mbrad Sat Apr 24, 2010 1:24 am

    I went in another direction here. This was just not the way to go. I was making the problem harder than it needed to be.

    Thanks for your reply.

    Have a great day,


    Brad
    wasim
    wasim


    Number of posts : 3
    Registration date : 2010-12-01

    database.php function Empty my qucik

    Post  wasim Wed Dec 01, 2010 2:09 am

    then loops through the results, building a string. I then want to print or echo that string back on the page I'm making.
    Company Formation
    Company Registration

    Sponsored content


    database.php function Empty Re: database.php function

    Post  Sponsored content


      Current date/time is Fri May 17, 2024 5:45 am