Solved

How do I pass parameters in PHP?

Posted on 2009-07-03
6
305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

733 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