Need help with PHP code
Posted: Sun Oct 26, 2003 3:00 pm
This is my first post in this forum. Let's help the newbie out, OK?
I'm trying to modify the following code to output results only if one particular field is not empty. If the field "complete" has any text at all (is not empty) then I would like the current code to proceed as normal. However, if the "complete" field is empty, I'd like to skip to the next entry in the database in which the "complete" field is again not empty.
Can anyone help out? I'm not trained in PHP at all, but I tinker with confidence.
I'm trying to modify the following code to output results only if one particular field is not empty. If the field "complete" has any text at all (is not empty) then I would like the current code to proceed as normal. However, if the "complete" field is empty, I'd like to skip to the next entry in the database in which the "complete" field is again not empty.
Can anyone help out? I'm not trained in PHP at all, but I tinker with confidence.
Code: Select all
<?php
echo "<p align="left">";
$configfile = "/home/uplandhi/php_configs/news_config.php";
require $configfile;
if (!$pageNum)
{
$pageNum=0;
}
$fullresult = mysql_query("SELECT * FROM ".$table." ORDER BY date DESC",$db);
$numRows = mysql_num_rows($fullresult);
$highNum = ($pageNum+1)*$entriesToPage;
$lowNum = ($pageNum*$entriesToPage);
$numOfPages = $numRows/$entriesToPage;
$numOfPages = ceil($numOfPages);
$actualPageNum = $pageNum+1;
echo "<table width="100%" border="0" cellspacing="0" cellpadding="4">";
$smallresult = mysql_query("SELECT * FROM `$table` ORDER BY `id` DESC LIMIT $lowNum, $entriesToPage",$db);
if ($therow = mysql_fetch_array($smallresult))
{
{
do
{
echo "<tr valign="top">";
echo "<td width="35" background="" class="anndate">";
printf($therowї"date"]);
echo "</td>";
echo "<td background="" class="small"><b>";
printf($therowї"title"]);
echo ": </b>";
printf($therowї"full"]);
echo "</td></tr>";
echo "<tr valign="top">";
echo "<td colspan="2" background="" class="small">";
printf($therowї"complete"]);
echo "</td></tr>";
}
while ($therow = mysql_fetch_array($smallresult));
}
echo "<tr valign="top">";
echo "<td width="35" background="" class="anndate"> </td>";
echo "<td background="" class="small">";
echo "Showing page $actualPageNum of $numOfPages";
echo "</td></tr>";
echo "<tr valign="top">";
echo "<td width="35" background="" class="anndate"> </td>";
echo "<td background="" class="small">";
if($numOfPages>1)
{
if($pageNum!=0)
{
$previousPage = $pageNum-1;
echo "<< <a href="index.php?pageNum=$previousPage">Previous</a> ";
}
$countPages=1;
do
{
$goToPage=$countPages-1;
if($countPages==$actualPageNum)
{
echo " <b>$countPages</b> ";
}
else
{
echo " <a href="index.php?pageNum=$goToPage">$countPages</a> ";
}
$countPages++;
}
while($countPages<=$numOfPages);
if($numOfPages-1!=$pageNum)
{
$nextPage = $pageNum+1;
echo " <a href="index.php?pageNum=$nextPage">Next</a> >>";
}
}
}
else
{
echo "There were no records";
}
echo "</td></tr>";
echo "</table>";
?>