Jump to content


Photo

trying to update fields


  • Please log in to reply
44 replies to this topic

#21 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 06:37 PM

In query1:
UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price'
WHERE prodId ='$prodId' and shopName='$shopName'

You use $prodName to update the prodName field. Where does $prodName come from, as this is mostl ikey why it is being deleted as $prodName doesnt exist

To redarrow -mysql_result is basically another form of retrieve results from an SQL Query. I have not used this before so I cant really explain it. Have a read in the manual about it http://php.net/mysql-query

#22 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 06:45 PM

Aaah I'm stupid! That has solved the deleting problem! Thanks Wildteen!! Now when I try to update something it says:

Unknown column 'INVALID' in 'where clause'

#23 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 06:51 PM

Oh crap. Another typo of mine.
Change this:
$prodId = isset($_GET['prodId']) && is_numeric($_GET['prodId']) ? $_GET['prodId'] : 'INVALID';

if($prodid == 'INVALID')
{
    die('<h1>Invalid Production Identification</h1>');
}
to this:
$prodId = isset($_GET['prodId'])) ? $_GET['prodId'] : '0'


#24 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 07:06 PM

ok so I changed the code to that

$prodId = 0;   // wasnt sure if this was to be left in but it doenst seem to make any difference when I take it out

$prodId = isset($_GET['prodId']) ? $_GET['prodId'] : '0'


$sql = "SELECT * FROM product WHERE prodId=$prodId";// line 77

now it says

Parse error: parse error, unexpected T_VARIABLE in /home/c/ciaracousins/public_html/admin_update2.php on line 77


#25 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 07:14 PM

Sorry, I am not being very alert today. Use this:
$prodId = isset($_GET['prodId']) ? $_GET['prodId'] : '0';

I forgot the semi-colon, at the end of the line.


#26 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 07:22 PM

ok its throwing no error messages now. Its still not updating. The URL just says http://snet.wit.ie/~...min_update2.php



#27 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 07:26 PM

Okay you are ussing POST as the method to submit the forms, but in your PHP script you use $_GET. $_GET retrieves the url parameters in the URL. Whereas $_POST retrieves the posted data. So chnage $_GET to $_POST in your code. Does it work now?

If you add 1 to the end of the url when you click the Click here to modify and delete Records in admin_index.php. You'll get some results

http://snet.wit.ie/~...login=true&id=1

#28 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 07:43 PM

Ok now its not bringing up the table with the details to be updated because its not getting the values from the URL. This is the problem I've been having for the past few days. I changed Get to Post in this line

$prodId = isset($_POST['prodId']) ? $_POST['prodId'] : '0';

The way I am passing the details through is appending the prodId to the URL.

<td align="center"><a href="admin_update2.php?login=true&shopName='.$row['shopName'].'&prodId='.$row['prodId'].'"><img src="http://snet.wit.ie/~ciaracousins/clothes/' . $row['image'] . '"></a>




#29 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 08:00 PM

Try this:
<?php
#Script 7.3 - register.php
include "db.php";

$prodId = 0;   // UPDATED
$prodId = isset($_REQUEST['prodId']) ? $_REQUEST['prodId'] : '1';

$sql = "SELECT * FROM product WHERE prodId=$prodId";

$result = mysql_query($sql, $conn) or die(mysql_error()); //comment out if not working

if (mysql_num_rows($result) == 1)
{
    //if authorized, get the values of prodId, shopName...
	$prodId 	= mysql_result($result, 0, 'prodId');
	$shopName	= mysql_result($result, 0, 'shopName');
	$dept 		= mysql_result($result, 0, 'dept');
	$brand 	    = mysql_result($result, 0, 'brand');
	$type		= mysql_result($result, 0, 'type');
	$image  	= mysql_result($result, 0, 'image');
	$price 	    = mysql_result($result, 0, 'price');

    $query1 = "UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'";

	$result = @mysql_query($query1) or die("Unable to perform query1 <code>" . $query1 . "</code><br /><br />" . mysql_error());

    echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>';

    $query2 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'";

    $result2 = @mysql_query($query) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());

    echo'<form action="admin_update2.php" method="post">
  <center>
    <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">
      ';

    while($row = mysql_fetch_array($result2, MYSQL_ASSOC))
    {
        echo'<tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td>
        <td align="left">' . $row['prodId'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
        <td align="left">' . $row['shopName'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
        <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
        <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
        <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td>
      </tr>
';
    }

    echo'      <tr>
        <td align="center">
          <p><input type="submit" name="submit" value="UPDATE"/>
		  <input type="reset" value="CLEAR FORM"></p>

          <input type="hidden" name="prodId" value=' . $prodId . '>
          <input type="hidden" name="shopName" value=' . $sName . '>

          <input type="hidden" name="submittedUpdate" value="TRUE"/>
        </td>
      </tr>
    </table>
  </center>
</form>';
}

if(isset($_POST['submitted']))
{
    $prodId = trim($_REQUEST['prodId']);
	$shopName= $_REQUEST['shopName'];

    $query3 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'";

    $result3 = @mysql_query($query3) or die("Unable to perform query3 <code>" . $query3 . "</code><br /><br />" . mysql_error());

    echo'<form action="admin_update.php" method="post">
  <center>
    <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">
      ';

    while($row = mysql_fetch_array($result3, MYSQL_ASSOC))
    {
        echo'<tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id</b></center></td>
        <td align="left">' . $row['prodId'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
        <td align="left">' . $row['shopName'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
        <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
        <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
        <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td>
      </tr>
      ';
    }
    echo'<tr>
        <td align="center">
          <input type="submit" name="submit" value="UPDATE"/>
          <!--<input type="reset" value="CLEAR FORM"></p>-->
        </td>
      </tr>
     <tr>
        <td align="center">
          <input type="hidden" name="prodId" value=' . $prodId . '>
          <input type="hidden" name="shopName" value=' . $shopName . '>
          <input type="hidden" name="submittedUpdate" value="TRUE"/>
        </td>
      </tr>
    </table>
  </center>
</form>';
}

?>
</body>
</html>
I changed your get/post vars to $_REQUEST. $_REQUEST includes _POST and _GET vars.

#30 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 08:05 PM

It threw me this error that time:

Unable to perform query2 SELECT * FROM product WHERE prodId = '106' and shopName='savage'

Query was empty

#31 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 08:10 PM

Sorry I copied my old code I used earlier.
Chnage this:
$result2 = @mysql_query($query) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());
To this:
$result2 = @mysql_query($query2) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());


#32 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 08:16 PM

ok now it is showing the details in the table again, but when I click on the update button it just changes the value back to what it was before. For example I wanted to change the price of a product. In the table it was 49.99 but I changed it to 39.99. When I clicked on UPDATE, it just changed back to 49.99

#33 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 08:21 PM

Okay looking at the html output, you have a submit button named submittedUpdate in the update page but in your PHP code you use $_POST['submitted'] to get your submit button

So change $_POST['submitted']  to $_POST['submittedUpdate'] and you should be good to go.

#34 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 08:41 PM

Its still not working, when I did that and clicked on update it created and second update button and the it still changes it back to the original value. I seem to have 2 values for submit

You can check it yourself what I mean

http://snet.wit.ie/~...savage&prodId=2

#35 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 08:55 PM

Are I see whats happening now. When you click the update button, you are not updating the database. What you're doing is querying the database to retrive the data again. So it resets the form data

Try this:
<?php
#Script 7.3 - register.php
include "db.php";

$prodId = 0;   // UPDATE

if(isset($_GET['prodId']) && is_numeric($_GET['prodId']))
{
    $prodId = $_GET['prodId'];

    $query1 = "SELECT * FROM product WHERE prodId=$prodId";

    $result1 = mysql_query($query1, $conn) or die(mysql_error()); //comment out if not working

    if (mysql_num_rows($result1) == 1)
    {

        echo'<form action="admin_update2.php" method="post">
      <center>
        <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">
          ';

        while($row = mysql_fetch_array($result1, MYSQL_ASSOC))
        {
            echo'<tr>
            <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td>
            <td align="left">' . $row['prodId'] . '</td>
          </tr>
          <tr>
            <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
            <td align="left">' . $row['shopName'] . '</td>
          </tr>
          <tr>
            <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
            <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td>
          </tr>
          <tr>
            <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
            <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td>
          </tr>
          <tr>
            <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
            <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td>
          </tr>
    ';
        }

        echo'      <tr>
            <td align="center">
              <p><input type="submit" name="submit" value="UPDATE"/>
    		  <input type="reset" value="CLEAR FORM"></p>

              <input type="hidden" name="prodId" value="' . $prodId . '">
              <input type="hidden" name="shopName" value="' . $row['shopName'] . '">

              <input type="hidden" name="submittedUpdate" value="TRUE"/>
            </td>
          </tr>
        </table>
      </center>
    </form>';
    }
}
elseif(isset($_POST['submittedUpdated']))
{
    foreach($_POST as $key => $value)
    {
        if($key != 'prodId' || $key != 'shopName')
        {
            $$key = mysql_real_escape_string($value);
        }
    }

    $query3 = "UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'";
    $result3 = @mysql_query($query3) or die("Unable to perform query3 <code>" . $query3 . "</code><br /><br />" . mysql_error());

    echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>';

    $query4 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'";
    $result4 = @mysql_query($query4) or die("Unable to perform query4 <code>" . $query4 . "</code><br /><br />" . mysql_error());

    echo'<form action="admin_update.php" method="post">
  <center>
    <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">
      ';

    while($row = mysql_fetch_array($result4, MYSQL_ASSOC))
    {
        echo'<tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id</b></center></td>
        <td align="left">' . $row['prodId'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
        <td align="left">' . $row['shopName'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
        <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
        <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
        <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td>
      </tr>
      ';
    }
    echo'<tr>
        <td align="center">
          <input type="submit" name="submit" value="UPDATE"/>
        </td>
      </tr>
     <tr>
        <td align="center">
          <input type="hidden" name="prodId" value="' . $prodId . '">
          <input type="hidden" name="shopName" value="' . $shopName . '">
          <input type="hidden" name="submittedUpdate" value="TRUE"/>
        </td>
      </tr>
    </table>
  </center>
</form>';
}

?>
</body>
</html>

I ahve rewritten the code a bit,

#36 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 09:02 PM

Its still going back to the original value  ???... Its got rid of the second button though

#37 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 09:06 PM

I had a few typos in that last code, try this:
<?php
#Script 7.3 - register.php
include "db.php";

$prodId = 0;   // UPDATE

