Jump to content


Photo

Simple Help Please


  • Please log in to reply
1 reply to this topic

#1 nashyboy

nashyboy
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 27 June 2006 - 04:55 PM

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);




?>

#2 adamwhiles

adamwhiles
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 27 June 2006 - 07:13 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users