Hi,i have made my own gift certification system for my own shopping cart system i have 4 Digit Numbers in the database which the user will get when they buy the the gift certificate.

And one is 4421 which is not used and the other gives a $50 discount

and the other is 8632 which has been used in the database when i try either one it doesnt work at all it say discount price blah blah blah and i try the other one and the other which is not used and the other one that is used says has been used where if i use the used one first then it says has been used if i use the one that hasnt been used after using the one that has been used it says the same for the 1st one,

What is wrong with this?

Can anyone help me find my problem Please?

Code is below.

Thanks
Code:
<br/>
		if you have a gift certificated please enter it here once you have entered it a message will appear saying<br/>
		the new discounted price will be under New Price under the gift certificate part of the page.
		<table>
		<tr>
			<td><th align="right">Gift Certificate Number:</th><br />
		<th align="right"><form method="post" action="">
		<input type="text" name="discountnum" maxlength="4" width="5px">
		<input type="submit" name="name2" value="Enter">
		</form></th>
	</td>
		</tr>
		</table>
PHP Code:
        <?php
        
if($_POST['name2'])
        {
            
//error_reporting(E_ALL);
            
$discountnum=trim($_POST['discountnum']);
            if(
$discountnum)
            {
                
//$cQuery="select gca from gcertificated Where idnum='$idnum' and gid='$gid'";
                
$cQuery="select * from gcertificated";
                
$rs=mysqli_query($con,$cQuery);
                if(!
$rs)
                {
                    echo 
"Error:".mysqli_error($con);
                }
                else
                {
                    
$count=$rs->num_rows;
                    
//echo $count;
                    
if($count>=0
                    
//while($data=mysqli_fetch_assoc($rs))
                    
{
                        
$data=mysqli_fetch_assoc($rs);
                        
//echo "<pre>";
                        //print_r($data);
                        //$used=$data['used'];
                        
$gca=$data['gca'];
                            {
                                echo 
$data['used'];
                                if(
$data['used']==0)
                                {
                                    echo 
"<tr>
                                    <th align=\"right\">New Price:</th><br />"
;
                                    echo 
"<th align=\"right\">$"number_format($total2);
                                    echo
"</th>
                                    </tr></table>"
;
                                    
$total-=$gca;
                                    echo 
$total;
                                }
                                else if(
$data['used']==1)
                                {
                                     echo 
"Already been used";
                                }
                            }
                    }
                }
            }
        }