Struggling With Get on Receiving Page


I am trying to try echo an article column on a page called article.php based on the ID of an item which is inserted into a link from the previous page. However, I am struggling to show the article. I can only echo the ID.

Previous page:

<a href=“article.php?ID=<?php echo $row[‘ID’]; ?>”><?php echo $row[‘title’]; ?></a>

Article Page:

<?php echo $_GET['ID'];?>
  • This works as it shows the ID
<?php echo $_GET['article'];?>
  • This does not work as it does not show the article.

The variable $_GET[‘article’] to return someting, you should have " article.php?ID=id&article=something " in URL address.

Thanks, I have done that so I have echoed all the columns into the link.

Is there code I can use to just echo the ID into the link? This is what I am trying to do.

Your previous page link did not include the value for article so you would get nothing when you echo it.

Do what MarPlo suggested then you should get the value if that is what you want.

For example, if $row[‘title’] is your article then you could do something like this:

<?php echo ‘<a href="article.php?ID=’.$row[‘ID’].‘&article=’.$row[‘title’].‘">’.$row[‘title’].‘</a>’; ?>

Thanks, I have done this but is there a way of echoing the information by just inserting the ID into the link?

I’m not quite sure what you have in mind. Is the information store in a database? If so you could simply retrieve the content from the database based on the ID and display it using echo.


Yes the information is stored in a database, but I dont know how to retreive the information to display it. Do I need to query the database to retrieve the information, if so do you know what code I need to do this please?

Yes you would. Sound as if you are new with this so I think best to start by learning a bit about database as well as PHP since this will be the language you use. Take a look at this tutorial and see if it helps. MySQL is used for the tutorial. If your database is not that then just Google it and I’m sure you will find them too. Post up additional info about your site if you could. Perhaps other members will offer suggestions.

Many thanks, I have been watching a number of YouTube videos. I shall also read through this.

The frustrating thing is I can echo everything if I put it into the URL such as this article.php?ID=<?php echo $row[‘ID’]; ?>&content=<?php echo $row[‘content’]; ?>…

It does work but it looks messy.

But if I use just the ID article.php?ID=<?php echo $row[‘ID’]; ?> I cant work out how to echo the content.

Is there some form of query I need to carry out?

For what you need , you must perform a Select in the database to get the row with data associated to that ID.

$sql = "SELECT * FROM table_name WHERE ID =". intval($_GET['ID']]). " LIMIT 1";

Than execute this query, and echo $row[‘article’] .
Well, try learn about mysql and php if you work with database, here’s a tutorial about Select PHP-MySQLi.

The frustrating thing is I can echo everything if I put it into the URL such as this article.php?ID=<?php echo $row[‘ID’]; ?>&content=<?php echo $row[‘content’]; ?>…

Can you give us the links to what you’re talking about?


Ive been working on this for nearly 4 hours today and it still wont work!

This is my link…


This is my code on article.php…


$query = mysql_query(“SELECT * FROM articles ORDER BY ID DESC LIMIT 15”);
while($row = mysql_fetch_array($query)) {

These are my echoes, I am trying both Get and Row.

<?php echo $_GET[‘title’];?>
<?php echo $row[‘intro’]; ?>

Does anyone have a basic guide on how to echo information use the Get Command?

The link I’m referring to is the one you enter on the browser’s address bar. For example:


Yes its…

It goes onto article.php but I cant echo the content.

This is the code I use to enter the ID <a href=“article.php?ID=<?php echo $row[‘ID’]; ?>”

If enter everything into the link then I can each it on the following page:

<a href=“article.php?ID=<?php echo $row[‘ID’]; ?>”

If echo everything into the link then I can display it on the following page but it should be done with just the ID but I dont know how to do this.


I now have the following code but it says: Invalid query: Query was empty


$sql = "SELECT * FROM articles WHERE '". mysql_real_escape_string($ID) ."'";
$rs = mysql_query($strSQL);

if (!$strSQL) { // add this check.
die('Invalid query: ' . mysql_error());


// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
while($row = mysql_fetch_array($rs)) {

  echo $row['title'] . "&lt;br /&gt;";