MySQL Forums
Forum List  »  PHP

Re: Passing dropdown list value to another SELECT statement on same page
Posted by: Peter Brawley
Date: August 03, 2012 08:22AM

Supposing there are two tables, parent (PK pid, ...) and child (PK cid, FK pid, ...), then at the top you have something like ...

if( isset( $_GET['pid'] )) { 
  $pid = $_GET['pid']; 
  if( $pid != $_SESSION['pid'] ) unset( $_SESSION['cid'] ); 
  $_SESSION['pid'] = $pid; 
} 
elseif( isset( $_SESSION['pid'] )) { 
  $pid = $_SESSION['pid']; 
} 
if( isset( $_GET['cid'] )) { 
  $cid = $_GET['cid']; 
  $_SESSION['cid'] = $cid; 
} 
elseif( isset( $_SESSION['table'] )) { 
  $table = $_SESSION['table']; 
}

Then further down, the query for child rows matching the pid selected by the user in the parent dropdown is...

select ... from child where pid=$pid;

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.