Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Requests
How to edit items from SQL table in a html form
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Markshall" data-source="post: 330556" data-attributes="member: 1872"><p>You need to refer to the specific ID of that item of furni and SELECT the information you need from the row then echo it out into the HTML form, then use the <a href="http://www.w3schools.com/sql/sql_update.asp" target="_blank">UPDATE</a> key in SQL to submit the changed data.</p><p></p><p>I hate spoon feeding but I'll show you a quick example:</p><p></p><p>So here, you would go to a link such as <em>boonrares.site88.net/admin/edit.php?furniid=34</em> and it would grab information from the furni item with an ID of 34 in your database.</p><p>[PHP]<?php</p><p>$FurniID = (int)$_GET['furniid'];</p><p></p><p>$Furni = $db->query("SELECT * FROM `furni` WHERE `FurniID` = '{$FurniID}'");</p><p>if ($Furni->num_rows > 0) {</p><p> $FurniRow = $Furni->fetch_array();</p><p> echo '<form action="post"></p><p> Name: <input type="text" name="name" id="name" value="' . $FurniRow['Name'] . '" /><br /></p><p> Cost: <input type="text" name="cost" id="cost" value="' . $FurniRow['Cost'] . '" /><br /><br /></p><p> </p><p> <input type="submit" name="save" value="Save changes" /></p><p> </form>';</p><p>} else {</p><p> echo 'This furni item doesn\'t exist in our database.';</p><p>}[/PHP]</p></blockquote><p></p>
[QUOTE="Markshall, post: 330556, member: 1872"] You need to refer to the specific ID of that item of furni and SELECT the information you need from the row then echo it out into the HTML form, then use the [URL='http://www.w3schools.com/sql/sql_update.asp']UPDATE[/URL] key in SQL to submit the changed data. I hate spoon feeding but I'll show you a quick example: So here, you would go to a link such as [i]boonrares.site88.net/admin/edit.php?furniid=34[/i] and it would grab information from the furni item with an ID of 34 in your database. [PHP]<?php $FurniID = (int)$_GET['furniid']; $Furni = $db->query("SELECT * FROM `furni` WHERE `FurniID` = '{$FurniID}'"); if ($Furni->num_rows > 0) { $FurniRow = $Furni->fetch_array(); echo '<form action="post"> Name: <input type="text" name="name" id="name" value="' . $FurniRow['Name'] . '" /><br /> Cost: <input type="text" name="cost" id="cost" value="' . $FurniRow['Cost'] . '" /><br /><br /> <input type="submit" name="save" value="Save changes" /> </form>'; } else { echo 'This furni item doesn\'t exist in our database.'; }[/PHP] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Requests
How to edit items from SQL table in a html form
Top