|
Posted by calms on 08/29/06 08:39
thks a lot.Yes it worked. Also thks for pointing my mistakes tht i
didnt learn in order. Yes i didnt follow any course or book....i learn
through Internet.
calms
Kimmo Laine wrote:
> "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)
[Back to original message]
|