Page 1 of 1

Replace Info in a single cell! --> I'm almost giving up!

Posted: Wed Jan 10, 2007 11:02 pm
by ykarmi
I searched and searched and read the W3Schools tutorials, fluffycat.com tutorials, different references and mainly Google (*ahm* Ole *ahm* :wink:) but I just COULDN'T FIND AN ANSWER!!! :roll: - how to replace information in a single cell?
What bothers me the most, is that INSERT doesn't have a WHERE to it, unlike SELECT.
I'm not even sure whether INSERT can replace data or not. I have a cell, that already contains data, but now I want to replace that data with new one, but when I tried to access one cell, I found out the the most you can do is access the whole row. I don't want to change the whole - I have 28 values in it!!!

How can I replace information in only one cell - preferably using PHP??? It's killing me!!!
Please don't jump on me saying I'm just posting, Iv'e been searching for the past 3 hours for a solution just so you guys don't yell at me for not trying :wink:

Thank you soooooooo much,
Yuval

Posted: Wed Jan 10, 2007 11:05 pm
by feyd
an UPDATE query.

Posted: Thu Jan 11, 2007 8:21 am
by volka

Posted: Thu Jan 11, 2007 12:04 pm
by Ollie Saunders
OK I'm just going to give it to you now:

Code: Select all

-- Change the value
UPDATE `table` SET `column` = 'new_value' WHERE `tablePrimaryKey` = 1

Code: Select all

-- Create it in the first place
INSERT INTO `table` VALUES (`... all the columns specified in order here`

Code: Select all

$q = 'SELECT `column` FROM `table` WHERE `tablePrimaryKey` = 1';
$result = mysql_query($q) or die('Query error');
$row = mysql_fetch_assoc($result);
echo $row['column'];
Post back if you are still having difficulties with your database schema.

Ohhhhhh

Posted: Thu Jan 11, 2007 2:13 pm
by ykarmi
Ohhhhhhhhhhh, So you can't select the cell right away?
You have to get the row, then select the cell out of the row?
I'll definitely give it a try and let you know how it worked.
Thank you sooooooo much! :P :P :P
Yuval :D

Posted: Thu Jan 11, 2007 3:31 pm
by Ollie Saunders
I could almost hear the click from your brain as it all suddenly made sense :D