<?php if(!defined('IN_INDEX')) { die('Sorry, you cannot access this file.'); } ?>

                    <?php 
                        $vouch = mysql_query("SELECT * FROM cms_vouchers"); 
                        while ($voucher = mysql_fetch_assoc($vouch)) { 
                            $username = $voucher['user_id']; 
                            if(($_SESSION['user']['username']) == "$username") { 

                    ?>

                    <div id="page-content-text" class="left">
                        <div id="contentTitle" class="red">%hotel_name% Alert: Enter the voucher code <?php echo $voucher['code'] ?> 
                        to receive <?php echo $voucher['smileys_points'] ?> </div>
                    </div>   

                    <?php        
                            } 
                        } 
                    ?>


                    I need a little help with the code above to not return the voucher code once it has been used, From using a ENUM in the database table 0 for unused and 1 for used

SELECT * FROM cms_vouchers where voucher_code =0;

this query will show only vouchers not used

Could you help do the other part, Not so good with PHP Myself :(

Also the table name is named used and the table is called cms_vouchers

Managed to do it with

$vouch = mysql_query("SELECT * FROM cms_vouchers WHERE used = '0'");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.