Solved

How do I pass parameters in PHP?

Posted on 2009-07-03
6
299 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now