Jump to content

update statement


witham

Recommended Posts

I am having alot of trouble getting some data to update, the problem I have is that I wish to update one particular  "prodequiv" but I cannot stop them all changing?

I have a page that allows data entry into two variables called 'Equivalent' and 'newequiv'.

[code]
$result  = mysql_query($sqlPRODNAME, $dblink)
or die("<p>Error Processing Query</p><hr /><p>".mysql_error()."</p>\n");



// mysql_fetch_array fetches the results from the query a row at a time and populates the drop down box each time it's called
// the result is returned as an array that can be referenced either by field name or by it's index, "ALL" is hardcoded because
//it is always constant and allows the % query to be executed


echo '<td><select name="Equivalent">';

while ($row = mysql_fetch_array ($result))



// loop through the rows outputing them as select options
  {
echo '<option value="' . $row["PRODEQUIV"] . '">' . $row["PRODEQUIV"] . "</option>";
  }
?>
</select></td></tr>

  <tr>
      <td><b>
New Equivalent Name:</b>
      </td>
      <td><input type text name="newequiv">
      </td>
  </tr>





<!--The other part of the form is hardcoded as the types of lubricant are constant-->


<!--Close the last selection box and put a submit button named "display results from equivalents database" to send the
data to query.php for processing-->
<tr><td colspan = 2 align = center class="style3"><button type="submit">AMEND EQUIVALENT NAME</button></td></tr>[/code]

These are passed to another page that has this statement:

[code]$sqlAMEND = "UPDATE prodname SET
  prodequiv = '$newprod' where
  prodequiv = '$Equivalent'
  and PRODID = prodid;";[/code]

But it just changes every 'prodequiv' entry, I have changed this and stared at it for days but can't get it to work. Could anyone please help!!!!
Link to comment
Share on other sites

I think that  '$Equivalent' holds the product equivalent selected from the database by the user and '$newequiv' holds the desired update. So I would think (using my limited knowledge) that what I need to do is:

1). Take the data contained within '$newequiv' (sorry this is posted as '$newprod' mis-type)

2). Take the selected product contained within '$Equivalent'; 

3). Now I need to update the rows where the prodequiv in the database is equal to the data contained within the '$Equivalent' variable;

But I thought that this "where prodequiv = '$Equivalent' would do it?
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.