Hello,
pls help me with my code...

I was able to output the database table on my page. It goes for example like this:


id | name | etc...
----------------------
01 | john | etc...

02 | mike | etc...


The "ID" is a link (a href).
Once click, it will popup a window with the information of the students.

How can I get a specific row in the database if they were output using while loop like this:

<?php
global $connection;
$query = "SELECT bookingDate, request_id, destination, request_by FROM tbl_tour_request 
          ORDER BY `tbl_tour_request`.`bookingDate` DESC ";
$result = mysql_query($query);
confirm_query($result);
$num = mysql_num_rows($result);

$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"bookingDate");
$f2=mysql_result($result,$i,"request_id");
$f3=mysql_result($result,$i,"destination");
$f4=mysql_result($result,$i,"request_by");
?>
    <tr>
        <td>&nbsp; <h3><?php echo $f1; ?></h3> </td>
        <td>&nbsp; <h3><a href="" ><?php echo $f2; ?></h3></a> </td>
        <td>&nbsp; <h3><?php echo $f3; ?></h3> </td>
        <td>&nbsp; <h3><?php echo $f4; ?></h3> </td>
      
    </tr>
<?php $i++;} ?>
</table>

Pls help...
Thanks alot!

either change your query and add in a where clause:
...tbl_tour_request where id = $id order by...
which should just pull the specific row you are looking for since you have the 'id' already set coming in from your link.
or inside your while statement nest an if();

while ($i < $num) {
     // would only print the 1 row associated with $id.
     // although, I'm not sure if request_id is the same as the id from your table
     if ($id == $f2) {  
          //print your student info
          <tr>
          <td>&nbsp; <h3><?php echo $f1; ?></h3> </td>
          <td>&nbsp; <h3><a href="" ><?php echo $f2; ?></h3></a> </td>
          <td>&nbsp; <h3><?php echo $f3; ?></h3> </td>
          <td>&nbsp; <h3><?php echo $f4; ?></h3> </td>
          </tr>
     }
}

either change your query and add in a where clause:
...tbl_tour_request where id = $id order by...
which should just pull the specific row you are looking for since you have the 'id' already set coming in from your link.
or inside your while statement nest an if();

while ($i < $num) {
     // would only print the 1 row associated with $id.
     // although, I'm not sure if request_id is the same as the id from your table
     if ($id == $f2) {  
          //print your student info
          <tr>
          <td>&nbsp; <h3><?php echo $f1; ?></h3> </td>
          <td>&nbsp; <h3><a href="" ><?php echo $f2; ?></h3></a> </td>
          <td>&nbsp; <h3><?php echo $f3; ?></h3> </td>
          <td>&nbsp; <h3><?php echo $f4; ?></h3> </td>
          </tr>
     }
}

thats my problem...
I know how to select specific row in mysql.
But to select a link-data that was looped... how?

is there such code that if you select a link, the value of that link will be pass to a variable, and that variable will be use for querying/searching for the data?

This is more of an ajax question.
here is a quick walk through, you can use onclick in your a href tag and call a function. look at page 2 of this tutorial:
http://www.w3schools.com/Ajax/ajax_example.asp
will show you how to send data to another page, retrieve it (you can then build your user object off the id). if this is what you are trying to accomplish. I don't fully understand your goal.

This is more of an ajax question.
here is a quick walk through, you can use onclick in your a href tag and call a function. look at page 2 of this tutorial:
http://www.w3schools.com/Ajax/ajax_example.asp
will show you how to send data to another page, retrieve it (you can then build your user object off the id). if this is what you are trying to accomplish. I don't fully understand your goal.

sorry if my explanation is not clear...

my goal is... once I click a 'a href tag', it will it will give me that code I click and store it into a php variable.

ex:
id | name | age
----------------------
01 | john | 5

02 | mike | 8

03 | jimm | 9

when I click a href tag '01', I will get the row of table whose id = '01'. And after getting, put it into a php variable.

pls still help me..
thanks..

// there are other ways, but this should do the trick for you
function decision(url){
	window.open(url);
}
// and then on your around your id tag..
echo "<a href=\"javascript:decision('popup.php?id=$id&action=lookup');\"> $id</a>";
// then on popup.php... (or whatever you name your page you can retrieve your //variabes in a $_GET
if($_GET['action']=='lookup' & $_GET['id']!="") {
   echo "GET ACTION ==".$_GET['action']." and GETid = " . $_GET['id']. "<br>";
   $id = $_GET['id'];
   // connection code etc...
   // query code
   //mysql_query("select * from table where id = " . $id);
   // result set from query
   // display stuff.
} else {
    echo "could not lookup data you must pass in an id<br>";
}

this is very simple php / javascript coding.
things can be very complex but I always try to keep my code simple.

Hi! thanks for the reply...

I saw that it was getting the id number I need and put it in the url.
The problem is, when I redirected to the popup page, I got this error:

Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server. If you think this is a server error, please contact the webmaster.
Error 403

