473,795 Members | 2,861 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 3028
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
1429
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
3511
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
4204
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
3346
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
4000
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
3855
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
1741
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
2266
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
1575
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
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10443
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...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7543
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
5437
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
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2921
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.