json_encode

--=-qj/kmQZV311nj+1sw7BL
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

What value does json_encode need to assign to
$verse_of_the_day_subscribe in order to cause this checkbox to be
checked when the form is updated with the query to the database?
<input type="checkbox" name="verse_of_the_day_subscribe"
id="verse_of_the_day_subscribe">

I have already figured out how to do ones such as:
<input type="text" name="first_name" id="first_name" size="20"
maxlength="40" />

Thanks, Ron

--=-qj/kmQZV311nj+1sw7BL--
Ron Piggott [ Sa, 03 Januar 2009 23:22 ] [ ID #1983164 ]

Re: json_encode

------=_Part_146246_12741085.1231098459660
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

First of all, I suggest you use $_POST['verse_of_the_day_subscribe'] instead
of $verse_of_the_day_subscribe to point to checkbox element value.

To answer your question, if your data is encoded with json_encode() just
decode it with json_decode() and use an if-else control structure to check
the value and check the checkbox using checked='checked' (XHTML) depending
on the condition.

To illustrate it with an example:
<?php
// Assuming the $json_encoded_data variable contains the JSON data
$html_form_element_values = json_decode($json_encoded_data);

// The rookie way
if ( $html_form_element_values->{'verse_of_the_day_subscribe'} == 1 /* or
whatever */ )
{
echo '<input type="checkbox" name="verse_of_the_day_subscribe"
id="verse_of_the_day_subscribe" checked="checked">';
}
else
{
echo '<input type="checkbox" name="verse_of_the_day_subscribe"
id="verse_of_the_day_subscribe">';
}
?>

On Sat, Jan 3, 2009 at 11:22 PM, Ron Piggott <ron.php [at] actsministries.org>wrote:

> What value does json_encode need to assign to
> $verse_of_the_day_subscribe in order to cause this checkbox to be
> checked when the form is updated with the query to the database?
> <input type="checkbox" name="verse_of_the_day_subscribe"
> id="verse_of_the_day_subscribe">
>
> I have already figured out how to do ones such as:
> <input type="text" name="first_name" id="first_name" size="20"
> maxlength="40" />
>
> Thanks, Ron
>


--
Isaak Malik
Web Developer

------=_Part_146246_12741085.1231098459660--
isaak malik [ So, 04 Januar 2009 20:47 ] [ ID #1983248 ]
PHP » gmane.comp.php.database » json_encode

Vorheriges Thema: PgDAY LFNW CFP
Nächstes Thema: If I make a mistake logging in, the error shows again even if I enter the right values