SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast andrew_z's Avatar
    Join Date
    Dec 2004
    Location
    brisbane
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help with a php code to make a value

    Hello,

    i have this page where people can create a story about there wedding.

    title and body (where there story goes)

    there is also a check box that will let them decide if the story is to be displayed yet or not..

    i need help in makeing a php code that says if the check box (named view) is checked then add the value of 1 else add a value of 0

    but i am not sure how to write the code, can any one help me please? thank you in advance.

  2. #2
    SitePoint Enthusiast andrew_z's Avatar
    Join Date
    Dec 2004
    Location
    brisbane
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, i got it working a bit..

    i have the insert working now, now i just have to get the update part working, it all works except for one bit..

    when you edit the story the check box (used to display / not display the story) is meant to be checked if the value = 1 but unchecked if the value = 0

    here is the code

    PHP Code:
    <input type="checkbox" name="view" value="1" <? if ("$view == 1"); echo checked?>>
    but it keeps it cheked no matter what..

    can some one please help me thank you.

    --begin edit--

    ok, never mind i working it out, i had part of the code wrong and missed a bit out completely.. thank you any ways.

    --end edit--

  3. #3
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Until the form is actually processed/submited I dont think you can check the value of it like you are.

    You would need to do that after the form has been submitted.

    Hope this makes sense!

    Mark

  4. #4
    SitePoint Enthusiast andrew_z's Avatar
    Join Date
    Dec 2004
    Location
    brisbane
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mark_W
    Until the form is actually processed/submited I dont think you can check the value of it like you are.

    You would need to do that after the form has been submitted.

    Hope this makes sense!

    Mark
    hey,

    yeah i got it working..

    it now checks to see if the value in the data base is 1 if it is then echo checked in the check box field.. if it dosnt = 1 then it wont do anything leaveing the check box empty..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •