Jump to content

Archived

This topic is now archived and is closed to further replies.

kikilahooch

trying to update fields

Recommended Posts

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

Share this post


Link to post
Share on other sites
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 [i]Click here to modify and delete Records[/i] in admin_index.php. You'll get some results

http://snet.wit.ie/~ciaracousins/admin_delete.php?login=true&id=1

Share this post


Link to post
Share on other sites
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.

[code]
<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>
[/code]


Share this post


Link to post
Share on other sites
Try this:
[code]<?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>[/code]
I changed your get/post vars to $_REQUEST. $_REQUEST includes _POST and _GET vars.

Share this post


Link to post
Share on other sites
It threw me this error that time:

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

Query was empty

Share this post


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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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/~ciaracousins/admin_update2.php?login=true&shopName=savage&prodId=2

Share this post


Link to post
Share on other sites
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:
[code]<?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>[/code]

I ahve rewritten the code a bit,

Share this post


Link to post
Share on other sites
I had a few typos in that last code, try this:
[code]<?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>[/code]

Share this post


Link to post
Share on other sites
Oops. I typed $_POST['submittedUpdated'] instead of $_POST['submittedUpdate']. Try this:
[code]<?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>[/code]
This code has been revised even more!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
I found out the problem You have a hidden field called shopName. The value of that field wan't being populated. I have now fixed that. Try this:
[code]<?php
#Script 7.3 - register.php
include "db.php";

if(isset($_POST['submittedUpdate']))
{
    foreach($_POST as $key => $value)
    {
        ${$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">
      ';

    $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>
      <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>[/code]
Should be the last time now!

I also removed the if in the foreach loop. it was also the cause of the problem.

Share this post


Link to post
Share on other sites
lol, almost there I hope! Just getting some error messages now, it said there was an inexpected ')' on this line

$row = mysql_fetch_array($result1, MYSQL_ASSOC))

So I removed the 2nd ')'

now I get the message


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

line 99:

[code]  echo'<tr>//line 99
        <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td>
        <td align="left">' . $row['prodId'] . '</td>
      </tr>
[/code]

Share this post


Link to post
Share on other sites
I just found another bug in my code. Change this:
$row = mysql_fetch_array($result1, MYSQL_ASSOC))

to this:
$row = mysql_fetch_array($result1, MYSQL_ASSOC);

I did noticedyou had trouble

Share this post


Link to post
Share on other sites
Wooo Hooo!! Its working! lol, thanks wildteen your a legend!! As you can see I know nothing about coding! lol. I have a delete page to do now, hopefully it will be pretty much the same but change the sql in it, think I'm gonna leave that till tomorrow though! Thanks for giving up your day, really appreciate it!  :)

Share this post


Link to post
Share on other sites
No problem! Glad we got there in the endm only took 7hours! :). I know I changed your code a lot post any questions you have about the code I used here and I'll answer them for you.

Share this post


Link to post
Share on other sites

×

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.