how to retrieve multiple values in checkbox checked

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amel86
    New Member
    • Apr 2010
    • 25

    how to retrieve multiple values in checkbox checked

    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

    Code:
    $getpost = $db->query_first("
    		SELECT post.*, thread.*, post.postid, post.threadid, thread.threadid
    		FROM " . TABLE_PREFIX . "post as post, " . TABLE_PREFIX . "thread as thread
    		WHERE post.threadid = $threadinfo[threadid] AND
    		post.threadid = thread.threadid
    		ORDER BY post.dateline
    		LIMIT 1
    	");
    	
    		$days = explode(",",$getpost['field23']);
    		$day1 = $days[0]; 
    		$day2 = $days[1];          
    		$day3 = $days[2];
    		$day4 = $days[3];
    		$day5 = $days[4];
    		$day6 = $days[5];
    		$day7 = $days[6];
    //html code

    Code:
    <td width="150px"><input type="checkbox" name="fields[$threadfield[fieldid]][0]" value="Monday" tabindex="1" 
                            <if condition="$day1 != ''">
                            <if condition="Monday == $day1">
                            checked
                            </if>
                            </if>
                             />Monday</td> 
                            <td width="150px"><input type="checkbox" name="fields[$threadfield[fieldid]][1]" value="Tuesday" tabindex="1" 
                            <if condition="$day1 != '' && $day2 != ''">
                            <if condition="Tuesday == $day1 || Tuesday == $day2">
                            checked
                            </if>
                            </if>
                             />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 ??
    Last edited by Dormilich; Apr 16 '10, 05:55 AM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    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.

    Comment

    Working...