Hello. I'm new to the community so hello everyone!
I am having some difficulties with my php script. I am trying to generate a list of the latest 10 news topics in my site and code those topic titles to hyperlink to another page, news.php, which will show the entire article. My problem is that when I visit my page, everything looks good except for my dynamic table is blank - there is no data shown, only the column header. I have highlighted the code I editted to transform the table text into hyperlinks. Forgive me if it's something obvious, I'm relatively new to .php and mysql. Below is the code:
<?php require_once('Connections/users.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_news = 10;
$pageNum_news = 0;
if (isset($_GET['pageNum_news'])) {
$pageNum_news = $_GET['pageNum_news'];
}
$startRow_news = $pageNum_news * $maxRows_news;
mysql_select_db($database_users, $users);
$query_news = "SELECT post_title FROM news_posts ORDER BY post_date DESC";
$query_limit_news = sprintf("%s LIMIT %d, %d", $query_news, $startRow_news, $maxRows_news);
$news = mysql_query($query_limit_news, $users) or die(mysql_error());
$row_news = mysql_fetch_assoc($news);
if (isset($_GET['totalRows_news'])) {
$totalRows_news = $_GET['totalRows_news'];
} else {
$all_news = mysql_query($query_news);
$totalRows_news = mysql_num_rows($all_news);
}
$totalPages_news = ceil($totalRows_news/$maxRows_news)-1;
?><link href="../includes/Style.css" rel="stylesheet" type="text/css">
<div class="latest_news_box">
<p>Latest News:<br />
</p>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo "<a href='news.php?post=".$row_news['post_title']."'></a>". "<br />"; ?></td>
</tr>
<?php } while ($row_news = mysql_fetch_assoc($news)); ?>
</table>
</div>
<?php
mysql_free_result($news);
?>