Jump to content

Edit a row in MySQL


medj

Recommended Posts

I am trying to implement a way to edit one piece of data in a row from my database. If you can take a quick look at:

http://eldoled.blankevolution.com/. Select "Match" and then any of the 3 sub options on the right. When you click submit, you will get a page that displays many rows where the stock is listed on the right.

The plan is to be able to click the Edit Link on the right and be able to edit the 'stock' value. When you hover over the edit links you will notice that the 'id' is set to the part number and it is being sent with the submit.

Now the problem I am having is being able to display an edit box that will let me edit the stock of the part that I click on. Here is some of my code:

 

The Edit Link

<a href='display.php?cmd=edit&id=$get_info[1]'><b>Edit</b> - $get_info[1]</a>

 

The query to get the required part to edit:

$id = $_GET["id"];
$edit_row = mysql_query( "SELECT components.part_num, components.stock FROM components WHERE components.part_num=$id" )
or die("SELECT Error: ".mysql_error());
$myrow = mysql_fetch_array($edit_row);

 

And just in case this might help, this is the error when I click the Edit link:

SELECT Error: Unknown column '10MQ100NTRPBF' in 'where clause'

 

The "10MQ100NTRPBF" is replaced with the part number of the link I click.

 

 

Can anyone please help?

Link to comment
Share on other sites

Since $id is not numeric, put single quotes around it in your query.

 

$edit_row = mysql_query( "SELECT components.part_num, components.stock FROM components WHERE components.part_num='$id'" )

 

Also, I don't see a reason you are selecting part_num when you already have it set in $id.

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.