Just need a set of fresh eyes - while()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Just need a set of fresh eyes - while()

Post by LiveFree »

Hey All,

I've been working with the query jCart provided to me (thank you, again) and I cannot see why all I see echoed (other than the table outside of the loop), is "Below Echo Outside of While". I do not see any of the echos that should execute inside the while loop.

I cannot see why that loop is not executing, the functions are correct and everything, could someone talk a look for any simple mistakes I made?

Thanks

(And BTW - It does return the specific amount of results it should, the query is fine, but the output is not outputting)

Code: Select all

global $prefix, $db;
OpenTable();

#Thanks jCart from DevNetwork for this query

$sql = $db->sql_query('
SELECT * FROM `sacom_docs`
INNER JOIN `sacom_docs_access` USING (`docID`)
WHERE `sacom_docs_access`.`groupID` IN ('. implode(', ', array_keys($userinfo['groups'])) .')
  AND `sacom_docs`.`docID` = `sacom_docs_access`.`docID`') OR DIE (mysql_error());

echo "<table width=\"503\" height=\"83\" border=\"0\">
  <tr>
    <th width=\"107\" height=\"23\" bgcolor=\"#000000\" scope=\"col\"><span style=\"color: #FFFFFF; font-weight: bold;\">Download</span></th>
    <th width=\"99\" bgcolor=\"#000000\" scope=\"col\"><span style=\"color: #FFFFFF; font-weight: bold;\">Title</span></th>
    <th width=\"85\" bgcolor=\"#000000\" scope=\"col\"><span style=\"color: #FFFFFF; font-weight: bold;\">Creator</span></th>
    <th width=\"194\" bgcolor=\"#000000\" scope=\"col\"><span style=\"color: #FFFFFF; font-weight: bold;\">Upload Date</span></th>
  </tr>";
echo "Below Echo";
while ($data = $db->sql_fetchrow($sql)) {
 echo "Inside While";
		echo "<tr>
    <td height=\"23\" bgcolor=\"#000000\"><div align=\"center\"><a href='modules/" . $module_name . "/uploads/Documents/" . $data['docFilename'] . "'><img src=\"modules/SACOM/download.gif\" width=\"40\" height=\"40\" /></a></div></td>
    <td bgcolor=\"#000000\">" . $data['docTitle'] . "</td>
    <td bgcolor=\"#000000\">" . $data['docUploader'] . "</td>
    <td bgcolor=\"#000000\">" . $data['docUploadDate'] . "</td>
  </tr>";
  echo "End of While";
}
echo "Outside of While";
echo "</table>";

CloseTable();
Thanks Again
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

Are you sure the result of your query isn't empty?
Post Reply