954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

href links with variables?

I'm not entirely sure if this is actually possible. Haven't found anything yet. What I'd like to do is have a page that lists numerous articles. Then when you click on the "Read more..." link I want to go through to a template page that would pull all the info from the MySQL database for that particular artical and display it.

If this isn't possible could someone suggest something else that might work in a similar fashion.

if ($_REQUEST('is_answered') {
  $reward = $_POST['cookie'];
  $user = $reward;
}


;)

Venom Rush
Posting Whiz
353 posts since Oct 2007
Reputation Points: 31
Solved Threads: 2
 

Well in the database you would store the page name/page ID as well as the actual page in a largetext or memo field. When the page is requested by name/ID you would simply pull it from the database and display it, ie., <a href="page?id=25018">Read more...</a>

ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 

This is a very simple example, but you can build on it:

I am sure you know how get works, but ill put it here anyway, this link sets $_GET['article'] to 1001 on my localhost: http://localhost/testing/test07.php?article=1001

mysql_select_db("testbase") or die(mysql_error());
$query=mysql_query("
	SELECT info 
	FROM articles
	WHERE article_id='" . $_GET['article'] . "'");
while($entry=mysql_fetch_array($query))
	{
	echo $entry['info'];
	}
echo "</select>";
?>


If you need further explanation just ask

hooray
Junior Poster in Training
62 posts since Jan 2008
Reputation Points: 11
Solved Threads: 6
 

Ok, I'm not sure if I understand this correctly but let me explain a little more on what I have.

At the moment I have a page that fetches the article id($aid), article title($title) and the article content($content) and displays a short summary of the content along with the title and a "Read more..." href link for each and every article in the database. Then I have a template page that has the MySQL query that would select a single article and display the entire thing on the page. So all I really need to know is how to tie them both together so that if someone clicks on "Read more..." for a particular article it will take him/her to template.php and display the article they're looking for.

My understanding from your response's so far would be to set each href as:

<a href="template.php?aid=$aid">Read more...</a>
Venom Rush
Posting Whiz
353 posts since Oct 2007
Reputation Points: 31
Solved Threads: 2
 

yes, but you would have to do that in php as $aid is a php variable, so it would be:

<?php
echo "<a href='template.php?aid=" . $aid . "'>Read more...</a>";
?>


OR

<a href="template.php?aid=<?php echo $aid; ?>">Read more...</a>


This would mean $_GET['aid'] would be equal to $aid

hooray
Junior Poster in Training
62 posts since Jan 2008
Reputation Points: 11
Solved Threads: 6
 

Awesome...thanks so much guys....much appreciated.

Venom Rush
Posting Whiz
353 posts since Oct 2007
Reputation Points: 31
Solved Threads: 2
 

you are most welcome :)

hooray
Junior Poster in Training
62 posts since Jan 2008
Reputation Points: 11
Solved Threads: 6
 

yes, but you would have to do that in php as $aid is a php variable, so it would be:

<?php
echo "<a href='template.php?aid=" . $aid . "'>Read more...</a>";
?>

OR

<a href="template.php?aid=<?php echo $aid; ?>">Read more...</a>

This would mean $_GET['aid'] would be equal to $aid


MMMWwwwwaaahhh!! I love you :D

masala_curry
Newbie Poster
4 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You