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


    database.php function

    Share
    avatar
    mbrad

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

    database.php function

    Post  mbrad on 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
    avatar
    Linchpin311

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

    Re: database.php function

    Post  Linchpin311 on 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?


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.
    avatar
    mbrad

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

    Re: database.php function

    Post  mbrad on 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
    avatar
    wasim

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

    my qucik

    Post  wasim on 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

    Re: database.php function

    Post  Sponsored content


      Current date/time is Mon Nov 20, 2017 9:38 am