View Single Post
Old 03-02-2007, 05:42 PM   #2 (permalink)
StupidScript
Inactive
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 678
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Here're a couple of examples ... don't quite know how deep the issue is:

1) Basic example that will use a space character when the value is empty:
Code:
..do query..id,name,address.. while($row=mysql_fetch_array($result)) { extract($row); if (!$name) { $name=" "; } if (!$address) { $address=" "; } }
2) Basic example to eliminate column from one-row result:
Code:
..do query..id,name,address.. while($row=mysql_fetch_array($result)) { extract($row); if (!$name) { $namecol=""; $nameval=""; } else { $namecol="<th>Name</th>"; $nameval="<td>".$name."</td>"; } if (!$address) { $addresscol=""; $addressval=""; } else { $addresscol="<th>Address</th>"; $addressval="<td>".$address."</td>"; } print "<table>\n"; print "<tr><th>ID</th>".$namecol.$addresscol."\n"; print "<tr><td>".$id."</td>".$nameval.$addressval."\n"; print "</table>\n"; }
There're lots of ways to do this ... it depends on what you want. You could use foreach($row as $key => $val) and test for empty $vals ... stuff like that.
StupidScript is offline   Reply With Quote