0

I have a question in PHP.

I have a website thats hold news from mysql the (title, date, author, description) everything works fine, I have a page when which the user click on the title he go readmore.php?id=10 (for example)

Now my question is how to make to read the full story in one single page

for example index.php?id=10, I don't want to send in the readmore.php page, I want in one single page, how can I make this ?

4
  • Add whatever you put in readmore.php to index.php? Commented Jan 17, 2011 at 18:35
  • Yes right, when I click I can read but the other news stay in the top of my full story, can you understand? Commented Jan 17, 2011 at 18:36
  • someone with editing privilege pls. reword the question. Commented Jan 17, 2011 at 18:47
  • You got several proper answers, please mark one as such :) Commented Jan 18, 2011 at 6:26

5 Answers 5

2
check there is **id** querystring .
if(isset($_GET["id"]))
{
     // show news which belongs to **id**
}
else
{
     // list all news
}

But don't forgot validating $_GET["id"] variable. For example, if ids only numeric, you can check use *is_numeric();* etc.

Sign up to request clarification or add additional context in comments.

Comments

1

It really depends on your current scripts but maybe you can modify the readmore.php page to only send the body of the page and then require ("readmore.php"); in your index.php where you need the full story, if the parameter (id) is the same. Then you can use something to show/hide the full body of the news in a div, in example.

Comments

0

you can use a jquery plugin for that, for example jQuery Expander Plugin

1 Comment

Yes @mdaguerre this is a great tool, but I mean in PHP
0

maybe you could send a get variable like: index.php?id=10&full=1. So, if full == 1 in index.php yo can show all the news, else cut the news with substr()

Comments

0

url like so:

index.php <- normal news page
index.php?readstory=10 <- will display story with id 10

in index.php

if(isset($_GET['readstory'])) {
  $story_id = $_GET['readstory'];
  display_story($story_id);
}
else {
  display_news();
}

2 Comments

can you write the functions (display_story) and (display_news)
No, that's the php code you'll run to render your story or your normal index page :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.