LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-19-2007, 02:33 PM   #1
orfiyus
Member
 
Registered: May 2006
Posts: 42

Rep: Reputation: 15
How do I output the result of a query in php?


Hey

I have an input form that a user types text into. This input then gets stored in a variable and then various php functions are called to query the db to see if the input exists in it. Anyway I am trying to see if this is working correctly so I decided to output the result of the query to the screen to make sure it is working. However I can not understand how to do this. I am working with a similar example that does this but it is just a straight query that relies on other variables that are defined through the code. If someone can give me any help I would appreciate it.

Here are the code pieces I am working with. The first one is what works and I am trying to model the second one after it. I have put a comment on where I get confused in the second piece of code.

Thanks

Code:
//query
$query = "select strike,opn_int from surfaces where undl_indx = $undl_indx and expire_date = ".$_SESSION['opt_exd_vals'][$opt_indx]." and call_put = '".$_SESSION['opt_cp_vals'][$opt_indx]."'";
$parsed = ociparse($db_conn, $query);
$succ = ociexecute($parsed);
	if ($succ){
		$nrows = ocifetchstatement($parsed, $rset);
                //prints results of array to the screen
		for ($indx = 0; $indx < $nrows; $indx++){
			$strike = $rset['STRIKE'][$indx];
			$open_int = $rset['OPN_INT'][$indx];
			$selected = ($strike == $_SESSION['opt_strk_vals'][$opt_indx])?"selected":"";
			echo("<option value=$strike $selected>$strike</option>\n");
			//echo("open interest is $open_int ");
			if ($open_int < 0)
				echo " (inserted)";
			else
				echo " ";
			
		}
	}
Here is what I put

Code:
//text field
echo("<input type=text name=opt_qty value=".$_SESSION['opt_qty_vals'][$opt_indx]." onBlur='submit();' class='qty_input'>");
echo("</td>");
//store user input
$user_input_strike = $_SESSION['opt_qty_vals'][$opt_indx];
$query1 = "select strike from surfaces where undl_indx = $undl_indx and and expire_date = ".$_SESSION['opt_exd_vals'][$opt_indx]." and call_put = '".$_SESSION['opt_cp_vals'][$opt_indx]." and strike = $user_input_strike";
$parsed1 = ociparse($db_conn, $query1);
$succ1 = ociexecute($parsed);
	if ($succ1)
	{
		$nrows = ocifetchstatement($parsed1, $rset);
		for ($indx = 0; $indx < $nrows; $indx++) {
			$user_input_result = $rset['STRIKE'][$indx];
                        //this is the part where I get confused. I dont understand how to define this properly.
			$selected = ($user_input_result == $_SESSION['opt_qty_vals'][$opt_indx])?"selected":"";
			echo(<"option value = $user_input_result $selected>$user_input_result</option>\n");
		} 
	}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with comparing user input to result of a query php orfiyus Programming 3 07-10-2007 11:08 PM
select query thru php outputs no result suchi_sood Programming 1 04-11-2006 10:21 AM
Output the result of a command to a file darkarcon2015 Linux - Newbie 1 09-24-2005 06:29 PM
php: output the result of exec( $command ) zovres Programming 6 08-27-2004 06:41 PM
mySQL redirecting query result to a .txt file! buttersoft Linux - Software 8 12-12-2003 03:05 AM


All times are GMT -5. The time now is 01:52 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration