Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:20:12+00:00 2026-06-17T04:20:12+00:00

I have a database table (furcodes) with fields A, B, C, D, E i

  • 0

I have a database table (furcodes) with fields A, B, C, D, E
i use this code to create a redeem code system in a Joomla site:

    <?php
$redeem_code = JRequest::getString('redeem_code', '', 'post');
$db =& JFactory::getDBO();
$query = "
    SELECT COUNT(`B`)
        FROM `furcodes`
        WHERE `B` = '$redeem_code' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count ) {

  $mainframe =& JFactory::getApplication();
  $mainframe->enqueuemessage('You have succesfully redeemed this fur code');
  return false;
} else {
    $mainframe =& JFactory::getApplication();
  $mainframe->enqueueMessage(JText::_('Invalid code. Please check and try again.'), 'error');
  return false;
}
?>

I use the count to check if this code exists in the database but i also need to get the field from column “E” that states if this code has been used before or not (values 0=not used or 1=used , one use for every code) and create an if like this:

    if $used == 1
 echo "This code has been used"

Any help?


Final code i used, it might help someone else.

<?php
$your_fur_code = JRequest::getString('fur_code', '', 'post');
$db =& JFactory::getDBO();
$query = "SELECT `E` FROM `furcodes` WHERE `B` = '$your_fur_code'";
$db->setQuery($query);
$code_used = $db->loadResult();
if ( $code_used == "1" ) {
  $mainframe =& JFactory::getApplication();
  $mainframe->enqueueMessage(JText::_('The code has already been used.'), 'error');
  return false;
} if ( $code_used == "0" ) {
  $mainframe =& JFactory::getApplication();
  $mainframe->enqueuemessage('You have succesfully redeemed this code');
  return false;
} else {
    $mainframe =& JFactory::getApplication();
  $mainframe->enqueueMessage(JText::_('Invalid code. Please check and try again.'), 'error');
  return false;
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:20:14+00:00Added an answer on June 17, 2026 at 4:20 am

    There is no need to check for the count at all, just do a regular select for column E

    SELECT `E` FROM `furcodes` WHERE `B` = '$redeem_code'
    

    If no rows are returned, you know the code didn’t exist in table. If a row is returned, you can then check the returned value of E to see the status.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have database table with few text fields which i use to filter data
I have a database table structured like this (irrelevant fields omitted for brevity): rankings
I have a database table that I use as a queue system, where separate
i have database table like this +-------+--------------+----------+ | id | ip | date |
I have a database table named Categories . I want to create a form
I have a database table using an enum. This is already working with hibernate
I have a database table and one of the fields (not the primary key)
I have database table with the follwoing fields: id, loan_no, installment, status which has
I have Database table of Questions. I use the integer variable Id to sort
I have a database table containing fields RACE, ETHNICITY and ETH. I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.