Here is the code...
while ($i < $num) {
$f1=mysql_result($result,$i,"bookingDate");
$f2=mysql_result($result,$i,"request_id");
$f3=mysql_result($result,$i,"destination");
$f4=mysql_result($result,$i,"request_by");
?>
    <tr>
        <td>&nbsp; <h3><?php echo $f1; ?></h3> </td>
        <td>&nbsp; <h3><?php echo "<a href=\"javascript<b></b>:decision('booking_request_popup.php?request_id=$f2&action=lookup');\"> $f2</a>"; ?></h3> </td>
        <td>&nbsp; <h3><?php echo $f3; ?></h3> </td>
        <td>&nbsp; <h3><?php echo $f4; ?></h3> </td>
     
    </tr>
<?php $i++;} ?>
</table>

booking_request_popup.php code...

<?php require_once("../includes/session.php");?>
<?php require_once("../includes/connection.php");?>
<?php require_once("../includes/functions.php");?>
<?php confirm_logged_in_admin(); ?>
<?php confirm_if_admin(); ?>

//some code here

<?php
if($_GET['action']=='lookup' & $_GET['request_id']!="") {
   echo "GET ACTION ==".$_GET['action']." and GETid = " . $_GET['request_id']. "<br>";
   $id = $_GET['request_id'];

			$query = "SELECT * FROM tbl_tour_request 
					  WHERE request_id = '$id'";
			$result = mysql_query($query);
			
			$row = mysql_fetch_row($result);
			echo $row[0]; 
			echo $row[1]; 

} else {
    echo "could not lookup data you must pass in an id<br>";
} ?>

I have another concern...we're dealing with "id numbers".
Is it safe to use "get"? Can I use "post" instead?

another concern again... the Id number we get will also be use to delete row.

ex:
id | name | age
----------------------
01 | john | 5 delete
02 | mike | 8 delete
03 | jimm | 9 delete

so to get the id number is really vital. should it still be pass to the url if this is the case?


sorry for bugging you...
thankyou for you concern...

yes, but that is an ajax call that needs to be made. I will look into it tomorrow and update in the morning. I've just done this exact issue for like 3 other people so I have the code but it is at work and I am at home. later brother...
when you get a chance... if you would like some elegant class code to handle all of your data transactions with the database and easily pass objects of your table and have re-usable code post a mysql dump of your table structure so I can clone your database on my server. no data. just structure. I'll teach you a valuable lesson if you would like to learn. I see you have posted quite a few questions lately. I can show you a completely different approach that you can build on always moving forward.

yes, but that is an ajax call that needs to be made. I will look into it tomorrow and update in the morning. I've just done this exact issue for like 3 other people so I have the code but it is at work and I am at home. later brother...
when you get a chance... if you would like some elegant class code to handle all of your data transactions with the database and easily pass objects of your table and have re-usable code post a mysql dump of your table structure so I can clone your database on my server. no data. just structure. I'll teach you a valuable lesson if you would like to learn. I see you have posted quite a few questions lately. I can show you a completely different approach that you can build on always moving forward.

Im happy to see your post!
My database is 'hatsdb' and the table inside it is 'tbl_tour_request'

-- phpMyAdmin SQL Dump
-- version 3.1.3.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Aug 18, 2011 at 10:35 PM
-- Server version: 5.1.33
-- PHP Version: 5.2.9

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `hatsdb`
--

-- --------------------------------------------------------

--
-- Table structure for table `tbl_tour_request`
--

CREATE TABLE IF NOT EXISTS `tbl_tour_request` (
`request_id` int(11) NOT NULL AUTO_INCREMENT,
`subject_name` varchar(250) NOT NULL,
`subject_code` int(50) NOT NULL,
`subject_overview` text NOT NULL,
`destination` varchar(250) NOT NULL,
`expected_num_participants` int(250) NOT NULL,
`prefDate` date NOT NULL,
`tour_objectives` text NOT NULL,
`seminar_topic` varchar(250) NOT NULL,
`seminar_speaker` varchar(250) NOT NULL,
`service_classification` varchar(50) NOT NULL,
`activities` text NOT NULL,
`budget_per_student` decimal(50,0) NOT NULL,
`additionalConcern` text NOT NULL,
`request_by` varchar(250) NOT NULL,
`applicant_id` int(11) NOT NULL,
`bookingDate` date NOT NULL,
`bookingTime` time NOT NULL,
PRIMARY KEY (`request_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10025 ;

--
-- Dumping data for table `tbl_tour_request`
--


Thanks ALOT :D

yes, but that is an ajax call that needs to be made. I will look into it tomorrow and update in the morning. I've just done this exact issue for like 3 other people so I have the code but it is at work and I am at home. later brother...
when you get a chance... if you would like some elegant class code to handle all of your data transactions with the database and easily pass objects of your table and have re-usable code post a mysql dump of your table structure so I can clone your database on my server. no data. just structure. I'll teach you a valuable lesson if you would like to learn. I see you have posted quite a few questions lately. I can show you a completely different approach that you can build on always moving forward.

I waited all day for your reply...
So how is it? :)

sorry,man, different time zones. it is 10:45 am here. I am working on some codes for you, I generated a class and just came back to consult your question so I can come up with the codes for an answer.

do you use jQuery or any javascript library? I'm asking because jquery ajax is pretty, and I have to make you some sort of ajax function to do that post.

ok, going back to basics here. I need you to test out the class code as I have no data to play with. dont be overwhelmed, name the class tour_request.class.php
and save it in the same directory as your form page for now.
yes, it's about a thousand lines long it came from a generator.
go to line 851 and look at that code. (set your db host as well at top of file)
right now that is the only code (besides the get/set methods) that you need for first request of data. then look at select_by_id($id) (line 731) we will use that for the second specific lookup of an id when they click on your form.
tour_request.class.php

<?php
// begin generated class -->
/*
* -------------------------------------------------------
* CLASSNAME:        tour_request
* GENERATION DATE:  19.08.2011
* CLASS FILE:       C:\wamp\www\PHP_LIB\sql_class_generator\generated_classes\tour_request.class.php
* FOR MYSQL TABLE:  tbl_tour_request
* FOR MYSQL DB:     test
* -------------------------------------------------------
* CODE GENERATED BY:
* MY PHP-MYSQL-CLASS GENERATOR
* from: >> www.voegeli.li >> 
* CLASS MODIFIED AND EXTENDED BY:
* dmd
* -------------------------------------------------------
*/
// Define your database connection parameters here.  
define(DB_HOST,'localhost');
define(DB_USER,'root');
define(DB_PASS,'');
define(DB_BASE,'hatsdb');
// **********************
// CLASS DECLARATION
// **********************
// class : begin
class tour_request { 
// **********************
// ATTRIBUTE DECLARATION
// **********************
	var $request_id;   // KEY ATTR. WITH AUTOINCREMENT
	var $subject_name;   // (normal Attribute)
	var $subject_code;   // (normal Attribute)
	var $subject_overview;   // (normal Attribute)
	var $destination;   // (normal Attribute)
	var $expected_num_participants;   // (normal Attribute)
	var $prefDate;   // (normal Attribute)
	var $tour_objectives;   // (normal Attribute)
	var $seminar_topic;   // (normal Attribute)
	var $seminar_speaker;   // (normal Attribute)
	var $service_classification;   // (normal Attribute)
	var $activities;   // (normal Attribute)
	var $budget_per_student;   // (normal Attribute)
	var $additionalConcern;   // (normal Attribute)
	var $request_by;   // (normal Attribute)
	var $applicant_id;   // (normal Attribute)
	var $bookingDate;   // (normal Attribute)
	var $bookingTime;   // (normal Attribute)

// **********************
// CONSTRUCTOR METHOD
// **********************
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- constructor
	* @param - tour_request
	* @return - Instance of $class
	* @vers	- 1
	* @Mod - 
	**/
	function tour_request() {
		
	}
// **********************
// GETTER METHODS
// **********************
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_request_id()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_request_id() {
		return $this->request_id;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_subject_name()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_subject_name() {
		return $this->subject_name;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_subject_code()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_subject_code() {
		return $this->subject_code;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_subject_overview()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_subject_overview() {
		return $this->subject_overview;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_destination()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_destination() {
		return $this->destination;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_expected_num_participants()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_expected_num_participants() {
		return $this->expected_num_participants;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_prefDate()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_prefDate() {
		return $this->prefDate;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_tour_objectives()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_tour_objectives() {
		return $this->tour_objectives;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_seminar_topic()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_seminar_topic() {
		return $this->seminar_topic;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_seminar_speaker()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_seminar_speaker() {
		return $this->seminar_speaker;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_service_classification()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_service_classification() {
		return $this->service_classification;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_activities()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_activities() {
		return $this->activities;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_budget_per_student()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_budget_per_student() {
		return $this->budget_per_student;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_additionalConcern()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_additionalConcern() {
		return $this->additionalConcern;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_request_by()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_request_by() {
		return $this->request_by;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_applicant_id()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_applicant_id() {
		return $this->applicant_id;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_bookingDate()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_bookingDate() {
		return $this->bookingDate;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- get variable value
	* @param - get_bookingTime()
	* @return - variable
	* @vers	- 1
	* @Mod - 
	**/
	function get_bookingTime() {
		return $this->bookingTime;
	}
	// **********************
	// SETTER METHODS
	// **********************
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_request_id($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_request_id($val) {
		$this->request_id = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_subject_name($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_subject_name($val) {
		$this->subject_name = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_subject_code($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_subject_code($val) {
		$this->subject_code = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_subject_overview($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_subject_overview($val) {
		$this->subject_overview = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_destination($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_destination($val) {
		$this->destination = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_expected_num_participants($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_expected_num_participants($val) {
		$this->expected_num_participants = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_prefDate($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_prefDate($val) {
		$this->prefDate = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_tour_objectives($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_tour_objectives($val) {
		$this->tour_objectives = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_seminar_topic($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_seminar_topic($val) {
		$this->seminar_topic = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_seminar_speaker($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_seminar_speaker($val) {
		$this->seminar_speaker = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_service_classification($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_service_classification($val) {
		$this->service_classification = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_activities($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_activities($val) {
		$this->activities = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_budget_per_student($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_budget_per_student($val) {
		$this->budget_per_student = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_additionalConcern($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_additionalConcern($val) {
		$this->additionalConcern = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_request_by($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_request_by($val) {
		$this->request_by = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_applicant_id($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_applicant_id($val) {
		$this->applicant_id = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_bookingDate($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_bookingDate($val) {
		$this->bookingDate = $val;
	}
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- set variable value
	* @param - set_bookingTime($val)
	* @return - void
	* @vers	- 1
	* @Mod - 
	**/
	function set_bookingTime($val) {
		$this->bookingTime = $val;
	}
	// **********************
	// print_to_screen()
	// this is used mainly for debugging purposes
	// if i am setting values or have an object on a page I call this to see 
	// what values the object that I am working with is holding...
	// **********************
	function print_to_screen() { 
		echo "request_id = ". $this->request_id ." \n <br />";
		echo "subject_name = ". $this->subject_name ." \n <br />";
		echo "subject_code = ". $this->subject_code ." \n <br />";
		echo "subject_overview = ". $this->subject_overview ." \n <br />";
		echo "destination = ". $this->destination ." \n <br />";
		echo "expected_num_participants = ". $this->expected_num_participants ." \n <br />";
		echo "prefDate = ". $this->prefDate ." \n <br />";
		echo "tour_objectives = ". $this->tour_objectives ." \n <br />";
		echo "seminar_topic = ". $this->seminar_topic ." \n <br />";
		echo "seminar_speaker = ". $this->seminar_speaker ." \n <br />";
		echo "service_classification = ". $this->service_classification ." \n <br />";
		echo "activities = ". $this->activities ." \n <br />";
		echo "budget_per_student = ". $this->budget_per_student ." \n <br />";
		echo "additionalConcern = ". $this->additionalConcern ." \n <br />";
		echo "request_by = ". $this->request_by ." \n <br />";
		echo "applicant_id = ". $this->applicant_id ." \n <br />";
		echo "bookingDate = ". $this->bookingDate ." \n <br />";
		echo "bookingTime = ". $this->bookingTime ." \n <br />"; 
		echo "end p_t_s function \n "; 
	}
	
	// **********************
	// process a form $_POST()
	// this may not work for you as is, but I have found it very helpful
	// this takes in a post value from a form and tries to set all of the 
	// variables in this object, I call $this->insert() at the end and would insert my data into the
	// database.  you might have no use for this in this class, or for your current purposes
	// but I am leaving here to show you that the ideal place to handle data processing / functions
	// is in your class code and not on your page.
	// one other note, of course your form values would have to match names (or the below code needs to change)
	// for instance... the code below is expecting your form to have a 'subject_name' field, and a 'subject_code' field etc...
	// the same naming conventions that are used by this class.
	// of course you can always make a form with different values and update what fields you are looking for in the call below.
	// **********************
	function process_form_post($_POST) { 
		$this;
		if (!empty($_POST['request_id'])) { 
			$this->set_request_id($_POST['request_id']);
		}
		if (!empty($_POST['subject_name'])) { 
			$this->set_subject_name($_POST['subject_name']);
		}
		if (!empty($_POST['subject_code'])) { 
			$this->set_subject_code($_POST['subject_code']);
		}
		if (!empty($_POST['subject_overview'])) { 
			$this->set_subject_overview($_POST['subject_overview']);
		}
		if (!empty($_POST['destination'])) { 
			$this->set_destination($_POST['destination']);
		}
		if (!empty($_POST['expected_num_participants'])) { 
			$this->set_expected_num_participants($_POST['expected_num_participants']);
		}
		if (!empty($_POST['prefDate'])) { 
			$this->set_prefDate($_POST['prefDate']);
		}
		if (!empty($_POST['tour_objectives'])) { 
			$this->set_tour_objectives($_POST['tour_objectives']);
		}
		if (!empty($_POST['seminar_topic'])) { 
			$this->set_seminar_topic($_POST['seminar_topic']);
		}
		if (!empty($_POST['seminar_speaker'])) { 
			$this->set_seminar_speaker($_POST['seminar_speaker']);
		}
		if (!empty($_POST['service_classification'])) { 
			$this->set_service_classification($_POST['service_classification']);
		}
		if (!empty($_POST['activities'])) { 
			$this->set_activities($_POST['activities']);
		}
		if (!empty($_POST['budget_per_student'])) { 
			$this->set_budget_per_student($_POST['budget_per_student']);
		}
		if (!empty($_POST['additionalConcern'])) { 
			$this->set_additionalConcern($_POST['additionalConcern']);
		}
		if (!empty($_POST['request_by'])) { 
			$this->set_request_by($_POST['request_by']);
		}
		if (!empty($_POST['applicant_id'])) { 
			$this->set_applicant_id($_POST['applicant_id']);
		}
		if (!empty($_POST['bookingDate'])) { 
			$this->set_bookingDate($_POST['bookingDate']);
		}
		if (!empty($_POST['bookingTime'])) { 
			$this->set_bookingTime($_POST['bookingTime']);
		} 
		//echo "end post function \n "; 
		// you may have other validation, at this point in the process you should expect good data, 
		// lets insert this record.
		$this->insert();
		// returns this object with any parameters set that were set in the post.
		return $this;
	}
	
	// **********************
	// INSERT
	// **********************	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- insert this object
	* @param - insert
	* @return - boolean
	* @vers	- 1
	* @Mod - 
	**/
	function insert() {
		$this->request_id = ""; // clear key for autoincrement
		$sql = "INSERT INTO tbl_tour_request (subject_name,subject_code,subject_overview,destination,expected_num_participants,prefDate,tour_objectives,seminar_topic,seminar_speaker,service_classification,activities,budget_per_student,additionalConcern,request_by,applicant_id,bookingDate,bookingTime ) VALUES ( '".$this->slashes($this->subject_name)."','".$this->slashes($this->subject_code)."','".$this->slashes($this->subject_overview)."','".$this->slashes($this->destination)."','".$this->slashes($this->expected_num_participants)."','".$this->slashes($this->prefDate)."','".$this->slashes($this->tour_objectives)."','".$this->slashes($this->seminar_topic)."','".$this->slashes($this->seminar_speaker)."','".$this->slashes($this->service_classification)."','".$this->slashes($this->activities)."','".$this->slashes($this->budget_per_student)."','".$this->slashes($this->additionalConcern)."','".$this->slashes($this->request_by)."','".$this->slashes($this->applicant_id)."','".$this->slashes($this->bookingDate)."','".$this->slashes($this->bookingTime)."' )";
		$dblink = null;
		try	{
			$dblink = mysql_connect(DB_HOST,DB_USER,DB_PASS);
			mysql_select_db(DB_BASE,$dblink);
		} catch(Exception $ex) {
			echo "Could not connect to " . DB_HOST . ":" . DB_BASE . "\n";
			echo "Error: " . $ex->message;
			exit;
		}
		
		$retid = mysql_query($sql,$dblink) or die(mysql_error());
		if (!$retid) { 
			echo( mysql_error()); 
		}		
		$this->request_id = mysql_insert_id($dblink);
		
		if(is_resource($dblink)) {		
			mysql_close($dblink);
		}		
		// returns the insert id from the database.
		return $retid;
		
	}

	// **********************
	// UPDATE
	// **********************
	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- update this object
	* @param - update($id)
	* @return - boolean
	* @vers	- 1
	* @Mod - 
	**/
	function update($id) {
		$sql = "UPDATE tbl_tour_request SET  subject_name = '$this->subject_name',subject_code = '$this->subject_code',subject_overview = '$this->subject_overview',destination = '$this->destination',expected_num_participants = '$this->expected_num_participants',prefDate = '$this->prefDate',tour_objectives = '$this->tour_objectives',seminar_topic = '$this->seminar_topic',seminar_speaker = '$this->seminar_speaker',service_classification = '$this->service_classification',activities = '$this->activities',budget_per_student = '$this->budget_per_student',additionalConcern = '$this->additionalConcern',request_by = '$this->request_by',applicant_id = '$this->applicant_id',bookingDate = '$this->bookingDate',bookingTime = '$this->bookingTime' WHERE request_id = $id ";
		$dblink = null;
		try	{
			$dblink = mysql_connect(DB_HOST,DB_USER,DB_PASS);
			mysql_select_db(DB_BASE,$dblink);
		} catch(Exception $ex) {
			echo "Could not connect to " . DB_HOST . ":" . DB_BASE . "\n";
			echo "Error: " . $ex->message;
			exit;
		}
		
		$retid = mysql_query($sql,$dblink) or die(mysql_error());
		if (!$retid) { 
			echo( mysql_error()); 
		}		
		
		if(is_resource($dblink)) {		
			mysql_close($dblink);
		}				
		// returns a 1 or 0
		return $retid;
	}

	// **********************
	// SELECT METHOD / LOAD
	// **********************
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- load this object
	* @param - select_by_id($id)
	* @return - sets this object from "$id"
	* @vers	- 1
	* @Mod - 
	**/
	function select_by_id($id) {
		$dblink = null;
		try	{
			$dblink = mysql_connect(DB_HOST,DB_USER,DB_PASS);
			mysql_select_db(DB_BASE,$dblink);
		} catch(Exception $ex) {
			echo "Could not connect to " . DB_HOST . ":" . DB_BASE . "\n";
			echo "Error: " . $ex->message;
			exit;
		}
		$sql = "SELECT * FROM tbl_tour_request WHERE request_id = ".$this->slashes($id);
		
		$retid = mysql_query($sql,$dblink) or die(mysql_error());
		if (!$retid) { 
			echo( mysql_error()); 
		}
		if ($row = mysql_fetch_array($retid)) {	

			$this->request_id = $row['request_id'];
			$this->subject_name = $row['subject_name'];
			$this->subject_code = $row['subject_code'];
			$this->subject_overview = $row['subject_overview'];
			$this->destination = $row['destination'];
			$this->expected_num_participants = $row['expected_num_participants'];
			$this->prefDate = $row['prefDate'];
			$this->tour_objectives = $row['tour_objectives'];
			$this->seminar_topic = $row['seminar_topic'];
			$this->seminar_speaker = $row['seminar_speaker'];
			$this->service_classification = $row['service_classification'];
			$this->activities = $row['activities'];
			$this->budget_per_student = $row['budget_per_student'];
			$this->additionalConcern = $row['additionalConcern'];
			$this->request_by = $row['request_by'];
			$this->applicant_id = $row['applicant_id'];
			$this->bookingDate = $row['bookingDate'];
			$this->bookingTime = $row['bookingTime'];
		}
		
		if(is_resource($dblink)) {		
			mysql_close($dblink);
		}
		return $this;
	}
	
	// **********************
	// SELECT METHOD / LOAD
	// **********************
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- load this object
	* @param - select_all_requests()
	* @return - sets all requests into an array
	* @vers	- 1
	* @Mod - 
	**/
	function select_all_requests() {
		$return_array=array();
		$dblink = null;
		try	{
			$dblink = mysql_connect(DB_HOST,DB_USER,DB_PASS);
			mysql_select_db(DB_BASE,$dblink);
		} catch(Exception $ex) {
			echo "Could not connect to " . DB_HOST . ":" . DB_BASE . "\n";
			echo "Error: " . $ex->message;
			exit;
		}
		$sql =  "SELECT * FROM tbl_tour_request ORDER BY bookingDate DESC";
		
		$retid = mysql_query($sql,$dblink) or die(mysql_error());
		if (!$retid) { 
			echo( mysql_error()); 
		}
		
		while ($row = mysql_fetch_array($retid)) {	
			// make a new class object referencing this class.
			$tr = new tour_request();
			$tr->request_id = $row['request_id'];
			$tr->subject_name = $row['subject_name'];
			$tr->subject_code = $row['subject_code'];
			$tr->subject_overview = $row['subject_overview'];
			$tr->destination = $row['destination'];
			$tr->expected_num_participants = $row['expected_num_participants'];
			$tr->prefDate = $row['prefDate'];
			$tr->tour_objectives = $row['tour_objectives'];
			$tr->seminar_topic = $row['seminar_topic'];
			$tr->seminar_speaker = $row['seminar_speaker'];
			$tr->service_classification = $row['service_classification'];
			$tr->activities = $row['activities'];
			$tr->budget_per_student = $row['budget_per_student'];
			$tr->additionalConcern = $row['additionalConcern'];
			$tr->request_by = $row['request_by'];
			$tr->applicant_id = $row['applicant_id'];
			$tr->bookingDate = $row['bookingDate'];
			$tr->bookingTime = $row['bookingTime'];
			// push this object into the return array.
			array_push($return_array,$tr);
		}
		
		if(is_resource($dblink)) {		
			mysql_close($dblink);
		}
		// returns an array of all request objects.
		return $return_array;
	}
	/*****
	this is the query from your web page.  it will only load the fields specified by you.
	******/
	// **********************
	// SELECT METHOD / LOAD
	// **********************
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- load this object
	* @param - select_all_requests()
	* @return - sets all requests into an array
	* @vers	- 1
	* @Mod - 
	**/
	function select_specific_info() {
		$return_array=array();
		$dblink = null;
		try	{
			$dblink = mysql_connect(DB_HOST,DB_USER,DB_PASS);
			mysql_select_db(DB_BASE,$dblink);
		} catch(Exception $ex) {
			echo "Could not connect to " . DB_HOST . ":" . DB_BASE . "\n";
			echo "Error: " . $ex->message;
			exit;
		}
		$sql =  "SELECT bookingDate, request_id, destination, request_by FROM tbl_tour_request ORDER BY bookingDate DESC";
		
		$retid = mysql_query($sql,$dblink) or die(mysql_error());
		if (!$retid) { 
			echo( mysql_error()); 
		}
		
		while ($row = mysql_fetch_array($retid)) {	
			// make a new class object referencing this class.
			$tr = new tour_request();
			$tr->request_id = $row['request_id'];
			$tr->destination = $row['destination'];
			$tr->request_by = $row['request_by'];
			$tr->bookingDate = $row['bookingDate'];
			// push this object into the return array.
			array_push($return_array,$tr);
		}
		
		if(is_resource($dblink)) {		
			mysql_close($dblink);
		}
		// returns an array of all request objects.
		return $return_array;
	}	
	
	// **********************
	// DELETE
	// **********************	
	/**
	* @author - rakwel
	* @type	- public
	* @desc	- delete this object
	* @param - delete($id)
	* @return - boolean
	* @vers	- 1
	* @Mod - beware, this works.
	**/
	function delete($id) {
		$dblink = null;
		try	{
			$dblink = mysql_connect(DB_HOST,DB_USER,DB_PASS);
			mysql_select_db(DB_BASE,$dblink);
		} catch(Exception $ex) {
			echo "Could not connect to " . DB_HOST . ":" . DB_BASE . "\n";
			echo "Error: " . $ex->message;
			exit;
		}
		$sql = "DELETE FROM tbl_tour_request WHERE request_id = $id;";
		
		$retid = mysql_query($sql,$dblink) or die(mysql_error());
		if (!$retid) { 
			echo( mysql_error()); 
		}
		
		if(is_resource($dblink)) {		
			mysql_close($dblink);
		}
		return $retid;
	
	}

	/**
	* @author - rakwel
	* @type	- public
	* @desc	- $str
	* @param - adding slashes if necessary
	* @return - escaped string
	* @vers	- 1
	* @Mod - 
	**/
	function slashes($str) {
		//if ((get_magic_quotes_gpc()) && (!empty($str))) {
		if (!empty($str)) {
			return addslashes($str);
		} else {
			return $str;
		}
	}
	/**************************************************************/
	/*          ADD YOUR CUSTOM FUNCTIONS BELOW			       */
	/**************************************************************/
// class : end
}
?>

New form page - the cool functionality. need you to plug this in and see if it works.
test_form.php

<html>

<?php
// include your class code
include('tour_request.class.php');
	$tr = new tour_request();
	$requests = $tr->select_specific_info();
?>
<body>
<table>
<?
    foreach ($requests as $request) {
?>
		<tr>
		<td>&nbsp; <h3><?php echo $request->get_bookingDate(); ?></h3> </td>
		<td>&nbsp; <h3><a href=\"javascript:decision('<?php echo $id;?>','action=lookup');\"><?php echo $request->get_request_id(); ?></h3></a> </td>
		<td>&nbsp; <h3><?php echo $request->get_destination(); ?></h3> </td>
		<td>&nbsp; <h3><?php echo $request->get_request_by(); ?></h3> </td>
		</tr>
<? 
    }
?>
</table>
</body>
</html>

does this work, are you getting errors, I am looking at the ajax function now.

you may want to re-indent some of that because it didn't indent cleanly.
2. the href line on the form I was escaping the " like \" remove the \.

I have yet to come up with the full solution working just as you want. I have to knock off early today but will maybe look this weekend and definitely on Monday to see if I cant do it the way you want to, (actually post and pop the page up at the same time), but I have crafted a little work around at the moment, making an ajax call and then displaying a div on the page that is centered. lets start with booking_request_popup.php you should be able to do something like this:

<?php  
// you had these scripts
confirm_logged_in_admin(); 
confirm_if_admin(); 
// include your new class
include_once('tour_request.class.php');
// instantiate it 
$rq = new tour_request();

if($_POST['action']=='lookup' & $_POST['request_id']!="") {
//echo "POST ACTION ==".$_POST['action']." and POSTid = " . $_POST['request_id']. "<br>";
// if you echo something out, it will be returned to the other page.  we only want to display response right now.
// set your id
$id = $_POST['request_id'];
// run your stored query from your class and return data into the $request variable
$request = $rq->select_by_id($id);
// create your output, all fields in class object are available here
$response .= "<table><tr><td>";
// we can tailor this to be any html ...  I will also continue to think about this problem you are having.
$response .= $request->print_to_screen();
$response .= "</td></tr></table>";
} else {
$response = "Could Not look up data you must pass in an id.<br>";
} 
// for now echo the response which will be returned to the ajax call on the other page.
echo $response;
?>

and here is some really ugly and too long javascript to accomplish sending, receiving and display returned from your popup page.
here is a main form page, please test and let me know your findings
form.php

<?php
// include your class code
include('tour_request.class.php');
$tr = new tour_request();
$requests = $tr->select_specific_info();
?>
<html>
<script type="text/javascript">
function fire_my_popup() {
	<!-- Due to different browser naming of certain key global variables, we need to do three different tests to determine their values -->
	// Determine how much the visitor had scrolled
	var scrolledX, scrolledY;
	if( self.pageYOffset ) {
	  scrolledX = self.pageXOffset;
	  scrolledY = self.pageYOffset;
	} else if( document.documentElement && document.documentElement.scrollTop ) {
	  scrolledX = document.documentElement.scrollLeft;
	  scrolledY = document.documentElement.scrollTop;
	} else if( document.body ) {
	  scrolledX = document.body.scrollLeft;
	  scrolledY = document.body.scrollTop;
	}

	// Determine the coordinates of the center of the page
	var centerX, centerY;
	if( self.innerHeight ) {
	  centerX = self.innerWidth;
	  centerY = self.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight ) {
	  centerX = document.documentElement.clientWidth;
	  centerY = document.documentElement.clientHeight;
	} else if( document.body ) {
	  centerX = document.body.clientWidth;
	  centerY = document.body.clientHeight;
	}
	var leftOffset = scrolledX + (centerX - 250) / 2;
	var topOffset = scrolledY + (centerY - 200) / 2;
	document.getElementById("mypopup").style.top = topOffset + "px";
	document.getElementById("mypopup").style.left = leftOffset + "px";
	document.getElementById("mypopup").style.display = "block";
	
}
function decision(id,action) {
	try {
	var http = new XMLHttpRequest();
	} catch (e) {
	    try {
	        var http = new ActiveXObject('Msxml2.XMLHTTP');
		} catch (e) {
			try {
				var objXHR = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e) {
				document.write('XMLHttpRequest not supported'); 
			}
		}
	}
		
	var url = "booking_request_popup.php";
	var params = "request_id="+id+"&action="+action;
	http.open("POST", url, true);

	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");

	http.onreadystatechange = function() {//Call a function when the state changes.
		if(http.readyState == 4 && http.status == 200) {
			//window.open(url);
			//alert(http.responseText);
			alert('call fire');
			fire_my_popup();
			document.getElementById('datadiv').innerHTML = http.responseText;

			
		}
	}	
	http.send(params);
}
</script>
<body>
<table>
<?php
    // if you want to know how many items:
	// $itemcount = count($requests);
    foreach ($requests as $request) {
?>
		<tr>
		<td>&nbsp; <h3><?php echo $request->get_bookingDate(); ?></h3> </td>
		<td>&nbsp; <h3><a href="javascript:decision('<?php echo $request->get_request_id(); ?>','lookup');"><?php echo $request->get_request_id(); ?></h3></a> </td>
		<td>&nbsp; <h3><?php echo $request->get_destination(); ?></h3> </td>
		<td>&nbsp; <h3><?php echo $request->get_request_by(); ?></h3> </td>
		</tr>
<?php 
    }
?>
<tr><td>
<div id='mypopup' name='mypopup' style='position: absolute; width: 450px; height: 400px; display: none; background: #ddd; border: 1px solid #000;'>
<div id='datadiv' name='datadiv'></div>
<input type='submit' value=' Close me! ' onClick='document.getElementById("mypopup").style.display="none"'>
</div>
</td>
</tr>
</table>
</body>
</html>

yes, but that is an ajax call that needs to be made. I will look into it tomorrow and update in the morning. I've just done this exact issue for like 3 other people so I have the code but it is at work and I am at home. later brother...
when you get a chance... if you would like some elegant class code to handle all of your data transactions with the database and easily pass objects of your table and have re-usable code post a mysql dump of your table structure so I can clone your database on my server. no data. just structure. I'll teach you a valuable lesson if you would like to learn. I see you have posted quite a few questions lately. I can show you a completely different approach that you can build on always moving forward.

are you still posting something to help me?
Cause I always visit this thread to check if you already posted anything.
I understand if you'll not.. thankyou for your time anyway..

Oh Im sorry... you already posted something... I didnt see the "page2".
Im looking at your code now.
Thanks alot :)

Sorry if I replied late. Thankyou for the code. I tried them.. sadly, Im getting an error 404, cannot find the page. This is the link that im getting in the url once I click the id: http://localhost/main/%5C%22javascript%3Cb

Im already shy getting some help form you coz I might taking alot of your time. I dont want to disturb people. Thanks for the codes...

I will close the thread now?

Before I close the thread, I want you to know that even if we did achieve what we want (fetching specific row), I did learn from your code. I just learned creating object and defining a class. Cool!

Thankyou
Rockwell

use the $_REQUEST thingy.

on the links use

//do your thing in connecting to your database.
$blah_result = mysql_query("SELECT .... ");
while($bla_row = mysql_fetch_array($blah_result))
{
 //look  at the url of the a href.
 <a href="profile.php?id=<?php $blah_row['stud_id'] ?>">
 <?php echo $blah_row['stud_name'];</a>
}

on the profile.php

//this will accept the value form the previous page. this is the value of $blah_row[stud_id].
$id = $_REQUEST['id];

//do your thing in connecting the database.
$result = mysql_query("SELECT.....");

while($row = mysql_fetch_aray($result)
{
 echo $row['stud_name'];
 echo $row['stud_info'];
}

the id is empty.
"main/admin/admin_tour_requests.php?id= "
It can't read it.

Where do you think is the problem?
The page where it redirects is working (admin_tour_requests.php).
I think its messing in this part...

<?php
global $connection;
$query = "SELECT bookingDate, request_id, destination, request_by FROM tbl_tour_request 
          ORDER BY `tbl_tour_request`.`bookingDate` DESC ";
$result = mysql_query($query);
confirm_query($result);
$num = mysql_num_rows($result);

$i=0;
while($rows=mysql_fetch_array($result)){

?>
    <tr>

        <td>&nbsp; <h3><?php echo $rows['bookingDate']; ?></h3> </td>
        <td>&nbsp;  <a href="admin_tour_requests.php?id=<?php $rows['request_id'] ?>">
        <?php echo $rows['request_id']; ?></a> </td>
        <td>&nbsp; <h3><?php echo $rows['destination']; ?></h3> </td>
        <td>&nbsp; <h3><?php echo $rows['request_by']; ?></h3> </td>
 
    </tr>
<?php $i++;} ?>

solved! I saw where the problem is..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.