Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: need help with mysqli  (Read 4778 times)

0 Members and 1 Guest are viewing this topic.

12Strings

    Topic Starter


    Rookie

    • Experience: Experienced
    • OS: Windows 7
    need help with mysqli
    « on: November 14, 2013, 12:00:41 PM »
     What I'm trying to do is select once from the dropdown and use the selection
    to update the numbersdb database via the submit button. Thanks for your help.
    Code: [Select]
    <?php
    $dbconnect 
    mysqli_connect('localhost','root','');
       
    mysqli_select_db($dbconnect'numbersdb') or die( "Unable to select database");
        
    $taxrate = (isset($_POST['submit'])) ? mysqli_real_escape_string($dbconnect$_POST['taxrate']) : '';
       
    $id = (isset($_POST['id'])) ? mysqli_real_escape_string($dbconnect$_POST['id']) : '';
        
    $result mysqli_query($dbconnect"SELECT * FROM numbdata");
        if (!empty(
    $_POST['update_taxrate'])) {
         
    $update mysqli_query($dbconnect"UPDATE numbdata SET taxrate = '$taxrate' WHERE id ='$id'");
         echo 
    "Taxrate has been set ...";
       }
     
    ?>
    [/color]
    Code: [Select]
    [color=red]<!DOCTYPE html>
    <html>
       <head>
         <title>Select taxrate</title>
          <style type="text/css">
           body {
             background: #cff;
           }
           form {
             text-align: center;
           }
         </style>
       </head>
    <body>
       <form name="taxset" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
         <p><label>Select state/rate</label><p>
           <select name="taxrate">
             <option value="0.04000" selected>4% Alabama</option>
             <option value="0.05600">5.6% Arkansas</option>
           </select>
         </p>
         <!--<p><label>Update taxrate</label>
           <input type="text" name="update_taxrate">-->
         <p><input type="submit" name="submit" value="update"></p>
       </form>
    </body>
    </html>
     [/color]