473,746 Members | 2,672 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

joining variables together

Hello
I am trying to update a session, ie everytime the page is resubmitted I want
the current selected value from a list to be appended to the old session
value. I have the following code but am unable to get it to work. I dont
know the correct syntac wher I have put the word 'PLUS'.

<?php $_SESSION['savedcomm'] = $_SESSION['savedcomm'] PLUS
$_POST['selectcomm'];?>

I have tried & but this doesnt work, or even && which I have seen in some
script

Help please
Ian

May 29 '06 #1
5 3025
Ian Davies wrote:
Hello
I am trying to update a session, ie everytime the page is resubmitted I want
the current selected value from a list to be appended to the old session
value. I have the following code but am unable to get it to work. I dont
know the correct syntac wher I have put the word 'PLUS'.

<?php $_SESSION['savedcomm'] = $_SESSION['savedcomm'] PLUS
$_POST['selectcomm'];?>

I have tried & but this doesnt work, or even && which I have seen in some
script


$_SESSION['savedcomm'] = $_SESSION['savedcomm'] . $_POST['selectcomm'];

//Aho
May 29 '06 #2
Thanks Aho

sorry I should have added, what if I want each newly added item to the
session to display as seperat lines when returned to a text field?

Ian

"J.O. Aho" <us**@example.n et> wrote in message
news:4e******** *****@individua l.net...
Ian Davies wrote:
Hello
I am trying to update a session, ie everytime the page is resubmitted I want the current selected value from a list to be appended to the old session
value. I have the following code but am unable to get it to work. I dont
know the correct syntac wher I have put the word 'PLUS'.

<?php $_SESSION['savedcomm'] = $_SESSION['savedcomm'] PLUS
$_POST['selectcomm'];?>

I have tried & but this doesnt work, or even && which I have seen in some script


$_SESSION['savedcomm'] = $_SESSION['savedcomm'] . $_POST['selectcomm'];

//Aho

May 29 '06 #3
Ian Davies wrote:
Thanks Aho

sorry I should have added, what if I want each newly added item to the
session to display as seperat lines when returned to a text field?

Ian


$lines = $_SESSION['line1'].'<br>'.$_SESSI ON['line2'];
or
$lines = sprintf("%s<br> %s", $_SESSION['line1'], $_SESSION['line2']);
or
$prefix = 'line';
$lines = '';
foreach($_SESSI ON as $key => $value) {
if( substr($key, 0, strlen($prefix) ) == $prefix) {
if( $lines == '' ) $lines = $value;
else $lines = sprintf("%s<br> %s", $lines, $value);
}
}

This assumes that all the lines you want to join together begin with the
tag name 'line'. (e.g. line1, line2, line_foo, etc.)

-david-

May 29 '06 #4
Ian Davies wrote:
sorry I should have added, what if I want each newly added item to the
session to display as seperat lines when returned to a text field?

$_SESSION['savedcomm'] = $_SESSION['savedcomm'] . "\n" . $_POST['selectcomm'];

This would add new line between the old and new data.

If you want to display it in a html section, then you can use nl2br()
http://www.php.net/manual/en/function.nl2br.php

<h2><?php echo nl2br($_SESSION['savedcomm']); ?></h2>

If you add things to a textarea, then do

<textarea name="thetext" rows="20" cols="80"><?php echo
$_SESSION['savedcomm']; ?></textarea>

Here you don't use the nl2br as the the textarea element does respect the new
line, which isn't done in html otherwise.
//Aho
May 29 '06 #5
Thanks J.O.
That was what I wanted

"J.O. Aho" <us**@example.n et> wrote in message
news:4e******** *****@individua l.net...
Ian Davies wrote:
sorry I should have added, what if I want each newly added item to the
session to display as seperat lines when returned to a text field?

$_SESSION['savedcomm'] = $_SESSION['savedcomm'] . "\n" .

$_POST['selectcomm'];
This would add new line between the old and new data.

If you want to display it in a html section, then you can use nl2br()
http://www.php.net/manual/en/function.nl2br.php

<h2><?php echo nl2br($_SESSION['savedcomm']); ?></h2>

If you add things to a textarea, then do

<textarea name="thetext" rows="20" cols="80"><?php echo
$_SESSION['savedcomm']; ?></textarea>

Here you don't use the nl2br as the the textarea element does respect the new line, which isn't done in html otherwise.
//Aho

May 29 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1424
by: chris | last post by:
im pretty ne to java script - so please be gentle :) basically what i want to do is construct an action in a function using a variable sent to that function ok - what i want to do is function ($number) {
2
3508
by: James | last post by:
Can anyone please shed some light on the following... I have a framework that uses dynamically created tables, named using an incremental "attribute set ID", as follows: attrdata_1 attrdata_2 attrdata_3 etc, etc...
2
4203
by: Paul M | last post by:
Hi, This is on an AS/400 which can be a little strange but I think the basic question is portable. I have a (non-C) program that needs to make series of calls to some C programs/functions. The problem is that I need to initialise certain variables within the first C program called and then use them in subsequent calls to other C functions.
5
3335
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example I'm adding a customer. The Customer fields are mostly foreign keys that refer to primary keys in other tables, left join instead of junction tables at this point. So, when I want to add a customer record, I also need to add records to the other...
5
3999
by: Ant | last post by:
hi, I'm now using C#. Seeing as though you can declare & initialize or pass a value to a variable on the same line as the declaration, is it still best practice to group all the variables together at the top of the method, or is it now acceptable for them to be declared at the point where they are initially needed, seeing as though you can 'go to the definition', with the right click of a mouse? Pedantic I know, but I'm curious. thanks...
2
3853
by: Coquette | last post by:
Hi all. I'm new here. I wanted to ask your opinion about *joining two tables* from *two different database* together. Is *that* possible? My project requires me to join identical tables from different database; *eg. MyTable* from *Friends.mdb* and *Foes.mdb* respectively. Is that achievable? I do hope anyone here can enlighten me on this one because I am really a newbie in using Access DB and also I'm using *ASP* in this project. Hope...
1
1739
by: s99999999s2003 | last post by:
hi i have some databse results that are NoneType and DateTimeType. now i have trouble joining these row results together like "|".join(result) as it says cannot join NoneType , DateTimeType . How can i change these types so i can join the columns together as string? thanks
2
2264
by: Supermansteel | last post by:
I am joining these 2 tables together in Access 2003 and can't figure out the exact way of writing this script......Can anyone help? I have the following SQL: SELECT PL_Input.Date_ID,Count(PL_Input.+PL_Input.+PL_Input.+PL_Input.+PL_Input.) AS FROM Country INNER JOIN PL_Input ON Country.Country_ID = PL_Input.Country_ID WHERE (((. & "" & . & "" & . & "" & . & "" & .) Like "*2*"))
3
1572
by: nickvans | last post by:
Hello everyone, I am new to SQL Server, and am having trouble joining several SELECT statements together. I have three SQL Select statements that do separate count operations to get the status of many projects. (One statement counts the number of open projects, one counts the number of completed projects, and the third one counts the number of late projects.) The count operations use GROUP BY project to operate. An example of one of...
0
9508
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9218
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8229
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6772
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6060
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4586
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2199
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.