| Jim Canfield 2004-05-20, 7:30 pm |
| Greetings,
I've been playing around with this code a while it allows for a lot of
flexability in terms of searching a database table. However I've found that
doing much with the $result can be rather combersome especialy considering
the row results have varied number of colums. I'm still a rather green with
php so I'm looking to learn on this one more than anyhting. Does anyone have
clean way to search a table for an expression and "nicely" assembled and
disassemble the $result into peices that can be linked, formated...etc??
Thanks!!
The following script is used to scan outlook database fields which have been
dumped into mysql:
$query = "SELECT * FROM database";
....
while ($field=mysql_fetch_field($result)) {
$names[$fieldcount] = $field->name;
# This is Reg Ex Statement To Add Spacing for Readability to the Field
Names (i.e FieldName = Field Name)
$names[$fieldcount] = ereg_replace("([A-Z])", " \\1",
$names[$fieldcount]);
$fieldcount++;
}
echo "<tr>";
while ($row = mysql_fetch_row($result)) {
if($srch) {
for ($i=0; $i<mysql_num_fields($result); $i++) {
$all .= $row[$i]; }
if (eregi($srch, $all)){
$found = 1;
echo "<td>";
for ($i=0; $i<mysql_num_fields($result); $i++) {
if(($row[$i]) && !($row[$i] == "0/0/00")) {
if(!ereg($notshow,$names[$i])) {
print "<B>$names[$i]:</B> ";
print "$row[$i]<br>"; }}
}
print "</td>";
}
$all = "";
echo "</tr>";
}
}
|