why I can not update the table after you have done the process?

Hello

For now I create a reservation system of material for my new project and I have a problem to update the data after reserved for equipment. It should reduce the amount ask you in the store but nothing. Can someone help me?

Here is my code:

<?php
$connection = mysql_connect("localhost", "ayden", "pass"); // Establishing Connection with Server
$db = mysql_select_db("equipment", $connection); // Selecting Database from Server


$res= mysql_query("SELECT * FROM squash WHERE Equipment='".$equipment."'");
$row= mysql_fetch_array($res);


if(isset($_POST["submitBook"])){
$FullName=$_POST['FullName'];
$IDNumber=$_POST['IDNumber'];
$PhoneNumber=$_POST['PhoneNumber'];
$equipment=$_POST['equipment'];
$Quantity=$_POST['Quantity'];
$clockbox=$_POST['clockbox'];
$textsports=$_POST['textsports'];


$dbTableName=$_POST['tablename'];






  $sql     = "UPDATE squash SET Quantity=Quantity - '".$Quantity."' WHERE Equipment='".$equipment."'";
  $res = mysql_query($sql) or die("Could not update".mysql_error());

  echo "<script type='text/javascript'>alert('Successfully Booked!')</script>";
  header("Location:equipment.php");


}?>


hope someone can help me to check it and correct me...

Thank you.

You must assign the current amount to a variable using a while loop after the SELECT query:

$res = mysql_query ("SELECT * SQUASH WHERE the equipment =" ".") $equipment." "") ;

$row = mysql_fetch_array ($res);

While ($row = mysql_fetch_array ($res)) {}

assign the current quantity in the database to a variable

$currentQuantity = $row ['quantity'];

}

Then after the data of $_POST, you need to work on the new amount based on the amount of current less the $_POST ['quantity']

work on the new quantity

$newQuantity = $currentQuantity - $Quantity;

Then use variable $newQuantity to update the datbase:

$sql = "UPDATE SET quantity = squash" "." $newQuantity. "" WHERE the equipment = "". " $equipment. » "« ;"

Tags: Dreamweaver

