Results 1 to 1 of 1
  1. #1
    New Lounger
    Join Date
    Jul 2014
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Help building PHP menu with update?

    Trying to get the handle on php and mysqli. hope to receive advice? following is current code.

    HTML Code:
    <!DOCTYPE><html><head><title>dropdown</title>
        <form name="form_update" method="post" action="">
    PHP Code:
     <?php
        $con
    =mysqli_connect("localhost","root","cookie","test");
        
    //============== check connection
        
    if(mysqli_errno($con))
        {echo 
    "Can't Connect to mySQL:".mysqli_connect_error();}
        else
        {echo 
    "Connected to database</br>";} 
       
       
    $id '';
       
    $cost ''
       if(isset(
    $_POST['cost']))
     { 
     
    $name $_POST['cost'];
        
    $fetch="SELECT cost FROM testbl WHERE cost = '".$name."'";
        
    $result mysqli_query($con,$fetch);    
        
    mysqli_query($con,"UPDATE testbl SET cost='$cost' WHERE id = '$id'");
        
    mysqli_close($con);
     } 
      
    ?>
    HTML Code:
     <form name="form" method="post" action="">
    <table border="0" cellspacing="1" cellpadding="2">
    <tr>
    <td>
    <select name="cost">
    <option value="" selected>Select product</option>
    <option value="10.00">doll</option>
    <option value="5.00">yoyo</option>
    </SELECT>
    <tr>
    <td><input name="update" type="submit" id="update" value="Update"></td>
    </tr></table></form>
    </body></html>
    Last edited by 12Strings; 2014-07-05 at 21:06.

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •