0

Hello everybody. I've been working on a PHP file that adds a value to a cell in one table in MySQL.
First I thought that the following code might work properly:

<?php
require("DB_Connector.php"); //The file that connects to the MySQL database required
mysql_query("update tableName set cellName= cellName + '$The_New_Value' where S_ID='$ID'",$connection);
?>

However, I learned later that this "+" mark is used only for math operations (Unlike JavaScript which uses the "+" mark instead of the "." used in PHP). I also tried the "." mark, but it didn't work! :@
Does anybody know how to add a value to a cell immediately without getting the content of that cell? I mean without writing the following code:

$getContent = mysql_query("select cellName from tableName",$connection);
while($contentArray = mysql_fetch_array($getContent))
{
     $newCellContent = $contentArray['cellName'] . $The_New_Value;
     $cell_ID = $contentArray['cell_ID'];
     mysql_query("update tableName set cellName='$newCellContent' where cell_ID='$cell_ID'",$connection);
}

So, I want to avoid writing the whole code I've already written, and I want to write a very shorter MySQL_Query code instead. Does anybody know how to do that?
Thanks.

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by Pro2000
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.