Jump to content

ataloss

New Members
  • Posts

    3
  • Joined

  • Last visited

ataloss's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hi guys I just would to know the correct code for these two lines. thanks for the help. <input type=text size = 10 value="<?php echo '$playdate'?>"; <input type=text size = 10 value="playtime<?php echo '$time'?>";
  2. thanks guys for your observations. firstly, the "id" is there, I just don't know where to put it. the input field..please do corrrect me where I'm wrong, I'm thinking that input code was for entering arguments and wouldn't that defeat the purpose of the dropdown menu? I haven't quite caught on to this yet. thanks for further help.
  3. Hi fellows. I'm trying mysqli for the first time and failing miserably. I'm trying to select a value from a dropdown and update a field (taxrate) in a database (numbersdb)..The nessage I get is "update_taxrate' was not set, so no update attempted".Thanks for any help. <?php ini_set('display_errors', true); error_reporting(E_ALL); $dbconnect = mysqli_connect('localhost','root',''); if($dbconnect == false) { throw new Exception("Connect failed: ".mysqli_connect_error()); } if(mysqli_select_db($dbconnect, 'numbersdb') == false) { throw new Exception("Select DB failed: ".mysqli_error($dbconnect)); } $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'])) { // $id=$_POST['id']; $sql = "UPDATE numbdata SET taxrate = '$taxrate' WHERE id ='$id'"; $update = mysqli_query($dbconnect, $sql); if($update == false) { throw new Exception("Update query failed: ".mysqli_error($dbconnect).PHP_EOL.$sql); } echo "Taxrate set for ".mysqli_affected_rows($dbconnect)." row(s)."; } else { echo "'update_taxrate' was not set, so no update attempted."; } ?> <!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>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.