0

I have tried to use this code but I can get it to work well in my server. When I run the mysql query in mysql it gives me the result that I want but within the code it does not output anything. It just gives a blank page. What can be wrong please.

<?php
if(isset($_GET['page2']))
{
include 'dbconnect.inc';
$year = $_GET['page2'];
$query = "select distinct MONTH(publicationdate) from agricultural_research_journal where year(publicationdate) = '$year' order by id asc";
$result = mysql_query($query) or die('Error, query failed');
$num_result = mysql_num_rows($result);

//to pick the dates
for ($i=0; $i <$num_result; $i++)
{
$story = mysql_fetch_assoc($result);
print '<table width = "385" border="1" align = "center">';
print '<tr>';
print '<td>';echo '$num_result';
$my_date = mysql_result($result, $i);
echo "<a href=month.php?month=$my_date>$my_date</a>";
print '</td>';
print '</tr>';
print '</table>';
}
}
?> 
3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by omoayan
0

Hy,
Try with the $year as number in sql query, without quotes:

$query = "select distinct MONTH(publicationdate) from agricultural_research_journal where year(publicationdate) = $year order by id asc";
0

Thanks I have checked the codes again. I got the codes wrong from the variable aspect. I called $_Get ['page2'] instead of calling for $_Get['year'] which is what I expected from the page I am getting the variable from. Thanks for your suggestions.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.