473,380 Members | 1,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,380 software developers and data experts.

i am trying to setup a link in my page that will change my page

I am working on a page with a right column that I want to use for
navigation. In this right column I am using the below code to set a
value for the link. I am using the variable $test right now.
I want to click on the link and when the value is set to a certain
value, say 1, I want the script to run and load a page based on a
switch case. This way I can use different links for navigation that
will load different forms and areas of my application. So here is the
code for the link line.

printf("<a href=\"%s?test=%s\">%s</a><br>\n", $_SERVER['PHP_SELF'],"1",
"Click Here");

I then want a switch statement to the effect

switch($test) {
case "1" :
Load form1
case "2" :
Load form2
case "3" :
Load form3;
}

To test out my idea I wrote this little test script to see if I could
get the response I wanted and it didn't work. I wanted to click on the
link and then get the value of test to echo back at me on the page.
Here is that code. I called the file testlink.php

<?php

printf("<a href=\"%s?test=%s\">%s</a><br>\n", $_SERVER['PHP_SELF'],"1",
"Click Here");

if (isset($test)){
echo "$test</br>\n";
}
?>
I get the right info in my url in my browser,

http://localhost/testlink.php?test=1

But I don't get the echo on the screen. Can anyone help?

May 17 '06 #1
2 1729
rich wrote:
I am working on a page with a right column that I want to use for
navigation. In this right column I am using the below code to set a
value for the link. I am using the variable $test right now.
I want to click on the link and when the value is set to a certain
value, say 1, I want the script to run and load a page based on a
switch case. This way I can use different links for navigation that
will load different forms and areas of my application. So here is the
code for the link line.

printf("<a href=\"%s?test=%s\">%s</a><br>\n", $_SERVER['PHP_SELF'],"1",
"Click Here");

I then want a switch statement to the effect

switch($test) {
case "1" :
Load form1
case "2" :
Load form2
case "3" :
Load form3;
}

To test out my idea I wrote this little test script to see if I could
get the response I wanted and it didn't work. I wanted to click on the
link and then get the value of test to echo back at me on the page.
Here is that code. I called the file testlink.php

<?php

printf("<a href=\"%s?test=%s\">%s</a><br>\n", $_SERVER['PHP_SELF'],"1",
"Click Here");

if (isset($test)){
echo "$test</br>\n";
}
?>
I get the right info in my url in my browser,

http://localhost/testlink.php?test=1

But I don't get the echo on the screen. Can anyone help?

$test = isset($_GET['test']) ? $_GET['test'] : null;

Add before you first use $test.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 17 '06 #2
Jerry thanks alot. I have been programming PHP for a month now and I
still forget little things. Here is the final code which worked of
course.

<?php
error_reporting(E_ALL ^ E_NOTICE);
$test =$_REQUEST['test'];

printf("<a href=\"%s?test=%s\">%s</a><br>\n", $_SERVER['PHP_SELF'],"1",
"Click Here");

if (isset($test)){
echo "$test</br>\n";
}
?>

May 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: pbj | last post by:
my application was created in vb.net, vs 2003. the setup project was also created in vs 2003. one of my application reviewers reported this: The .Net link that is included in the setup is not the...
1
by: JJ | last post by:
Hi, I have gone the setup project route and added the setup project to my solution as in the guide. I have checked the dependancy's and they all seem to be there. Now do I just build the project...
12
by: Ron Weldy | last post by:
I have a test server runinng 2003/IIS 6 with a mixture of asp and asp.net files. On my workstation I have a share set up to the folder where the web files reside. I am just doing quick and dirty...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
1
by: Andrew | last post by:
I'm adding this as it to me a while to figure out all the pieces to be able to do this without using Microsoft.Office.Interop which caused me problems on the web-server. Streaming is the easy...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
1
by: rsteph | last post by:
I've got some product information pages, with images and text, all setup within a table. I'm trying to add a small image in the upper right hand corner of the content div (where all the important...
12
by: dmorand | last post by:
I'm trying to get a 3 column layout with equal widths. Here is my page: domosworld.net I want it so the two gray borders in the middle always extend to the bottom of the page. I have it setup...
4
by: ARC | last post by:
I have reports that are designed to where it doesn't matter if the region using the program uses a letter sized paper or A4 sized. I have the width to be just slightly over 7", so the reports work...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.