473,395 Members | 1,797 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,395 software developers and data experts.

problem with sending value to php page via url - HELP!

Hi!

i have php page that displays records from mysql base.
on that page i have link like this:

<a href="mypage.php?option1">option1</a>

("option1" is name of one of my tables in db)

now i want to load that page and assign this value "option1" as string to
my variable "table".
I tried this:
$table=$_SERVER['QUERY_STRING'];
$query_rs_komp = "SELECT * FROM " . $table;

but it fills my $table var with "database.option1", and i need only
"option1"

Also i'll need help with checking if anything was sent to page anyway - so
if it's first time someone opens page, default value is assigned to var
$table.

please if anyone has idea?
Jul 17 '05 #1
5 1874
ToMeK wrote:
i have php page that displays records from mysql base.
on that page i have link like this:

<a href="mypage.php?option1">option1</a>
<a href="mypage.php?db=option1">option1</a>
("option1" is name of one of my tables in db)

now i want to load that page and assign this value "option1" as string to
my variable "table".
I tried this:
$table=$_SERVER['QUERY_STRING'];
$table = isset($_GET['db']) ? $_GET['db'] : 'default_table';
$query_rs_komp = "SELECT * FROM " . $table;

but it fills my $table var with "database.option1", and i need only
"option1"

Also i'll need help with checking if anything was sent to page anyway - so
if it's first time someone opens page, default value is assigned to var
$table.


HTH
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2
In article <2g************@uni-berlin.de>, Pedro Graca wrote:
ToMeK wrote:
i have php page that displays records from mysql base.
on that page i have link like this:

<a href="mypage.php?option1">option1</a>


<a href="mypage.php?db=option1">option1</a>
("option1" is name of one of my tables in db)

now i want to load that page and assign this value "option1" as string to
my variable "table".
I tried this:
$table=$_SERVER['QUERY_STRING'];


$table = isset($_GET['db']) ? $_GET['db'] : 'default_table';


If the man requests page.php?option $_GET will be empty.
But when i test here, $_SERVER['QUERY_STRING'] contains 'option'

With page.php?option=page1 will fill $_GET['option'] with 'page1'
--
http://home.mysth.be/~timvw
Jul 17 '05 #3
"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2g************@uni-berlin.de...
In article <2g************@uni-berlin.de>, Pedro Graca wrote:
ToMeK wrote:
i have php page that displays records from mysql base.
on that page i have link like this:

<a href="mypage.php?option1">option1</a>
<a href="mypage.php?db=option1">option1</a>
("option1" is name of one of my tables in db)

now i want to load that page and assign this value "option1" as string to my variable "table".
I tried this:
$table=$_SERVER['QUERY_STRING'];


$table = isset($_GET['db']) ? $_GET['db'] : 'default_table';


If the man requests page.php?option $_GET will be empty.
But when i test here, $_SERVER['QUERY_STRING'] contains 'option'


thanks it looks like my mistake... wrong table name.
it really contains "option"
- how can i check if there is value in query string, and if there's none,
use default table?

With page.php?option=page1 will fill $_GET['option'] with 'page1'
--
http://home.mysth.be/~timvw

Jul 17 '05 #4
thanks it looks like my mistake... wrong table name.
it really contains "option"
- how can i check if there is value in query string, and if there's none,
use default table?


There are different ways of checking, this just checks to see if there is
any value at all and if not, sets it.

if (!$_SERVER['QUERY_STRING']) { $default_table = "default_value"; }
Jul 17 '05 #5
In article <c7**********@ls219.htnet.hr>, ToMeK wrote:
"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2g************@uni-berlin.de...
In article <2g************@uni-berlin.de>, Pedro Graca wrote:
> ToMeK wrote:
>> i have php page that displays records from mysql base.
>> on that page i have link like this:
>>
>> <a href="mypage.php?option1">option1</a>
>
><a href="mypage.php?db=option1">option1</a>
>
>> ("option1" is name of one of my tables in db)
>>
>> now i want to load that page and assign this value "option1" as string to >> my variable "table".
>> I tried this:
>>
>>
>> $table=$_SERVER['QUERY_STRING'];
>
> $table = isset($_GET['db']) ? $_GET['db'] : 'default_table';


If the man requests page.php?option $_GET will be empty.
But when i test here, $_SERVER['QUERY_STRING'] contains 'option'


thanks it looks like my mistake... wrong table name.
it really contains "option"
- how can i check if there is value in query string, and if there's none,
use default table?


If you looked carefully at the code, you would have noticed that there
was a isset function in use.

--
http://home.mysth.be/~timvw
Jul 17 '05 #6

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

Similar topics

3
by: TekWiz | last post by:
I've got a system that automatically generates a form. I have it set up so that the backend will return to the inital form page with an error object in sessions data (assuming the backend detected...
2
by: Kingdom | last post by:
I have a SelectBoxes.asp page that is working with multiple selection dropdown boxes to extract data and total the selection prices. Tom & Bob were kind enough to give me a big help getting this...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
5
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I...
5
by: wktarin | last post by:
Hi. I'm a relative newcomer to the world of php, and I keep bumping into a problem with a mail () form. I need to send an automatic email to two addresses, but I can't seem to get it to work. One...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.