Hi,
I am having a problem that I have been wrestling with for 2 solid days and it is driving me mad. I need another set of eyes to look at it.
I simply have two functions. One that retrieves data from a database, and one that displays it. A link is clicked that passes a 'catid' in the querystring to another page with the following code.
$links = getLinks($_REQUEST['catid']);
displayLinks($links);
Here is the code for the 2 functions
function getLinks($catid)
{
if(!$catid || $catid=="")
return false;
$query = "select * from links where catid='$catid'";
$result = @mysql_query($query);
if(!$result)
return false;
$num_links = @mysql_num_rows($result);
if($num_links == 0)
return false;
$result = db_result_to_array($result);
return $result;
}
and
function displayLinks($links)
{
if(!is_array($links))
{
echo '<br>No links currently available in this category<br>';
}
else
{
foreach($links as $row)
{
$url = 'show_links.php?linkid=' .($row['linkid']). ' target=content';
$title = $row["catname"];
do_html_url($url, $title);
}
}
}
For whatever reason, I always get 'No links currently available in this category' when this is not the case. From what I can deduct, getLinks does not recognize 'catid'. You can clearly see the catid passed in the address bar and I can echo it out on the page.
I use two almost identical functions to display the different categories of links (the links that pass the catid) and it works fine. The difference is that getLinks accepts the catid parameter.
There is definitely not a problem with the query or the data either.
I'd appreciate any input 🙂