You are here: Re: dymanic populating checkboxes « PHP Programming Language « IT news, forums, messages
Re: dymanic populating checkboxes

Posted by Kimmo Laine on 08/29/06 08:18

"calms" <calmsqurill@gmail.com> wrote in message
news:1156836800.803848.266940@m79g2000cwm.googlegroups.com...
> HI,
>
> First of all im vry new to PHP, i like to retrieve a value from DB,
> accordingly i like to display the checkbox, either checked or not.
>
>
> Now im able to retrieve the value from DB, i can show even show the
> checkbox, but i cant make it checked????
>
>
> Can anyone help, plzzzzzzz!!!
>
>
> the Code i used to display as follows,


> echo "<tr>
> <td Class='navText'
> align='center' class=$c>$event_id</td>
> <td class='navText'
> class=$c>$event_name</td>
> <td class='navText'
> align='center' class=$c><input type='checkbox'
> name='publish' ?></td>
> <td class='navText'
> align='center' class=$c><a
> href='delete_event.php?event_id=$event_id'>$take_action</a></td></tr>";
>

IF-statements don't work like that, inside a string. You've chosen a very
peculiar way of studying php if you've managed to get all the way to
retrieving information from a databases but have no idea how if's and
strings work or don't work.

Okay, so you have this really big string and inside it you have an if
statement. That won't do. You have to perform the if-test outside the
string. Try this. Before echoing the string, write the following code:

if($event_publish==1){
$checked_state = 'checked="checked"';
} else {
$checked_state = '';
}

And then, inside the string:
echo "...<input type='checkbox'name='publish' $checked_state >...";

And see how it works.

And then the lecture from a seasoned and old php veteran....

I started "coding" by looking into source codes of other websites, studied
the html structures, javascript etc. several years ago. It was in the 90's,
when this thing called "the internet" got big. It was a fun way of learning
and kept me interested, but also very frustrating. Since then I've taken
courses and studied programming really hard and finally stopped copy-pasting
other peoples codes and write everything myself, now that I know how. I
admire your enthusiasm and I strongly encourage you to study php, but start
from the basic stuff. It's very simple and boring first, I mean how exciting
can 1+2 be? I know, boring as hell, but you gotta learn the ground rules of
the language before you can really get into this programming stuff. Keep up
the good work!

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net || Gedoon-S @ IRCnet || rot13(xvzzb@bhgbyrzcv.arg)

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация