Jump to content

Recommended Posts

Hey guys.

 

I've made a script which will allow people to buy items, when an item is sold it will delete from the database.

 

so its easy to see the items i have it have separate colors so its dark grey and light grey on the next line and so on. But the problem is when the item is bought 2 of the same colors are next to each other. I am checking if the item_id is an odd or even number to get the result I want but cant figure out a soluction to when an item is purchased.

 

 <?php foreach(getItems() as $item): ?>
                  <?php if($item['item_id'] & 1): ?>
                    <tr class="grey2">
                        <?php else: ?>
                    <tr class="grey">
                        <?php endif; ?>
                   
                  
                    <td><?php echo $item['item_account']; ?></td>
                    <td><?php echo $item['item_country']; ?></td>
                    <td><?php echo $item['item_info']; ?></td>
                    <td><?php echo $item['item_login']; ?></td>
                    <td><?php echo $item['item_pass']; ?></td>
                    <td><?php echo $item['item_price']; ?> </td>
                    <td><form method="post" action="#"><input type="submit" name="buy" value="Buy" class="button" /></form></td>
        
                </tr>
                <?php endforeach; ?>

 

Thanks guys

$class = 'grey';
<?php foreach(getItems() as $item): ?>
                  <?php $class = ($class == 'grey') ? 'grey2' : 'grey'; ?>
                   <tr class="<?php echo $class; ?>">              
                    <td><?php echo $item['item_account']; ?></td>
                    <td><?php echo $item['item_country']; ?></td>
                    <td><?php echo $item['item_info']; ?></td>
                    <td><?php echo $item['item_login']; ?></td>
                    <td><?php echo $item['item_pass']; ?></td>
                    <td><?php echo $item['item_price']; ?> </td>
                    <td><form method="post" action="#"><input type="submit" name="buy" value="Buy" class="button" /></form></td>
        
                </tr>
                <?php endforeach; ?>

 

I think that's right.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.