Solved

How do I pass parameters in PHP?

Posted on 2009-07-03
6
303 Views
Last Modified: 2012-05-07
Hi there, I'm a newbie with php and not much of a programmer, I let Dreamweaver do most of the work. I am trying to pass parameters through the URL to load a page within a page for example
aboutus.php?pageid=1 sort of thing.
I have defined the recordset and want to load the content of the page with the corresponding id.
How do I do it?
0
Comment
Question by:cokefour
6 Comments
 
LVL 11

Accepted Solution

by:
BrianMM earned 210 total points
ID: 24771358
OK something like;

if(isset($_REQUEST['pageid']) {
  // code to get the content for that page i.e. do your query with something like SELECT * from table WHERE id = $_REQUEST['pageid']
} else {
  // get some default content i.e. no pageid was passed...
}
0
 
LVL 5

Author Comment

by:cokefour
ID: 24771534
the '{' is throwing errors after [pageid]
0
 
LVL 28

Assisted Solution

by:gamebits
gamebits earned 20 total points
ID: 24771620
if(isset($_REQUEST['pageid']) {

should be

if(isset($_REQUEST['pageid'])) {  

was missing a bracket )
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 4

Assisted Solution

by:stevepicks
stevepicks earned 20 total points
ID: 24771661
try this also
<?php
$pageid= $_GET['pageid']; // or $_POST['pageid']; if u used a form to post variable
switch ($pageid) {
    case 1:
        echo "page = 1";
        break;
    case 2:
        echo "page = 2";
        break;
    default:
       echo "not a known page";
}
?>
0
 
LVL 11

Assisted Solution

by:BrianMM
BrianMM earned 210 total points
ID: 24771908
doh :) typing too quickly as usual :|
0
 
LVL 5

Author Closing Comment

by:cokefour
ID: 31599514
thanks guys
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question