tet3828 Posted October 30, 2006 Share Posted October 30, 2006 Moving right along. Theses forums are helping me LEARN in INTREPRUT alot more than my 700 page php/mySQL book.I have a script that i've written. So far it selects the information form a row in a table and displays it in a conventinol html table.I want to have forms below my table to edit the stored data.The only stored data I am looking to modify for now is item Name, Price and description as I have not even thought of a way to approach the avilibilty and catagories. Ill tackel that later.the comments I've made in the script show what I have so far and where I left off: Thanks in advance if anyone can help:<?php/// Store Passed Data as $id$id = $_GET['id'];/// Select data from mySQL table$qry = "SELECT itemName,itemCat,itemSub,itemId,itemPrice,itemDesc,itemSmall FROM `products` WHERE `itemId`=\"$id\"";$result = mysql_query($qry) or die(mysql_error());/// edit page headerecho "Listed below is the stored data for the item #$id <br /> Use the fields below the item table to modify the information.";echo "<br /> ";echo "<br />";echo "<br />";/// Display item data loopwhile($row = mysql_fetch_array($result)){ echo "<table border=\"1\"><tr><td>".$row['itemName']."<td>".$row['itemId']."</td></td></tr>"; echo "<tr><td><img src=\"".$row['itemSmall']."\" /></td><td valign=top width=150>Description:<br />".$row['itemDesc']."</td>"; echo "</tr><tr><td>Price: $".$row['itemPrice']."</td><td>Avilibility: </td></tr>"; echo "<tr><td width=150>Catagory: ".$row['itemCat']."</td><td width=150>Sub-Catagory:".$row['itemSub']."</td></tr>";}echo "</table>";echo "<br / ";/// Display fields for data modification.... This is where Im stumped. Help :oif(!isset($_POST['submit'])){die("<html><body><form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">?> Quote Link to comment Share on other sites More sharing options...
jwk811 Posted October 30, 2006 Share Posted October 30, 2006 you'd have to use the UPDATE query.. you'll have to go UPDATE (which table) and SET (row) WHERE (something=something).. heres an example you should understand it after this.. this is to a password change in a membership thing[code]mysql_query("UPDATE users SET password='$db_password' WHERE email_address='$email_address'");[/code]here the table in the db is found.. the row that needs to be changed depending on the email address givenhope that helps Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 30, 2006 Share Posted October 30, 2006 assuming that "itemId" is always going to be an integer you might wanna type cast it for security (ebil sql injection!)[code]$id = $_GET['id'];[/code]would be safer as[code]$id = (int)$_GET['id'];[/code]always nicer to be paranoid ;D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.