Re: formatting logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

First, execute your query

unset($fail);
$res=mysql_query($sql,$dbhandle) or $fail=true;
if( (isset($fail)) || (!(is_resource($res)) )
 echo "There was a problem with the execution of the query";
if(mysql_num_rows($res)==0)
 echo "The query resulted in ZERO records";

#now that's out of the way, start processing the records.  Since you ordered 
them by category already, just do like this

$oldcat='';
while($rec=mysql_fetch_assoc($res)
{if(!($oldcat==$rec['category']))
 {echo "Your category header here";
  $oldcat=$rec['category'];}
 echo "picture data here";}
if(is_resource($res))
 mysql_free_result($res);

>
> What am I missing?
>
The way to the php.net website.
http://www.php.net/


-- 
Registered Linux User Number 379093
-- --BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/O/>E$ d-(---)>+ s:(+)>: a--(-)>? C++++$(+++) UL++++>++++$ P-(+)>++
L+++>++++$ E---(-)@ W+++>+++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e>++++$@ h++(*) r-->++ y--()>++++
-- ---END GEEK CODE BLOCK------
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/
--

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux