Getting null in fetching high values from mysql table

Hi, I am using a code to fetch values from the database using php code in Html format. but i am facing a problem while fetching table having more than 1000 rows that giving the result “Null”, but for lesser rows table this code working fine.
Here is the code…
<?php
include(“repo_db.php”);
$query=mysql_query(“Select * from tbl_coupons”) or die(mysql_error());
if(!$query) { mysql_close();
echo json_encode("There was an error running the query: " . mysql_error());
}
else if(!mysql_num_rows($query))
{
mysql_close();
echo json_encode(“No result return!”);
}
else
{
$header = false;
$output_string = “Production Details By Customer Name”; $output_string .= "
";
while($row = mysql_fetch_assoc($query))
{
if(!$header)
{
$output_string .= "
";
foreach($row as $header => $value) { $output_string .= "{$header}
";
}
$output_string .= "
";
}
$output_string .= "
";
foreach($row as $value)
{
$output_string .= "{$value}
";
}
$output_string .= "
";
}
$output_string .= "
";
}
mysql_close();
// This echo for jquery
echo json_encode($output_string);
?>
Can anyone suggest the problem solution.
Thanks