Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 07-19-2007, 03:33 PM   #1
Registered: May 2006
Posts: 42

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


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.


$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)";
				echo " ";
Here is what I put

//text field
echo("<input type=text name=opt_qty value=".$_SESSION['opt_qty_vals'][$opt_indx]." onBlur='submit();' class='qty_input'>");
//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");


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-11-2007 12:08 AM
select query thru php outputs no result suchi_sood Programming 1 04-11-2006 11:21 AM
Output the result of a command to a file darkarcon2015 Linux - Newbie 1 09-24-2005 07:29 PM
php: output the result of exec( $command ) zovres Programming 6 08-27-2004 07:41 PM
mySQL redirecting query result to a .txt file! buttersoft Linux - Software 8 12-12-2003 04:05 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:21 PM.

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