HAVOCWIZARD Posted June 13, 2007 Share Posted June 13, 2007 guys , i get all the data from my database, but when i return i only get the first record of the query, it doesnt go to the next record in the query, really need help i have tride the almost evrything dont know what else to go, cvan anybody help pls.. <?php include "scripts/php/test1.php"; $find = "mountain view"; $searching = "yes"; ?> <h2>Search</h2> <form name="search" method="post" action="<?=$PHP_SELF?>"> Seach for: <input type="text" name="find" /> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> <?php //This is only displayed if they have submitted the form if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified //$data = mysql_query("SELECT * FROM registrations WHERE upper(register_companyName) LIKE'$find', "); $data = mysql_query("SELECT * FROM registrations WHERE register_companyName = '$find' or register_contactPerson = '$find' or register_telephoneNumber = '$find' or register_telephoneNumber2 = '$find' or register_faxNumber = '$find' or register_cellphoneNumber = '$find' or register_emailAddress = '$find' or register_website = '$find' or register_address1 = '$find' or register_address2 = '$find' or register_area = '$find' or register_suburb = '$find' or register_province = '$find' or register_country = '$find' or register_postalCode = '$find' or register_business = '$find' or register_description = '$find' or register_trading = '$find' or register_Mcat = '$find' or register_keyword1 = '$find' or register_keyword2 = '$find' or register_keyword3 = '$find' or register_keyword4 = '$find' or register_keyword5 = '$find' or register_keyword6 = '$find' or register_keyword7 = '$find' or register_keyword8 = '$find' or register_keyword9 = '$find' or register_keyword10 = '$find' or register_keyword11 = '$find' or register_keyword12 = '$find' or register_keyword13 = '$find' or register_keyword14 = '$find' or register_keyword15 = '$find' or register_keyword16 = '$find' or register_keyword17 = '$find' or register_keyword18 = '$find' or register_keyword19 = '$find' or register_keyword20 = '$find' or register_latitude = '$find' or register_longitude = '$find'"); //And we display the results //while ($result = mysql_fetch_array($data)) //echo $result['register_companyName']; //echo " "; //echo $result['register_telephoneNumber']; //echo "<br>"; //echo $result['register_faxNumber']; //echo "<br>"; //echo "<br>"; while ($row = mysql_fetch_array($data)) //{ // print "<pre>"; // var_dump($row); // print "</pre>"; //} $result = $row; $result_fnd = mysql_num_rows($data); for ($loop_result = 0; $loop_result <> $result_fnd; $loop_result++) { if($result_fnd != 0) { echo '<div id="resultDIV' . $loop_result . '" style="" class="textField">'; echo ' <table style="width:100%;">'; echo ' <tr>'; echo ' <td style="width:75%">'; // company name echo ' <a href="javascript:showHideDIV(\'resultDropDownDIV' .$loop_result . '\')" class="linkResults">'; //ob_start("highlight"); echo htmlspecialchars( stripslashes( $result['register_companyName']) ); //ob_end_flush(); echo '</a>'; echo ' </td>'; echo ' </tr>'; echo ' <tr>'; echo ' <td>'; echo ' Relevancy: <img src="images/relevancy.gif" style="width:' . ($result[$loop_result]["relevancy"] / 2) . 'px; height:8px" alt="relevancy_rating" /> ' . $result[$loop_result]["relevancy"] . '%'; echo ' <td>'; echo ' </tr>'; echo ' </table>'; echo ' <div id="resultDropDownDIV' . $loop_result . '" style="width:95%; display:none;"> '; echo ' <table style="width:100%;table-layout:fixed"> '; if($result['$register_business']) { // business echo ' <tr> '; echo ' <td style="width:20%; vertical-align:top"> '; echo ' Business: ' ; echo ' </td> '; echo ' <td style="width:40%"> '; echo ' '; // start our highlight procedure ob_start("highlight"); echo htmlspecialchars( stripslashes($result['register_business']) ); // end our highlight procedure ob_end_flush(); echo ' </td> '; echo ' </td> '; echo ' </tr> '; } if($result['register_description']) { // description echo ' <tr> '; echo ' <td style="vertical-align:top"> '; echo ' Description: '; echo ' </td> '; echo ' <td> '; echo ' <pre class="textField">'; ob_start("highlight"); echo htmlspecialchars( stripslashes( $result['register_description'])); // end our highlight procedure ob_end_flush(); echo "</pre>"; echo ' </td> '; echo ' </tr> '; } if($result['register_address1'] || $result['register_address2'] || $result['register_area'] || $result['register_suburb'] || $result['register_province'] || $result['register_country'] || $result['register_postalCode']) { // Address echo ' <tr> '; echo ' <td style="vertical-align:top"> '; echo ' Address: '; echo ' </td> '; echo ' <td style="vertical-align:top"> '; if($result['register_address1']) { echo ' '; ob_start("highlight"); echo $result['register_address1']; // end our highlight procedure ob_end_flush(); echo "<br />"; } if($result['register_address2']) { echo ' '; ob_start("highlight"); echo $result['register_address2']; // end our highlight procedure ob_end_flush(); echo "<br />"; } if($result['register_area']) { echo ' '; ob_start("highlight"); echo $result['register_area']; // end our highlight procedure ob_end_flush(); echo "<br />"; } if($result['register_suburb']) { echo ' '; ob_start("highlight"); echo $result['register_suburb']; // end our highlight procedure ob_end_flush(); echo "<br />"; } if($result['register_province']) { echo ' '; ob_start("highlight"); echo $result['register_province']; // end our highlight procedure ob_end_flush(); echo "<br />"; } if($result['register_country']) { echo ' '; ob_start("highlight"); echo $result['register_country']; // end our highlight procedure ob_end_flush(); echo "<br />"; } if($result['register_postalCode']) { echo ' '; ob_start("highlight"); echo $result['register_postalCode']; // end our highlight procedure ob_end_flush(); echo "<br />"; } echo ' </td> '; echo ' </tr> '; echo ' <tr><td> </td></tr> '; } if($result['register_contactPerson']) { // Contact Person echo ' <tr> '; echo ' <td style="width:30%; vertical-align:top"> '; echo ' Contact Person: '; echo ' </td> '; echo ' <td style="width:70%"> '; echo ' '; echo $result['register_contactPerson']; echo ' </td> '; echo ' </tr> '; echo ' <tr><td> </td></tr> '; } if($result['register_telephoneNumber']) { // telephone echo ' <tr> '; echo ' <td style="width:30%; vertical-align:top"> '; echo ' Tel: '; echo ' </td> '; echo ' <td style="width:70%"> '; echo ' '; ob_start("highlight"); echo $result['register_telephoneNumber']; // end our highlight procedure ob_end_flush(); echo ' </td> '; echo ' </tr> '; } if($result['register_telephoneNumber2']) { // Alternative telephone echo ' <tr> '; echo ' <td style="width:30%; vertical-align:top"> '; echo ' Tel: '; echo ' </td> '; echo ' <td style="width:70%"> '; echo ' '; ob_start("highlight"); echo $result['register_telephoneNumber2']; // end our highlight procedure ob_end_flush(); echo ' </td> '; echo ' </tr> '; } if($result['register_faxNumber']) { // fax echo ' <tr> '; echo ' <td style="width:30%; vertical-align:top"> '; echo ' Fax: '; echo ' </td> '; echo ' <td style="width:70%"> '; echo ' '; ob_start("highlight"); echo $result['register_faxNumber']; // end our highlight procedure ob_end_flush(); echo ' </td> '; echo ' </tr> '; } if($result['register_cellphoneNumber']) { // cellphone echo ' <tr> '; echo ' <td style="width:30%; vertical-align:top"> '; echo ' Cell: '; echo ' </td> '; echo ' <td style="width:70%"> '; echo ' '; ob_start("highlight"); echo $result['register_cellphoneNumber']; // end our highlight procedure ob_end_flush(); echo ' </td> '; echo ' </tr> '; } if($result['register_trading']) { // trading hours echo ' <tr> '; echo ' <td style="vertical-align:top"> '; echo ' Trading Hours: '; echo ' </td> '; echo ' <td> '; echo ' <pre class="textField">'; ob_start("highlight"); echo htmlspecialchars( stripslashes( $result['register_trading'] ) ); // end our highlight procedure ob_end_flush(); echo "</pre>"; echo ' </td> '; echo ' </tr> '; } if($result['register_emailAddress']) { // email echo ' <tr> '; echo ' <td style="width:30%; vertical-align:top"> '; echo ' Email: '; echo ' </td> '; echo ' <td style="width:70%"> '; echo ' <a href="mailto:' . htmlspecialchars( stripslashes( $result['register_emailAddress'] ) ) . '" class="linkResults">'; ob_start("highlight"); echo htmlspecialchars( stripslashes( $result['register_emailAddress'] ) ); ob_end_flush(); echo '</a>'; echo ' </td> '; echo ' </tr> '; } if($result['register_website']) { // website echo ' <tr> '; echo ' <td style="width:30%; vertical-align:top"> '; echo ' Website: '; echo ' </td> '; echo ' <td style="width:70%"> '; if(stristr(htmlspecialchars( stripslashes( $result['register_website'] ) ), "http://")) { echo ' <a href="' . htmlspecialchars( stripslashes( $result['register_website'] ) ) . '" class="linkResults">'; ob_start("highlight"); echo htmlspecialchars( stripslashes( $result['register_website'] ) ); // end our highlight procedure ob_end_flush(); echo '</a>'; } else { echo ' <a href="http://' . htmlspecialchars( stripslashes( $result['register_website'] ) ) . '" target="_blank" class="linkResults">http://'; ob_start("highlight"); echo htmlspecialchars( stripslashes( $result['register_website'] ) ); ob_end_flush(); echo '</a>'; } echo ' </td> '; echo ' </tr> '; } echo ' <tr><td> </td></tr>'; echo ' </table> '; echo ' </div> '; echo '</div> '; echo "<br />"; } } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } ?> i am passing the stuff it should find and it finds it, testing local, on the database, have only 3 records with that value and it show that on the count there are only 3, but it only gives the first records info, doesnt loop to the next one, if i just echo them it show all, very confused... Quote Link to comment https://forums.phpfreaks.com/topic/55388-solved-still-need-help-with-wrong-info/ Share on other sites More sharing options...
HAVOCWIZARD Posted June 13, 2007 Author Share Posted June 13, 2007 found the problem, had to remove the for statement and the {} from the loop, thanks guys for the help Quote Link to comment https://forums.phpfreaks.com/topic/55388-solved-still-need-help-with-wrong-info/#findComment-273755 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.