I've created a function:
public function showProjects($sort) {
$project_list_result = mysql_query("SELECT * FROM projects ORDER BY name ".$sort."") or die ('Project list could not be generated: '.mysql_error());
return $project_list_result;
}
The function is part of a class (Projects) that is included in the page that is going to display these records
When I try to use a while loop, my computer goes into overdrive and will eventually either display a white page, or it will display the name of the first project in the list 80 bajillion times:
$project_list = new Projects();
while ($project_list_row = mysql_fetch_assoc($project_list->showProjects($sort))) { // The $sort variable is set much earlier in the page - it is not a typo from the function
$page->contentSet('
<tr>
<td>'.$project_list_row['name'].'</td>
<td>'.$project_list_row['url'].'</td>
<td>'.$project_list_row['added'].'</td>
<td valign="middle" align="center"><img src="images/edit.png" /></td>
<td valign="middle" align="center"><img src="images/delete.png" /></td>
</tr>
');
}
I have done many googles trying to find anything similar to what I'm doing and have been presented mostly with pagination class/function tutorials. While these tutorials aren't useless (I will have to implement them one day I would guess), I cannot follow what it is they are trying to do and wind up lost within the first 10-15 lines of code. I've also searched around on PHP.net and couldn't find any help there (my guess is because I didn't really know what to look for).
Some of my googling has shown me that instead of using a while loop, I should actually be using a foreach or a while-list. It is almost about this point in the code that I begin to get lost.
I know that there are 13 records in the table I'm querying.
Any help is greatly appreciated and please keep in mind that because I've been writing procedural code for so long, all of this oop stuff is difficult for me to wrap my head around
Thanks!
This post has been edited by Shiznit: 11 November 2009 - 09:28 PM

New Topic/Question
Reply




MultiQuote





|