| | |
href links with variables?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
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 this isn't possible could someone suggest something else that might work in a similar fashion.
php Syntax (Toggle Plain Text)
if ($_REQUEST('is_answered') { $reward = $_POST['cookie']; $user = $reward; }
This user has a spatula. We don't know why, but we are afraid.
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> GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
•
•
Join Date: Jan 2008
Posts: 62
Reputation:
Solved Threads: 6
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
If you need further explanation just ask
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
php Syntax (Toggle Plain Text)
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
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:
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:
html Syntax (Toggle Plain Text)
<a href="template.php?aid=$aid">Read more...</a>
Last edited by Venom Rush; Jan 21st, 2008 at 10:41 am.
This user has a spatula. We don't know why, but we are afraid.
•
•
Join Date: Jan 2008
Posts: 62
Reputation:
Solved Threads: 6
yes, but you would have to do that in php as $aid is a php variable, so it would be:
OR
This would mean $_GET['aid'] would be equal to $aid
php Syntax (Toggle Plain Text)
<?php echo "<a href='template.php?aid=" . $aid . "'>Read more...</a>"; ?>
OR
PHP Syntax (Toggle Plain Text)
<a href="template.php?aid=<?php echo $aid; ?>">Read more...</a>
This would mean $_GET['aid'] would be equal to $aid
Last edited by hooray; Jan 21st, 2008 at 11:00 am. Reason: added another example
•
•
Join Date: Aug 2008
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
yes, but you would have to do that in php as $aid is a php variable, so it would be:
php Syntax (Toggle Plain Text)
<?php echo "<a href='template.php?aid=" . $aid . "'>Read more...</a>"; ?>
OR
PHP Syntax (Toggle Plain Text)
<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
![]() |
Similar Threads
- Open In New Window Php (PHP)
- Help with changing variables in links (PHP)
- Do You Know Sessions! HELP PLEASE! (PHP)
- [Revised] vBulletin Mod_rewrite Tutorial (PHP)
- Parse XML from ASP!!! (ASP)
- PHP Variables (PHP)
- Please Help!!! MOD function (ASP)
Other Threads in the PHP Forum
- Previous Thread: Syntax Errors, Variables & Query, Oh my!
- Next Thread: flash player
Views: 6988 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery js limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube






