5 Replies - 23271 Views - Last Post: 14 May 2011 - 07:27 AM Rate Topic: -----

#1 carmelraj  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 50
  • Joined: 28-April 11

passing multiple values through query string in php

Posted 14 May 2011 - 05:24 AM

How to pass multiple values through query string in php..plz explain with example... i want to pass values to more than one page...
Is This A Good Question/Topic? 0
  • +

Replies To: passing multiple values through query string in php

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6110
  • View blog
  • Posts: 23,670
  • Joined: 23-August 08

Re: passing multiple values through query string in php

Posted 14 May 2011 - 05:43 AM

Read a tutorial!
Was This Post Helpful? 0
  • +
  • -

#3 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 948
  • View blog
  • Posts: 2,357
  • Joined: 15-February 11

Re: passing multiple values through query string in php

Posted 14 May 2011 - 05:47 AM

If you want to pass variables to other pages you can do so via SESSIONS.
session_start();
$_SESSION['foo'] = 'bar';


Other Page
session_start();
echo $_SESSION['foo'];


You can even use the GET method of passing variables.
http://www.mysite.com/page.php?foo=bar

<?php
//page.php
$foo = $_GET['foo'];
echo $foo;
?>


using SETCOOKIE
There is also cookies but these are stored on the client's machine and can be use for as long as it doesn't expire or isn't deleted.
setcookie('foo', 'bar', time() + 3600 * 24 * 365, '/'); //this won't expire for a year (365 days)

<?php
//page.php
echo $_COOKIE['foo']; //prints bar
?>

Was This Post Helpful? 1
  • +
  • -

#4 carmelraj  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 50
  • Joined: 28-April 11

Re: passing multiple values through query string in php

Posted 14 May 2011 - 05:51 AM

if (mysql_query($sql))
{
       $add_id=mysql_insert_id();
       
echo "<script>window.location.href='cheque_details.php?adv_id=$add_id&order_id= $order_id&bookingf_no=$bookingf_no'</script>";


}
die('Error: ' . mysql_error());
}



this is the code for passing values through query string.. the values is not passing to another page... i want to pass two values. order_id and bookingf_no

<td>ORDER ID :<input type="text" disabled="disabled" name="order_id" id="order_id" size="3" value="<?php echo $order_id;?>"></td>


<td align=right>BOOKING FORM NO.:<input type="text" name="bookingf_no" size="3" disabled="disabled" value="<?php echo $bookingf_no; ?>"> </td>

Was This Post Helpful? 0
  • +
  • -

#5 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 948
  • View blog
  • Posts: 2,357
  • Joined: 15-February 11

Re: passing multiple values through query string in php

Posted 14 May 2011 - 06:19 AM

A few things
  • Your address isn't suppose to have any spaces in it.
  • Don't use Javascript to redirect a page when you can use PHP
  • On your 2nd page you never assigned your variables with the values in the $_GET array


To redirect a page with PHP use
header("location: page.php");


To build the location string you can do the following
$location = "location: page.php?foo=" . $foo . "&bar=" . $bar;
header($location);


Did you even read my previous post about using $_GET?
Was This Post Helpful? 1
  • +
  • -

#6 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: passing multiple values through query string in php

Posted 14 May 2011 - 07:27 AM

View Postcarmelraj, on 14 May 2011 - 12:51 PM, said:

this is the code for passing values through query string.. the values is not passing to another page... i want to pass two values. order_id and bookingf_no

<td>ORDER ID :<input type="text" disabled="disabled" name="order_id" id="order_id" size="3" value="<?php echo $order_id;?>"></td>


<td align=right>BOOKING FORM NO.:<input type="text" name="bookingf_no" size="3" disabled="disabled" value="<?php echo $bookingf_no; ?>"> </td>

If you mark <input> elements as disabled, they won't be sent with the rest of the form.

If you just want it so the user can't edit them, use the readonly attribute instead.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1