Problem while fetching latest news section

I am in a problem that when i click on the heading of the news then it shows the whole news on next page but when i again click on the same or any other heading on that page then it shows an error like undefined index: ‘id’.
Here is my fetching code of heading where i have to click:

                         <?php
		   include_once("config.php");
		    $query2="select * from news";
                   $rid2=mysql_query($query2);
		    echo"<table cellspacing='4' cellpadding='3'>";
				while($temp=mysql_fetch_array($rid2))
				{
				
               echo"<tr>";

;
echo"<td><a href=‘news.php’>“.$temp[‘heading’].”</a></td>";

                echo"&lt;/tr&gt;";			
				}
            echo"&lt;/table&gt;";
			?&gt;

And this is the fetching of news when i clicked on heading:

                          &lt;?php
			 include_once("config.php");
			 $i=$_REQUEST['id'];
			 $m="select * from news where heading='$i'";
			 $n=mysql_query($m);
			 while($row=mysql_fetch_array($n)){
			  echo"&lt;h3&gt;".$row['news']."&lt;/h3&gt;";
			 }
                                 ?&gt;

Please suggest me.

I can’t see how the news.php code ever knows what ID to open up, as you don’t seem to pass it in your code. Shouldn’t it read something like:


<?php
  include_once("config.php");
  $query2="select * from news";
  $rid2=mysql_query($query2);
  echo"<table cellspacing='4' cellpadding='3'>";
  while($temp=mysql_fetch_array($rid2))
    {
    echo"<tr>";
    echo"<td><a href='news.php?id='" . $temp['heading'] . "' >".$temp['heading']."</a></td>";      echo"</tr>";
    }
  echo"</table>";
  ?>

your code shows blank page.
But now i got it.
Thank you for your reply
Its like this
<a href='news.php?id=“.$temp[‘heading’].” '>“.$temp[‘heading’].”</a>

Can you please post the code as it stands?

Please be aware that the mysql_* extension is now deprecated as of the current version of PHP and will very likely be removed from the next 5.x version and will likely not be in PHP 6.x (when it eventually is released). You should migrate over to either the mysqli_* extension or to PDO. PDO is a better choice as it doesn’t tie you down so much to a particular database server software.

Once you have migrated you should use Prepared Statements to prevent SQL Injection attacks. Have a read of this article from the PHP manual, it shows how to use prepared statements with PDO and also explains the principle.