if(isset($_GET['prodId']) && is_numeric($_GET['prodId']))
{
    $prodId = $_GET['prodId'];

    $query1 = "SELECT * FROM product WHERE prodId=$prodId";
    $result1 = mysql_query($query1, $conn) or die("Unable to perform query1 <code>" . $query1 . "</code><br /><br />" . mysql_error());

    if (mysql_num_rows($result1) == 1)
    {

        echo'<form action="admin_update2.php" method="post">
      <center>
        <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">
          ';

        while($row = mysql_fetch_array($result1, MYSQL_ASSOC))
        {
            echo'<tr>
            <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td>
            <td align="left">' . $row['prodId'] . '</td>
          </tr>
          <tr>
            <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
            <td align="left">' . $row['shopName'] . '</td>
          </tr>
          <tr>
            <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
            <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td>
          </tr>
          <tr>
            <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
            <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td>
          </tr>
          <tr>
            <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
            <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td>
          </tr>
    ';
        }

        echo'      <tr>
            <td align="center">
              <p><input type="submit" name="submit" value="UPDATE"/>
    		  <input type="reset" value="CLEAR FORM"></p>

              <input type="hidden" name="prodId" value="' . $prodId . '">
              <input type="hidden" name="shopName" value="' . $row['shopName'] . '">

              <input type="hidden" name="submittedUpdate" value="TRUE"/>
            </td>
          </tr>
        </table>
      </center>
    </form>';
    }
}
elseif(isset($_POST['submittedUpdated']))
{
    foreach($_POST as $key => $value)
    {
        if($key != 'prodId' || $key != 'shopName' || $key != 'submittedUpdated')
        {
            $$key = mysql_real_escape_string($value);
        }
    }

    $query2 = "UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'";
    $result2 = @mysql_query($query2) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());

    echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>';

    $query3 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'";
    $result3 = @mysql_query($query3) or die("Unable to perform query3 <code>" . $query3 . "</code><br /><br />" . mysql_error());

    echo'<form action="admin_update.php" method="post">
  <center>
    <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">
      ';

    while($row = mysql_fetch_array($result3, MYSQL_ASSOC))
    {
        echo'<tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id</b></center></td>
        <td align="left">' . $row['prodId'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
        <td align="left">' . $row['shopName'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
        <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
        <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
        <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td>
      </tr>
      ';
    }
    echo'<tr>
        <td align="center">
          <input type="submit" name="submit" value="UPDATE"/>
        </td>
      </tr>
     <tr>
        <td align="center">
          <input type="hidden" name="prodId" value="' . $row['prodId'] . '">
          <input type="hidden" name="shopName" value="' . $row['shopName'] . '">
          <input type="hidden" name="submittedUpdate" value="TRUE"/>
        </td>
      </tr>
    </table>
  </center>
</form>';
}

?>
</body>
</html>


#38 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 09:12 PM

Now when I click on update it just brings me to a blank admin_update2.php page

#39 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 09:17 PM

Oops. I typed $_POST['submittedUpdated'] instead of $_POST['submittedUpdate']. Try this:
<?php
#Script 7.3 - register.php
include "db.php";

if(isset($_POST['submittedUpdate']))
{
    foreach($_POST as $key => $value)
    {
        if($key != 'prodId' || $key != 'shopName' || $key != 'submittedUpdated')
        {
            $key = mysql_real_escape_string($value);
        }
    }

    $query2 = "UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'";
    $result2 = @mysql_query($query2) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());

    echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>';

}

$prodId = 0;

if(isset($_REQUEST['prodId']) && is_numeric($_REQUEST['prodId']))
{
    $prodId = $_REQUEST['prodId'];
}

$query1 = "SELECT * FROM product WHERE prodId=$prodId";
$result1 = mysql_query($query1, $conn) or die("Unable to perform query1 <code>" . $query1 . "</code><br /><br />" . mysql_error());

if (mysql_num_rows($result1) == 1)
{
    echo'<form action="admin_update2.php" method="post">
  <center>
    <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">
      ';

    while($row = mysql_fetch_array($result1, MYSQL_ASSOC))
    {
        echo'<tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td>
        <td align="left">' . $row['prodId'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td>
        <td align="left">' . $row['shopName'] . '</td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td>
        <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td>
        <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td>
        <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td>
      </tr>
      ';
    }

    echo'<tr>
        <td align="center">
          <p>
            <input type="submit" name="submit" value="UPDATE"/>
    	    <input type="reset" value="CLEAR FORM">
          </p>

          <input type="hidden" name="prodId" value="' . $prodId . '">
          <input type="hidden" name="shopName" value="' . $row['shopName'] . '">

          <input type="hidden" name="submittedUpdate" value="TRUE"/>
        </td>
      </tr>
    </table>
  </center>
</form>';
}

?>
</body>
</html>
This code has been revised even more!

#40 kikilahooch

kikilahooch
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 02 September 2006 - 09:24 PM

Still not working! I wasnt sure whether the submittedUpdate mattered in this line

if($key != 'prodId' || $key != 'shopName' || $key != 'submittedUpdated')

But I changed it to

if($key != 'prodId' || $key != 'shopName' || $key != 'submittedUpdate')

to try it but still didnt make any difference




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users