For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > May 2004 > Results with Variable number of rows...help!









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Results with Variable number of rows...help!
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>";

}

}


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com