Click here to Skip to main content
15,042,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!
I am new to PHP and I have just a very, very basic knowledge of this language. I want to ask a question of Advanced or Exert Level I think.
My question is that I want to make a php page, in which there are a few news boxes, which are extracted from some information from a database. I have successfully scripted those boxes. But the main thing is their link, that where they will redirect the user. When the user clicks on the box, i want him to be taken to a page where he can read the full news story. But I want it to be just one PHP page that will show al the news stories. In technical words, when the viewer clicks on the box, the box submits the news id to the PHP page where the user will be taken to. Then that PHP page extracts text files of those names and presents them. But the main problem is only the id submission and recognition by the PHP page. I can do the rest of work.
I have the idea that the news boxes will have a unique id which it will pass to the page (like "/news.php?id=50"), but here's what 's the issue:
1. I don't know the HTML link code which will onclick send this id to the page (I know about forms and I have worked with them but don't know to submit something to a page on a single click on a link)
2.I don't know the PHP code which the page will use to identify a news or its id which was submitted to its URL.

Any ideas?

Thanks
Posted

1 solution

Get the PHP manual and look up $_GET. It is an array that gets the stuff after ? in the URL. So if I have a link <a href="path/to/news.php?art=20&size=10&who=xyz">click here</a>, when it is clicked, news.php is called on the server, with $_GET like this:
art => 20
size => 10
who => xyz

news.php can use these to determine what to serve.

Pretty simple, isn't it? (Actually, things are a bit more complicated, but this will get you started.)

Peter

If you like the answer, vote for it, and mark it accepted if it answers your question.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900