Jump to content

need help Modifying data stored in MySQL tables with PHP


tet3828

Recommended Posts

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 header
echo "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 loop
while($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 :o
if(!isset($_POST['submit']))
{
die("<html><body><form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">


?>
Link to comment
Share on other sites

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 given

hope that helps
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.