Jump to content

Search the Community

Showing results for tags 'mysql mass update form'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hey people, I am faced with a problem that I need guidance with in order to solve. I have a catering website that is connected to a mysql database that has a back end to do changes to the menu. I have created an update page that originally updated the price but I was asked for it to update all the fields with any changes being made on the page, sounds simple right? Only problem is, is that the data that is being displayed is pulled from the database and displayed as values in input boxes so that the user can make changes. Each input box has a nameid which is a unique number that is pulled from the database that is stored in a field for each entry. I want it so that the user can change any input box data and click on the one button and it update the records to each correct field based on their own unique id. Here is the code for the front end <form action="chstarterprice.php" method="post"> <br><br> <?php include("connection.php"); $result= mysql_query("SELECT title, subtext, nameid, category, price FROM starters"); while($row = mysql_fetch_array($result)) { $nameid = $row['nameid']; $title = $row['title']; $subtext = $row['subtext']; $category = $row['category']; $price = $row['price']; echo"<table>"; echo"<tr>"; echo"<td width=\"70px\">"; echo"<p class=\"form2\">"; echo "<b>Title</b>"; echo"</td>"; echo"<td width=\"120px\">"; echo"<p class=\"form2\">"; echo "<b>Subtext</b>"; echo"</td>"; echo"<td width=\"80px\">"; echo"<p class=\"form2\">"; echo "<b>Category</b>"; echo"</td>"; echo"<td width=\"80px\">"; echo"<p class=\"form2\">"; echo "<b>Price</b>"; echo"</td>"; echo"</tr>"; echo"<tr>"; echo"<td width=\"120px\">"; echo"<p class=\"form2\">"; echo"<input type=\"text\" name=\"$nameid\" value=\"$title\">"; echo"</td>"; echo"<td width=\"80px\">"; echo"<p class=\"form2\">"; echo"<input type=\"text\" name=\"$nameid\" value=\"$subtext\">"; echo"</td>"; echo"</td>"; echo"<td width=\"80px\">"; echo"<p class=\"form2\">"; echo"<input type=\"text\" name=\"$nameid\" value=\"$category\">"; echo"</td>"; echo"<td width=\"120px\">"; echo"<p class=\"form2\">"; echo"<input type=\"text\" name=\"$nameid\" value=\"$price\">"; echo"</td>"; echo"</tr>"; echo"<tr>"; echo"</tr>"; echo"</table>"; } mysql_close($con); ?> <br> <input name="Submit" type="submit" value="Change" /></p> </form> Here is the backend script that processes the form data <? ob_start(); ?> <?php include("connection.php"); $nameid = $_POST['nameid']; $query = "update starters set title, subtext, nameid, category, price = ('$_POST[nameid]') where 'starters'.'nameid' = '$nameid' or die(mysql_error)"; if(mysql_query($query)){ header("location:change-prices.php");} else{ header("location:change-prices.php");} ?> <? ob_flush(); ?> If you guys can point me in the right direction with the code to make this work I would be greatly appreciated, I am really sure that it has something to do with the backend script as opposed to the front end. Please get back to me, thanks guys. Mitch
×
×
  • 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.