
July 30th, 2003, 02:19 PM
|
|
Junior Member
|
|
Join Date: Jul 2003
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Formatting query results/table
I have seen this posted in the MySQL forums but am new to LDAP/PHP stuff. I want to post data from an LDAP query into a table format for an online phone directory. The results returned are a name and a phone number that is formatted right now as a table with two rows. Like the following:
User1 Number1
User2 Number2
User3 Number3
User4 Number4
I want it to read:
User1 Number1 User2 Number2
User3 Number3 User4 Number4
Any help or suggestions is greatly appreciated. The full code is as follows:
PHP Code:
<?php
error_reporting (7);
$surname = trim($_REQUEST['sursearch']);
$ds = ldap_connect("10.1.2.1"); // must be a valid LDAP server!
if ($ds) {
$r = ldap_bind($ds); // this is an "anonymous" bind, typically read only access
// Search surname entry
$sr = ldap_search($ds, "o=bl", "sn=$surname*");
$info = ldap_get_entries($ds, $sr);
for ($i=0; $i<$info["count"]; $i++) {
//This line looks to see if telephonenumber field actually has a number if not it does not post the data
if ($info[$i]["telephonenumber"][0]) {
if ($info[$i]["fullname"][0])
//Put results in a table
echo " <table border='1' cellspacing='1' cellpadding='0'>
<td valign='center' align='left' bgcolor='#ffffff' width=200><font size='3'>" . $info[$i]["fullname"][0] . "</td></font>
<td valign='center' align='center' bgcolor='#ffffff' width=100><font size='3'>" . $info[$i]["telephonenumber"][0] . "</td></font>
";
}
}
}
echo "</table>";
ldap_close($ds);
?>
Last edited by Viper_SB : July 30th, 2003 at 03:36 PM.
|