Jump to content

Archived

This topic is now archived and is closed to further replies.

nashyboy

Simple Help Please

Recommended Posts

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...

Management
no contacts found

Internal Support
no contacts found

Server Team
no contacts found

Helpdesk Team
no contacts found

However it appears that bcause the connect has not closed it only shows

Management
no contacts found

and then nothing under at all....

I have tried using the mysql_close() command but no luck. Can anyone help please.

My code is this.....

<?php

include("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);




?>

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.