Similar Questions

  • why I can not update the net framework I get faild 66A

    I have treid for the last month 5-day frame work net xp to Windows vista, but I get faild code 66A why, I need help everytime I update the only two major update, but it does not work, I thank you if you can help me

    Take a look at this link and see if it helps-

    http://social.answers.Microsoft.com/forums/en-us/vistawu/thread/3adefda0-69f3-4075-96ee-e2c61bd599cc>

    12:17:5708/07/11

  • Can not see my model after you have copied the site on laptop

    I copied a site I created in Dreamweaver CC computer I created it on a laptop. On the laptop, I am unable to create a new page of the model the model does not appear in the "New" menu even if it is in the list of files. In addition, changes to the template do not update child pages more. How to manage this site copied to make the model work properly?

    _templates is not a valid folder name.  It must be models or DW does not recognize them.

    Nancy O.

  • why I can not get the same apps I have on my iPad?

    why I can not get the same apps I have on my iPad?

    Because they are different versions for different operating systems.

  • why I can not change the method of payment and my billing information?

    why I can not change the method of payment and my billing information? By clicking on the buttons right just does not work

    Manage your membership and your payment. Creative cloud

    https://helpx.Adobe.com/x-productkb/policy-pricing/membership-subscription-troubleshooting-creative-cloud.html

    To the link below, click on the still need help? option in the blue box below and choose the option to chat or by phone (do not support the weekend)...
    Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache.  If it fails to connect, try to use another browser.

    Creative cloud support (all creative cloud customer service problems)
    http://helpx.Adobe.com/x-productkb/global/service-CCM.html ( http://adobe.ly/19llvMN )

  • Why I can not get the Norton Toolbar? In the menu, the add ons, extensions, it says Norton toolbar is inconsistent &amp; disabled.

    I can not get the norton for 36 firefox toolbar. Have run Norton live update repeatedly. He updated of all good and applied a patch. When I go to the firefox menu > Modules > extensions, toolbar Norton is grayed out and says he is not compatible with firefox 36 and is disabled. Help! I need my Norton safe.

    Hi Cathie7372, according to Norton the latest version of the toolbar is compatible with firefox 36 is 2014.7.10.26 - your watch as 2014.7.10. 16...

    as norton distributes the updates themselves we are probably not able to help much - please contact norton support if you do not receive the last update, even after running liveupdate repeatedly. they should be able to help get their product to date.

  • Can not update the settings on the Airport Express

    Currently have a facility - two extremes and an Express network.  I for the life of me can't update the Express settings. I always get an error message but I can update the settings on the two extremes very well. I can make changes to the Express with my Iphone but I can't with my Imac.  I want to activate the function of 5 GHz but I can't do that via my Iphone - with the desktop app I think.  Can someone help me?

    Let's first check and make sure that on which Airport Express version you have.

    Your version of the AirPort Express is there only 1 or 2 Ethernet ports?

    The Express to connect to your network and extend it wireless?  Alternatively, the Express connects to one of the extremes airport using a wired Ethernet cable connection.

    Then, I would be not too concerned of not being able to 'see' the Express of the iMac as long as you can access the settings of the iPhone. You can make almost any change using the iPhone you can use a Mac.

  • Satellite Pro A300D-161 why I can not download the latest version of the Bios Toshiba

    Hello

    I need your help because I can not download the latest version of the Bios for my laptop to the toshiba-europe support page.
    Either internet expoler 8, or firefox can not open the Bios download page.
    Why is this problem? Thre is anyway to fix it?

    Anyone have the same problem with me?

    Note: I am using windows xp and the version of the bios is * 3.10 * v as of 4/30/2009 +.

    Thanks in advance and sorry for my English, mike.

    Hello

    I checked the page European driver of Toshiba and I download of couldn t BIOS too...

    Seems that there is something wrong with the server

    However, I think that Toshiba will fix it in next time

    So I recommend you to check this page later

  • Amazon presentation question: can not update the library. The connection to the server has failed.

    I am presenting my application Viewer for the Amazon store. I had tested only on Android devices, because that's what I had at my disposal, and my APK worked perfectly on those.

    The apk android pulls my free folios with my retail ones and has in-app purchases fully configured and ready to hit the shelves.

    However, in my submission for the Amazon store process, I was rejected for the following error message appears when the testers tried to load my folio of the APK:

    "Can not update library." The connection to the server has failed. »


    This problem persisted with all Kindle devices and fire, with what they have tested.


    Can someone point me in the right direction from where I should be looking?



    Thanks in advance!

    Created a native Viewer, and it seems that the problem has been resolved.

  • Why XP does not display Japanese characters after you add the language pack?

    I installed XP on a new drive after a virus killed the other installation of it.  I noticed that XP did not display the titles to my Japanese music.  I tried to install the language pack, but he's really changed anything.  They were clearly visible on my old version before it crashed. Any suggestions?

    Imran M.

    Thanks for your reply!

    I need Japanese for display on all browsers (IE 8.0) and Opera, and I need it to appear inside Windows Media Player. (version 11).

    I do not download language files.  I only installed the language pack from my drive XP (service pack 2).

    Today, however, I started my computer and some "automatic updates" waiting to be installed.  I went ahead and install.  Afterwards, I checked WMP and all my Japanese music correctly displayed in Japanese.  (I don't know why).  Then, I went to IE and jumped a couple of Japanese pages and found that they were showing the language correctly.

    Then... I don't know how to solve the problem itself, but things seem to work the way I need them for.  It is a little frustrating not knowing how the problem has been fixed, in which case it should never show himself again, but no real sense to worry about this.

    Thanks for your help!

  • Can not stop the process after throwing the error in the OPS

    Dear Experts,

    I am oaf extension co page. I want to stop the process when getting the error after click on apply. I have written logic for error message

    if(vRowCount!= 0)

    {

    pageContext.writeDiagnostics (this, "vrowcoun t! 0 ", 1);

    throw new OAException ("xxThe number already exists", OAException.ERROR);

    }

    It throws the error as an exception, so that it continues the process. I would through error message and stop the process.

    Could someone explain to me how can I solve this problem?

    JDeveloper version: 10.1.3.3.0

    Thanks in advance.

    Here's the code extended co.

    package xxxpai.oracle.apps.ar.hz.components.address.webui;

    import java.sql. *;

    Import oracle.apps.ar.hz.components.address.webui.HzPuiAddressCreateUpdateCO;

    Import oracle.apps.fnd.common.MessageToken;

    Oracle.apps.fnd.framework import. *;

    Import oracle.apps.fnd.framework.server.OADBTransaction;

    Import oracle.apps.fnd.framework.webui.OADialogPage;

    Import oracle.apps.fnd.framework.webui.OAPageContext;

    Import oracle.apps.fnd.framework.webui.beans.OAWebBean;

    Import oracle.apps.fnd.framework.webui.beans.message.OAMessageLovInputBean;

    public class xxHzPuiAddressCreateUpdateCO extends HzPuiAddressCreateUpdateCO

    {

    public xxHzPuiAddressCreateUpdateCO()

    {

    }

    ' Public Sub processRequest (pageContext OAPageContext, OAWebBean webBean)

    {

    super.processRequest (pageContext, webBean);

    }

    ' Public Sub processFormRequest (pageContext OAPageContext, OAWebBean webBean)

    {

    If (PageContext.GetParameter ("Apply")! = null)

    {

    OAApplicationModule am2 = pageContext.getRootApplicationModule ();

    Connection con = pageContext.getApplicationModule (webBean) .getOADBTransaction () .getJdbcConnection ();

    pageContext.writeDiagnostics (this, "entered button1", 1);

    OAViewObject arvo = (OAViewObject) am2.findViewObject ("HzPuiPartySiteVO");

    String abtype = null;

    int vRowCount = 0;

    OAMessageLovInputBean vLOV = (OAMessageLovInputBean) webBean.findChildRecursive ("partySiteInformation0");

    If (vLOV! = null)

    {

    abtype = vLOV.getValue (pageContext) m:System.NET.SocketAddress.ToString ();

    pageContext.writeDiagnostics(this,_(new_StringBuilder()).append ("xxx view object is not null, abtype") .append (abtype) m:System.NET.SocketAddress.ToString (), 1);

    }

    pageContext.writeDiagnostics(this,_(new_StringBuilder()).append ("attribute is") .append (abtype).append("_").toString(), 1);

    Try

    {

    String s1 = (new StringBuilder()).append("").toString ().append("SELECT_no_active_plots_FROM_XXPAI_REF_PLOTS_CONTRCT_VW_where_ref_number_=").append (abtype);

    PreparedStatement vpreparedsatement = con.prepareStatement (s1);

    ResultSet vresultset = vpreparedsatement.executeQuery ();

    pageContext.writeDiagnostics(this,_(new_StringBuilder()).append ("Select is instruction") .append (s1) m:System.NET.SocketAddress.ToString (), 1);

    If (vresultset. Next())

    {

    vRowCount = vresultset.getInt (1);

    pageContext.writeDiagnostics (this, "vRowCount value is" + vRowCount, 1);

    vresultset. Close();

    vpreparedsatement. Close();

    }

    }

    catch (System.Exception e)

    {

    throw OAException.wrapperException (e);

    }

    pageContext.writeDiagnostics(this,_(new_StringBuilder()).append ("vRowCount xxxx") .append (vRowCount) m:System.NET.SocketAddress.ToString (), 1);

    If (vRowCount! = 0)

    {

    pageContext.writeDiagnostics (this, "vrowcoun t! 0 ", 1);

    throw new OAException ("xxThe number already exists", OAException.ERROR);

    }

    }

    super.processFormRequest (pageContext, webBean);

    }

    }

    Hi, I found the solution, I used chips by using the following code.

    MessageToken chips [] = {new MessageToken("ATTRIBUTE3","abtype")};

    OAException errorMessage = new OAException("AR","XX_CUSTOMER_PAGE",tokens,OAException.ERROR,null);

    pageContext.putDialogMessage (errorMessage);

    pageContext.writeDiagnostics(this,_(new_StringBuilder()).append ("xxx before you throw new OAException') .append (vRowCount) m:System.NET.SocketAddress.ToString (), 1);

    pageContext.writeDiagnostics (this, "error message is" + errorMessage, 1);

    pageContext.forwardImmediately ("OA.jsp?page=/oracle/apps/ar/cusstd/acctSite/webui/ArAcctSiteOverviewPG",

    NULL,

    OAWebBeanConstants.KEEP_MENU_CONTEXT,

    NULL,

    NULL,

    true,

    OAWebBeanConstants.ADD_BREAD_CRUMB_NO);

    But, here, I want to update the record already exists, its getting eror

  • Hello, why I can not install the trial version?

    I tried several times and days, but still nothing. It appears on the screen 4 rolling boxes and nothing more. Can you help me please?

    Hello

    Looks like as you progress the creative application of cloud spinning wheel

    Reference:--

    Please check the help below document:

    Does not open App | Wheels of progress turn continuously

    You can also view the nets below where this issue has been addressed:

    Adobe Creative Cloud / Desktop App / Home Screen: constant spinning wheel

    Creative Cloud Desktop App taped blue spinning wheel after update.

  • 80070005 "Sorry, we can not update the web filter now" for a month

    I get this message every time I try to refresh the filter for a month.  It is also the 80070005 error.  It happened on two PCs at the same time, and my kids are totally locked on two PCs, so they use the account of a parent, that completely breaks the security.  How can I fix it?  All I could find online is one of the user accounts may be damaged and I have to delete user accounts.  I hope not.

    It turns out that the problem is that I've changed the e-mail alias is primary on Outlook.com.  I ended up uninstalling parental controls, reinstall and alias primary with my new signature.  I'm now able to download the updated the site settings.

    Thank you!

  • Why I can not get the value of the element on the tabular layout?

    Product, version, OS: Forms [32 bit] Version 9.0.4.0.19 + WinXP

    I have create a tabular layout and I inserted 3 records in [a TIME-NEW-FORM-INSTANCE], then I created a test button.
    But when I press the button, I can't get the value of the item on tabular layout.

    Can someone tell me why? any suggestion is appreciated.

    [A TIME-NEW-FORM-INSTANCE]:
    go_block('selected_stock_list');
    first_record;
    :selected_stock_list.stock_id   := '1001';
    :selected_stock_list.stock_desc := 'AAA';
    next_record;
    :selected_stock_list.stock_id   := '1002';
    :selected_stock_list.stock_desc := 'BBB';
    next_record;
    :selected_stock_list.stock_id   := '1003';
    :selected_stock_list.stock_desc := 'CCC';
    first_record;
    [WHEN BUTTON PRESSED]:
    go_block('SELECTED_STOCK_LIST');
    first_record;
    loop
       if :selected_stock_list.stock_id is not null then
         --message('abc');
         message('stock_id:'||nvl(:selected_stock_list.stock_id,'XXX')); pause;
      end if;
      if :system.last_record = 'TRUE' then
        exit;  -- reached last record so exit loop
      else
        next_record;
      end if;
    end loop;

    Remove the break or see the status bar

    Please mark helpful/correct

    Iqbal

    Published by: Sabrina on May 3, 2009 20:50

  • Can not update the RAM on Satellite Pro 4300 to 320 MB

    Hello

    My 4300 Pro Satellite has two memory slots (A and B).

    My computer initially had 64 MB in the slot a (PA3004U).

    Now I plugged in both modules of memory of 128 MB (PA3005U) but I get only 192 MB!

    What I am doing wrong? What do I need to enable something in the BIOS?

    Thanks in advance

    Hi Juan29 ;) greetings from Juan28 :D

    OK now to your problem:
    I m not 100% sure but I think the 64 MB could be an internal memory and usually such module memory can not be removed. In addition it is possible that the memory of this unit can be improved to the amount of the 192 MB (64 MB + 128 MB)

Maybe you are looking for