Im new to php. Im trying to display data via url. (example) www.mySite.com/usercomment?user_id=1. I would like to let users retreive data by having to type in specific url. Not pageing through data. Any comments, suggestions would be appreciated

Recommended Answers

All 2 Replies

You can get PHP parameters (the things after the ?), by using $_GET. In your case you'd go:

$variable = $_GET["user_id"];

Unless I got your question wrong and you're asking something else?

Member Avatar for diafol

Im new to php. Im trying to display data via url. (example) www.mySite.com/usercomment?user_id=1. I would like to let users retreive data by having to type in specific url. Not pageing through data. Any comments, suggestions would be appreciated

What do you mean 'type in an url'. The url given as an example contains a 'querystring' - a list of parameter-value pairs. Don't have your users type this as they probably wouldn't know what to type. These urls are usually pre-written into links. THe previous post mentions using $_GET to retrieve the value - this is correct. However, you could get a nasty error unless you check for its existence first:

if(isset($_GET['user_id'])){
   $user_id = $_GET['user_id'];
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.