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
https://forums.phpfreaks.com/topic/109413-edit-a-row-in-mysql/
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
https://forums.phpfreaks.com/topic/109413-edit-a-row-in-mysql/#findComment-561380
Share on other sites

Archived

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

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