Search the Community
Showing results for tags 'loop_iterating_msql_databse'.
-
Hello: I have been working on this code for some time. It is for a directory database for which I am retrieving information from two tables. From one table I am retrieving one entry while multiple entries are retrieved from another table. The problem is that I only the one entry to display only once followed by the display of the multiple entries following it. The way I have it set up now the entry I only want to appear at the top of the disp;ay repeats itself for every record it is associated with. Here is my code: { $library_search=$_POST ['Library_search']; $query= "select * from library RIGHT JOIN name USING (Library_ID) WHERE library_name like '%".$library_search."%'"; $query_results=mysql_query($query)or die (mysql_error()); $match_results=mysql_num_rows($query_results); } for ($i=0; $i < $match_results; $i++) { echo '<tr><td>'; $row=mysql_fetch_array($query_results); echo ($row ['university_name']),'<br/>'; echo ($row ['library_name']),'<br/>'; echo ($row ['address']),'<br/>'; echo ($row ['city']),'<br/>'; echo ($row ['state']),'<br/>'; echo ($row ['zip']),'<br/>'; echo ($row ['fax']),'<br/>'; echo ($row ['home_URL']),'<br/>'; echo ($row ['catalog_URL']),'<br/>'; echo ($row ['hours_URL']),'<br/>'; echo ($row ['special_access']),'<br/>'; echo ($row ['FirstName']), " "; echo ($row ['Middleinit'])," "; echo ($row ['LastName']),'<br/>' ; echo ($row ['PositionHeld']),'<br/>' ; echo ($row['OtherPosition']),'<br/>' ; echo ($row['Library_ID']),'<br/>' ; echo ($row['Address']), '<br/>'; echo ($row['City']), " "; echo ($row['State'])," ", " "; echo ($row['zip']),'<br/>'; echo ($row['Workphone']),'<br/>'; echo ($row['Residencephone']), '<br/>'; echo ($row['Email']),'<br/>'; echo ($row['WAALMember']), '<br/><br/>'; }