473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to concatenate values in php?

how to concatenate multiple check box values in same fields


Pls rply me fast...................
Oct 10 '12 #1
10 3457
Rabbit
12,516 Expert Mod 8TB
I have no idea what you mean.
Oct 10 '12 #2
johny10151981
1,059 1GB
First of never tell "Reply me fast". That is very rude.

Secondly your question does not make any sense.

if you want the checkbox to be selected then simply:

do below:
Expand|Select|Wrap|Line Numbers
  1. <INPUT TYPE="Checkbox" CHECKED>
  2.  
if you want it to be judge by php then it can look like something below:

Expand|Select|Wrap|Line Numbers
  1. if(certain_condition_fulfilled()==true)
  2. {
  3.  $sel="SELECTED";
  4. }
  5. else $set="";
  6. ?>
  7. <INPUT TYPE="Checkbox" <?php echo $set;?>>
  8.  
Oct 10 '12 #3
ATNC33
7
I can't understand your question. On checkbox you can only have one answer... Like, gender: masculin or feminin.

A if you use a radio, then you can have more than one answer...

I don't know if i'm helping, but i can't do better with your question!
Oct 10 '12 #4
johny10151981
1,059 1GB
ATN, will you rethink your answer?
Oct 10 '12 #5
johny10151981
1,059 1GB
did you edit the question? If you did then explain the reason Please
Oct 11 '12 #6
ATNC33 you have that backwards. Checkboxes are for multiple values. Radio buttons are for a single value from multiple choices.

Anis Nimi, You literally want the values concatenated? Like:

value1value2

or you want them in an array?

array[0]=value1
array[1]=value2

or do you want them as an array in PHP?

You need to clarify your question.
Oct 12 '12 #7
Rabbit
12,516 Expert Mod 8TB
@jd, ATNC33 is not the original poster. I believe they were trying to answer the original poster.
Oct 12 '12 #8
I addressed the original poster in my second paragraph.
Oct 13 '12 #9
HI ! i think you could try this :

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Serializing Checkbox</title>
  4. <script src="http://code.jquery.com/jquery-latest.js"></script>
  5. <script>
  6. $(document).ready(
  7.         function()
  8.         {
  9.                 $("#test").click(
  10.                 function() {
  11.                         serializeCheckbox();
  12.                 }
  13.                 );
  14.         }
  15. );
  16.  
  17. function serializeCheckbox()
  18. {
  19.         var string = '&string=';
  20.  
  21.         var inputs = document.getElementsByTagName('input');
  22.  
  23.         for( var x = 0; x < inputs.length; x++ )
  24.         {
  25.                 if(inputs[x].type == "checkbox" && inputs[x].name == 'field') 
  26.                 {
  27.                         if(inputs[x].checked == true)
  28.                         {
  29.                                 string += inputs[x].value + ',';
  30.                         }
  31.                 }
  32.         }
  33.     if (/,$/.test(string)) {
  34.         string=string.replace(/,$/,"")
  35.     }
  36.         alert(string);
  37. }
  38.  
  39. </script>
  40. </head>
  41. <body>
  42. <form>
  43. <input type="button" id="test" value="Click me" />
  44. <br />
  45. <input name="field" type="checkbox" value="blue" />Blue<br />
  46. <input name="field" type="checkbox" value="red" />Red<br />
  47. <input name="field" type="checkbox" value="green" />Green<br />
  48. </form>
  49. </body>
  50. </html>
Oct 13 '12 #10
Hi,
I hope this short code shall help you to understand the whole concept.

Expand|Select|Wrap|Line Numbers
  1. $concated_str = '';
  2. if(isset($_POST['checkboxvalues'])){
  3.     $concated_str = implode(',',$_POST['checkboxvalues']);
  4. }
  5. //store $concated_str in the database
  6.  
In short, use simply implode function. For more detail.
http://php.net/manual/en/function.implode.php
Dec 20 '12 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Sunil Gosavi | last post by:
I have to write a master detail query, in which the detail record should be stored in a variable as Comma Seperated Values. Can anyone help me...... Sun *** Sent via Developersdex...
30
by: priya | last post by:
Hi How to concatenate two integer Values. Example Program : #include "Port.h" #include "BinaryConversion.h" # include "iostream.h"
0
by: Michelle | last post by:
Hi all I have a form with two subforms The main form has a combo box which lists ShiftPatternID. When user selects from combo first subform shows shift pattern for that ID, ie user selects,...
6
by: Sheldon | last post by:
Hi, I am trying to build a large array using concatenate function in python. So as I loop over the number of arrays, of which there are 12 (4 down and 3 across), I create 3 long arrays by...
1
by: pobnospam | last post by:
I need to loop thru a table and concatenate values from a field called "items" and place in a new table with the concatenated values displaying in one record (grouped by order#). Any ideas ? ...
4
by: Avi | last post by:
Hi I am creating web application in which i want to assign by default values to the property which i had created my own. In that one of the property is of type color and i am unable to assign...
12
by: parth | last post by:
Hi I want to achieve the following transformation of data using a stored procedure. Source col1 col2(varchar) -------------------------
2
by: Garimella | last post by:
Hi Experts. Need a help in writing a query. Here is the scenario. table has three columns : Emp Id, Book Name, Book Number sample data is...... 1 ten 1 1 two 2 1 Thr 3
4
by: mattdoughty | last post by:
Hi Forum, I'm trying to perform a type of concatenate function on a table and am not really sure where to start. I'd like to aggregate the values from 'field' on their ID. To explain, my table is...
1
by: avanthika | last post by:
hi, i want to concatenate values of three column in one row for example my data is: Binoy> select * from fpfm_nominies where emp_no='1283L'; EMP_NO NOMINEE -------...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.