rbragg Posted October 11, 2007 Share Posted October 11, 2007 I have built a search script that searches based on what a user has entered. In this case, the user has entered a value into a textfield that is brought in with the GET method. I use that value to find the S_NUM to those matching values. Using this while loop echoes each S_NUM for each match, however, when I run the appended query, the query only uses the LAST matching S_NUM and I get one record. For example, there may be 3 S_NUM's that match the query (56, 58, 59) and the appending query only displays one record (59) when I need 3: <?php # start of $querySearch here and I'm appending to it based on some criteria # criteria: if ( !empty($_GET['searchStudent']) ) { $gotStudent = $_GET['searchStudent']; $queryStudentResult = " SELECT s_num FROM student WHERE student.s_first LIKE '%" . $gotStudent . "%' OR student.s_last LIKE '%" . $gotStudent . "%' "; $studentResult= ociparse($connect, $queryStudentResult); ociexecute($studentResult); while ( ocifetch($studentResult) ) { $studentNum = ociresult($studentResult,"S_NUM"); echo "<br>studentNum: " . $studentNum . "<br>"; } $querySearch.= "AND call.s_num = " . $studentNum . " "; }?> I also realize I need to make some upper/lower changes with using LIKE, but first I'm just trying to get this appending functioning. How to I manipulate an array to get my desired results here? I have also tried using foreach within the While loop. Quote Link to comment https://forums.phpfreaks.com/topic/72837-solved-query-appending-using-an-array/ Share on other sites More sharing options...
rbragg Posted October 11, 2007 Author Share Posted October 11, 2007 Btw, I'm using PHP 4. Quote Link to comment https://forums.phpfreaks.com/topic/72837-solved-query-appending-using-an-array/#findComment-367335 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.