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
The function in my database.php is:
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
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