Styling selected records

Hi all,

if I use this to get records

[php]


    <?php
    $cquery = mysql_query (“Select * From product Where category_id=$category_id”);
    while ( $cr = mysql_fetch_array ($cquery)) {
    while ( $pr = mysql_fetch_array ($cquery) ) {
    ?>
  •            <a href="index.php?product=<?php echo $category_id; ?>&product_id=<?php echo $pr['product_id']; ?>"><?php echo $pr['name']; ?></a>
    
    
             </li>
             <?php  } } ?>
           </ul>
    

    [/php]

    Then how can I apply different style to the clicked product, like if below code results:

    product 1
    product 2
    product 3

    And then if some one click on product 1, it should be like this:

    product 1
    product 2
    product 3

    And then if some one click on product 2, it should be like this:

    product 1
    product 2
    product 3

    And then if some one click on product 3, it should be like this:

    product 1
    product 2
    product 3

    I have tried with several things but have not succeeded yet. What is the best way to do this?

    Thanks.

hi please do the following things

1.) Add class to li tag(here i use protab as class)

2.) use following script

3.) if jquery is not loaded than use following jquery script

[php]

.selected { background-color:#000000;} a{ color:#FFFFFF;} [/php]

#replace old li tag with following

[php]


  • <?php echo $pr['name']; ?>
  • [/php]

    reply your feedback
    SR

    Sorry for my late reply.

    I applied as you wrote but now when I click on result record, only class is changed and it do not go to product page. Seems a is disabled.

    Sponsor our Newsletter | Privacy Policy | Terms of Service