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 7493447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:57:41+00:00 2026-05-29T16:57:41+00:00

I have a system where i want to up date a record, change its

  • 0

I have a system where i want to up date a record, change its status between 0 and 1. To turn a feature on or off. This is my form to turn it on or off:

<form id="form1" name="form1" method="post" action="">
            <label>
                Select Market: 
                    <select name="market" id="market">
                        <option value="EUR/USD">EUR/USD</option>
                        <option value="gbpusd">GBP/USD</option>
                        <option value="chfusd">CHF/USD</option>
                        <option value="brent">Brent</option>
                        <option value="GOLD">Gold</option>
                        <option value="downjones">Down Jones</option>      
                    </select>
            </label>
            <label>
                <input type="submit" name="on" id="on" value="On">
                <input type="submit" name="off" id="off" value="Off">
            </label>
        </form>

Now this is the php for updating the record:

if(isset($_POST['on']))
{
    if(isset($_POST['market']))
    {
        if($_POST['market'] == 'EUR/USD')
            $market_id = '1';

        $updateRecord = mysql_query("UPDATE current_trades SET status='1' WHERE id='$market_id'");

        //Update record by turning it on
        echo "market on";
    }
}

So as you can see, the user would select a value from the drop down menu and the hit on or off to turn that feature on or off. But when i click on (Which is the only one with logic so far) it doesn’t update my record, any see anything wrong with that?

I don’t think its anything to do with permissions because i have other pages editing other tables in my database.

also if i go into phpMyAdmin and run the Mysql from there it works.

I have also tested just grabbing some records from my database and this works just fine.

So any ideas?

  • 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-05-29T16:57:44+00:00Added an answer on May 29, 2026 at 4:57 pm

    The problem is $market_id is not defined (except when $_POST['market'] == 'EUR/USD'), so the updated query will fail (it will look for records WHERE id='', which is probably none).

    Maybe you also want the mysql_query and echo lines inside the if? In this case, you need { and } around the whole block:

    if($_POST['market'] == 'EUR/USD') {
        $market_id = '1';
        $updateRecord = mysql_query("UPDATE current_trades SET status='1' WHERE id='$market_id'");
        //Update record by turning it on
        echo "market on";
    }
    

    EDIT

    I re-read your question, and now I think the code I suggested is not what you need. What you need is to have a proper $market_id set for each possible selected value from #market. The easiest solution would be to make the value attribute of each <option> the market id, like

    <option value="1">EUR/USD</option>
    

    Then you PHP you’d just do $market_id = is_numeric($_POST['market']) ? $_POST['market'] : 0;.

    If you don’t want that, you’ll need a switch statement on your PHP, or a bunch of if/else. The important thing here is that you need a different $market_id set for each situation, so you can run the right query based on that.

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

Sidebar

Related Questions

I have a System.Windows.Forms.ComboBox on a form and I want to capture the event
I have a System.Windows.Forms.Button control, and I want to add a hover-text explanation of
First I have install Mac 10.6.3 on my system now I want to install
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have a requirement that i want to get all the system services running
I have an object of the type System.Drawing.Image and want to make every pixel
I have a web application that I want to run some system tests on,
I want to ensure I have done all I can to configure a system's
I have built a php mail system. now I want to also send attachments
I have a problem with the system function. I want to store the system

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.