0

Hi

I am trying to join 2 sentences together using php and mysql. How can i do so?

I am doing this as i need to add an update of a new remarks to the existing remarks.

For example,

$first = 'Hello';
$second = 'world';

To get the string 'Hello world', can i actually simply just add $first and $second ie:

$final = $first + $second ;
Thanks

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by futhonguy
0

Logic:

Get the content from the databse and stored it in a variable
$content=sqlContent;
$updRmrks="This is extra text has to be palced";

$content = $content . $updRmrks;

update the record with usual update query and overwrite the contents.

Hope you understand the logic!

0

if you want to use two columns to concat into third column then you may use following query

update mytable set col1=concat(col2,col2) where col4='mycondition'
0

Thanks guys for the replies.

works fine. However i am trying to overwrite a content in one of the table. ie:

Case 1:
$first = 'NA';
$second = 'Hello world';
$final = $second;

Case 2:
$first = 'Hello';
$second = 'world';
$final = $first.$second ;


For 1st case, if $first = 'NA', then $final will be set to $second as i want to overwrite $first.
For the 2nd case, if $first != 'NA', then $final will be a combination of $first.$second

I tried to use if.. else statement to solve it but somehow i will still get $final = $first.$second as my result be it $first = 'NA' or 'first'.
below is my code:

if ($first != 'NA' || $first != 'Nil' ) 
{ 	$first = $first .",".$second; 
}
         else {
	$first  = $second; 
	         }

Thanks for the help!

This topic has been dead for over six months. 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.