473,385 Members | 1,535 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,385 software developers and data experts.

how to retrieve multiple values in checkbox checked

25
hello,
i have a question. firstly sorry coz my grammar is not so good. i hope you all understand what question i will submit here..

the problem i face now is i cant retrieve all data that user already checked in checkbox. i want to edit the complete data. actually i need to modify the system that completely finish. so there no problem with saving or edit data.the problem is i just want to display data in checkbox.

there have data like days such as monday, tuesday, wednesday, thursday, friday, saturday n sunday. so when user checked monday and tuesday, i want if i go to the edit page, monday and tuesday already checked and the others uncheck. data already in the mysql. data hve been stored like monday, tuesday.
they separated by comma.

i used php and mysql.

here my code:

//php code

Expand|Select|Wrap|Line Numbers
  1. $getpost = $db->query_first("
  2.         SELECT post.*, thread.*, post.postid, post.threadid, thread.threadid
  3.         FROM " . TABLE_PREFIX . "post as post, " . TABLE_PREFIX . "thread as thread
  4.         WHERE post.threadid = $threadinfo[threadid] AND
  5.         post.threadid = thread.threadid
  6.         ORDER BY post.dateline
  7.         LIMIT 1
  8.     ");
  9.  
  10.         $days = explode(",",$getpost['field23']);
  11.         $day1 = $days[0]; 
  12.         $day2 = $days[1];          
  13.         $day3 = $days[2];
  14.         $day4 = $days[3];
  15.         $day5 = $days[4];
  16.         $day6 = $days[5];
  17.         $day7 = $days[6];
//html code

Expand|Select|Wrap|Line Numbers
  1. <td width="150px"><input type="checkbox" name="fields[$threadfield[fieldid]][0]" value="Monday" tabindex="1" 
  2.                         <if condition="$day1 != ''">
  3.                         <if condition="Monday == $day1">
  4.                         checked
  5.                         </if>
  6.                         </if>
  7.                          />Monday</td> 
  8.                         <td width="150px"><input type="checkbox" name="fields[$threadfield[fieldid]][1]" value="Tuesday" tabindex="1" 
  9.                         <if condition="$day1 != '' && $day2 != ''">
  10.                         <if condition="Tuesday == $day1 || Tuesday == $day2">
  11.                         checked
  12.                         </if>
  13.                         </if>
  14.                          />Tuesday</td>
the error is when user choose monday and tuesday, the code that i wrote here just check for monday not both. i can call out
values like $day1, $day2 and others at html page, but if i do if condition its not run smoothly.


anybody can help me?? please ??
Apr 16 '10 #1
1 3147
Dormilich
8,658 Expert Mod 8TB
I don’t know, what you use for Mark-up, but it’s certainly not HTML …

and I can’t see major errors in the PHP.
Apr 16 '10 #2

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

Similar topics

3
by: RC | last post by:
I am try test a simple HTML form with PHP <form method=POST action="testing.php"> Cat <input type="checkbox" name="pet" value="cat"> Dog <input type="checkbox" name="pet" value="dog"> Pig...
8
by: Jack | last post by:
Hi, Here is my problem: I am logging in to a page, where the page retrieves a record from a database. The text boxes are used in the display formto let the users update the fields, if they...
4
by: Dave Parrin-Bull | last post by:
Hi all, I have been asked (nay told!) to do a quiz for a webpage at work, now I can do the basic things like getting the radio boxes up there and assign values to them but here is what they...
3
by: niftyhawk | last post by:
Hi All, I have a php page say "abc.php" generating the following HTML. I am posting the form action to another php page say "TestCheckbox.php". How do I retrieve in "TestCheckbox.php" which...
5
by: mayur_hirpara | last post by:
Hi, I have been developing web applications for a while now. However, as I was thinking through the architecture I really don't understand the "How server can identify between which buttons has...
10
by: Girish | last post by:
Hi Everyone, I am passing a form to a php script for further processing. I am able to retrieve the last value set for that given form variable using $variable=$_REQUEST;
6
by: Daz | last post by:
Hi everyone. Firstly, I apologise if this i not what you would call a PHP problem. I get quite confused as to what lives in which realm, so if this shouldn't be posted here, please suggest where...
3
by: mountain.dog | last post by:
I have a query that shows a list of options that a user can toggle on or off using a checkbox. query... form... while($row = mysql_fetch_array($result))... <input name="menu_show_attribute"...
4
by: Matt | last post by:
I am no JavaScript guru so please bear with me and be as detailed as possible with your response. I thank you in advance. I have an ASP page that contains form elements. I also have an inline...
4
by: TechnoAtif | last post by:
Hi ALL I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.