views:

29

answers:

2

I mean, using css sprites on non static content like: Inside while(mysql_fetch_array())...

A: 

You can use a CSS sprite anywhere you are writing HTML code... As far as "inside while..."... i have no idea what you mean by that. If your while loop prints HTML, then yes, you can use a sprite.

webdestroya
Thanks for reply, while($cat = mysql_fetch_array($query){?> <p><?php echo $cat['cat_name'];?></p><?php }?>How can i apply the back-ground-position?May be this way:?if($cat['cat_id'] == 1){background-position: 0 0;}...You imagine 20 categories?
jartaud
No. You can't just dump the CSS like that, you need to have a table or something and apply the formatting to a row of the table. (But you have the right idea... just need to implement it correctly.)
webdestroya
Thanks again: i use float left n this is the result: http://www.box.net/shared/odhcmqlssrI think with a switch case i can apply the sprites:[$id_cat]case 1: ?><p class="aClass"><?php echo $cat['cat_name'];?></p>.catCont{the css sprites}.catCont .aClass{background-position:0px -4px;}<?php break;?>
jartaud
Yea, if you are using the PHP to generate a CSS file, then that should work for you.
webdestroya
Thanx for ur precious time :)
jartaud
No problem, be sure to upvote
webdestroya
A: 

your code looks like PHP. That is processed on the server to generate static HTML content. It is not executed dynamically in the browser like JavaScript. You can have have the element classes and id attributes echoed out to whatever content your'e generating in PHP and then reference those from your CSS.

Timothy
Thanks again, the problem is: im output data in column using float left...Also i have about 20 categories. The only way i can do it is:[HARD CODED]if($cat['cat_id'] == 1){background-position: 0 0;}...
jartaud