-4

I want pass a variable through AJAX url to another PHP page and get it with:

 $id=$_GET['id'];

This is my link where value is passed for example $id=6.

<a id="pageid" href="ifsc-bank.php?id=<?=$id?>"><img src="images/iconf.png"/> <?=$bank?> </a>

I want to get the value in ifsc-bank.php.

$id=$_GET['id'];

I tried:

pag.ajax({
type: "post",
url: "ifsc-bank.php",
data: {'data':dataString}, 
success: function(ccc)
  {
    pag("#pageid").html(ccc);
  }
});
EM-Creations
  • 4,195
  • 4
  • 40
  • 56
Asesha George
  • 2,232
  • 2
  • 32
  • 68

2 Answers2

0

First thing, you seem to have an incorrect php open tag It is currently:

<?code?>

It should be:

<?php code here ?>

I also think that your ajax call should be more like the following:

$.ajax
({
type: "get",
url: "ifsc-bank.php",
data: {'data':dataString}, 
success: function(ccc)
  {
    $("#pageid").html(ccc);
  }
});

That is if you have not defined jQuery to be pag. Also, if you are trying to find the value of id using "GET", you should add that in your ajax type.

Please do let me know if these suggestions have not fixed the issue. :)

SML
  • 214
  • 2
  • 3
  • 12
  • can you please give us some more details then? – SML Jul 27 '15 at 10:07
  • actually my problem is with pagination i am passing a value through url where id contain value and in php page i am gettting the value by using $_GET['id'] so far so good but is working only for the first page when i click on next or second page its not showing any result i tried by giving direct number to id like $id=5 then its showing related records and its working fine in other pages also . but when i use $id=$_GET['id']; , not working in second page so i thought lets store the value some ware. please see my website www.bankhints.com below you will find bank name click on it – Asesha George Jul 27 '15 at 11:49
  • you can see my code http://stackoverflow.com/questions/31638907/how-to-pass-url-variable-to-next-pages-in-php-pagination – Asesha George Jul 27 '15 at 11:55
0

Thank god thank you all down voters I got my answer the problem is on index.php I have few links on clicking. It will pass a variable link.php?id=8 through the url so hear id=8 passing to second page hear link.php displays all records according to the filter query

 $id=$_GET['id'];

 "select * from table_name where id=".$id "limit";

It's showing 10 records because i set limit 10. now the pagination showing

 1 2 3 4 125 Next Last

on clicking Page 2 its not showing anything because its not passing the id=8 to second page because. i solved it by putting $id=$_GET['id']; before HTML start with small change of code it works

<?php if (isset($_GET["id"]))
 {   
     $_SESSION['page']=$_GET["id"];
     $page = $_SESSION['page'];
 } else {
 $page = $_SESSION['page'];
 $tableName = $page."r";  }   ?>

if you not down voted I keep on searching stackoverflow with out trying it

Thank you all

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Asesha George
  • 2,232
  • 2
  • 32
  • 68