nashyboy Posted June 27, 2006 Share Posted June 27, 2006 Hi,I have the following code (different where command...) listed 4 times on my page. The problems appears to be that it doesnt have a close command so it is only showing one connection and then nothing underneath.Currently this page should display...Managementno contacts foundInternal Supportno contacts foundServer Teamno contacts foundHelpdesk Teamno contacts foundHowever it appears that bcause the connect has not closed it only shows Managementno contacts foundand then nothing under at all....I have tried using the mysql_close() command but no luck. Can anyone help please.My code is this..... <?phpinclude("includes/login_details.inc");mysql_connect ($dbhost, $dbuser, $dbpass) or die (mysql_error()); //Connects to database mysql_select_db ($dbname) or die (mysql_error()); //Selects your database $sql = "SELECT * FROM contacts where department = 'Server Team' "; $result = mysql_query($sql); //echo $sql; if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No Contacts Found"; exit; } // While a row of data exists, put that row in $row as an associative array // Note: If you're expecting just one row, no need to use a loop // Note: If you put extract($row); inside the following loop, you'll // then create $userid, $fullname, and $userstatus while ($row = mysql_fetch_assoc($result)) { echo "<table width=800 border=0 cellpadding=0 cellspacing=0><tr>"; echo "<td width=22></td>"; echo "<td width=128><font size=1 face=Verdana, Arial, Helvetica, sans-serif><strong>"; echo $row["name"]; echo "</strong></font></td>"; echo "<td width=100><font size=1 face=Verdana, Arial, Helvetica, sans-serif>"; echo $row["mobile1"]; echo "</font></td>"; echo "<td width=100><font size=1 face=Verdana, Arial, Helvetica, sans-serif>"; echo $row["phone"]; echo "</font></td>"; echo "<td width=100><font size=1 face=Verdana, Arial, Helvetica, sans-serif>"; echo $row["mobile2"]; echo "</font></td>"; echo "<td width=350><font size=1 face=Verdana, Arial, Helvetica, sans-serif><strong>"; echo $row["jobrole"]; echo "</strong></font></td>"; echo "</tr></table>"; } mysql_free_result($result);?> Quote Link to comment https://forums.phpfreaks.com/topic/13033-simple-help-please/ Share on other sites More sharing options...
adamwhiles Posted June 27, 2006 Share Posted June 27, 2006 try taking the exit; out of this statement: if (mysql_num_rows($result) == 0) { echo "No Contacts Found"; exit; }then doing a else statement around everything after that. Quote Link to comment https://forums.phpfreaks.com/topic/13033-simple-help-please/#findComment-50191 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.