+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Explain this code pls

  1. #1
    balaji2u's Avatar
    balaji2u is offline x10 Lieutenant balaji2u is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Senthamil Nadu,India
    Posts
    410

    Exclamation Explain this code pls

    im trying to working on a template based document building script.i think this code will help me to get a input from the user such that he dont need to type the full document just the name,places of his choice must be selected and our script will generate the final document with his needed text in the placeholder like {name} {place} etc.

    the code is here.pls tell me for what this code exactly for? and of these two codes which will best suit my need?
    PHP Code:
    $Sdocbuild->db_Query"INSERT INTO `$tem_table` (`Template`) VALUES ('".$_POST['New_Template']."')" ); 
    second code is
    PHP Code:
        $SkaLinks->db_Query"UPDATE `$tem_table` SET `Template`='".$_POST['Letter_tem'][$value]."' WHERE `ID`='".$value."'" ); 
    thanks.
    Submit your Site Links Now ! >>> :cool:
    Live Aritlces Free Articles and Links Directory


  2. #2
    compwhizii is offline Banned compwhizii is an unknown quantity at this point
    Join Date
    May 2008
    Location
    The Moon
    Posts
    779

    Re: Explain this code pls

    Those are queries to a MySQL database. From what I can gather those lines of code will not do anything to help you.

  3. #3
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: Explain this code pls

    They are simple queries to a database, but they are returned from a (I think) a class or a function.

    you will probably find a bit of code above these a bit like..

    PHP Code:
    class Sdocbuild{
           function 
    something{
           }
    blah de blah

    each class will contain a whole bunch of other variables and functions.

    the symbol "->" tells you that it is returning a value from a class or function.

    That said, it is also possible that these functions are in a different file; called at the beginning of the script.

    If this is a template, its going to make your life very tricky.

    As for the querys, the first one inserts a record with a value from a form (New_template) into a table defined by the variable $tem_table.

    The second query simply updates the same table. The column updated is "Template" and the value it is updating again comes from a form with a name "Letter_tem", providing the ID is like "value" (whatever value is).

    It is very difficult to tell without seeing what is in the function/class.

  4. #4
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: Explain this code pls

    Quote Originally Posted by freecrm View Post
    The symbol "->" tells you that it is returning a value from a class or function.
    Close, nothing is necessarily returned. Its the equivalent of a "dot" operator in other Object Oriented langauges. So it is used to return a value or run a method. In this case it's running a subroutine to insert/update the table.

    Quote Originally Posted by freecrm View Post
    As for the querys, the first one inserts a record with a value from a form (New_template) into a table defined by the variable $tem_table.

    The second query simply updates the same table. The column updated is "Template" and the value it is updating again comes from a form with a name "Letter_tem", providing the ID is like "value" (whatever value is).
    Right. The first one inserts your template from the form as a record into the 'Template' field of your table. The second updates an existing template in the table.

    It might be better to include a link to your form and tell us what you want to happen.
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


  5. #5
    xcaliberse is offline x10Hosting Member xcaliberse is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    46

    Re: Explain this code pls

    Seems like a PHP/ MySQL script. I think what u need for this to happen is a HTML post code.

  6. #6
    balaji2u's Avatar
    balaji2u is offline x10 Lieutenant balaji2u is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Senthamil Nadu,India
    Posts
    410

    Re: Explain this code pls

    Quote Originally Posted by vol7ron View Post
    Close, nothing is necessarily returned. Its the equivalent of a "dot" operator in other Object Oriented langauges. So it is used to return a value or run a method. In this case it's running a subroutine to insert/update the table.

    Right. The first one inserts your template from the form as a record into the 'Template' field of your table. The second updates an existing template in the table.

    It might be better to include a link to your form and tell us what you want to happen.
    I want to have a text field that shows text like

    Hi my name is {name} ,im living in {place}.i finished masters in {degree}.Im now going to {destination}.
    and now below this text box there are 4 drop down boxes one is {name} ,and for {place} and for {degree} and for {destination}
    all these drop down boxes have multiple values for example
    {name} list box contains options like vol7ron,corey,jackson etc
    now if he selects the name vol7ron then the next page(i.e page that comes after clicking submit button) must show the replaced texts and now it will become a easily made document.
    hope this is sufficient if you want to know more details pls dont hesitate to ask me.
    Submit your Site Links Now ! >>> :cool:
    Live Aritlces Free Articles and Links Directory


  7. #7
    exghost is offline x10Hosting Member exghost is an unknown quantity at this point
    Join Date
    Dec 2008
    Posts
    1

    Re: Explain this code pls

    you can use cookies to store data...and it will appear in the next page too..

    <?php
    session_start();
    setcookie ( 'name', 'vol7ron', time() + 1209600 );
    ?>

    and on the next page you can get it by using $_COOKIE['name'] like this

    <?php
    session_start();
    echo "Hi my name is".$_COOKIE['name'].", im living....";
    ?>
    Last edited by exghost; 12-14-2008 at 07:57 AM.

  8. #8
    xPlozion's Avatar
    xPlozion is offline x10 Elder xPlozion is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Delaware, USA
    Posts
    872

    Re: Explain this code pls

    you don't need `session_start()` to use cookies. session_start is only if you are going to be using `$_SESSION`'s instead. you would set sessions like `$_SESSION['name'] = 'vol7ron';`. there's no expiration time since they expire when you close your browser.

  9. #9
    gptsven is offline x10 Lieutenant gptsven is an unknown quantity at this point
    Join Date
    Dec 2008
    Posts
    253

    Re: Explain this code pls

    Quote Originally Posted by xPlozion View Post
    you don't need `session_start()` to use cookies. session_start is only if you are going to be using `$_SESSION`'s instead. you would set sessions like `$_SESSION['name'] = 'vol7ron';`. there's no expiration time since they expire when you close your browser.
    you do need sessions when using cookies to automatically login a user -.-

  10. #10
    gptsven is offline x10 Lieutenant gptsven is an unknown quantity at this point
    Join Date
    Dec 2008
    Posts
    253

    Re: Explain this code pls

    You are the one who is ignorant.

    cookies are mainly used to auto-login users on forums/websites.

    and Im saying
    you need a session to log in, using the data from your cookie (autologin)

    "mister I argument everything and im always right"
    whats your argument for this line?

    I HATE IT WHEN ILL-INFORMED PEOPLE TELL ME I'M WRONG WHEN OBVIOUSLY THEY HAVE LESS EXPERIENCE WITH PHP THEN I, AND CONSIDERING THE FACT THAT I BACKUP MY STATEMENTS WITH WELL RESPECTED SOURCES!!!
    firstly I'm not ILL-formed
    secondly,I didnt tell you you are wrong you idiot I only stated that you DO need sessions if you want users to be able to login automatically, dumb****, learn to read.

    Its nice to include a lot of arguments and sources in your post. for those who are still learning. I however do not need to learn anything anymore PHP-wise. I'm not saying I know everything, but I know how to use php.net to find and implement the functions I need. you did not enlighten me with your post. I know what sessions are, I know what cookies are. I KNOW OK? I'm not some retarded kid who just started doing php and is trying to bash you ok?


    so my advice for you is
    stay calm, and dont feel offended. cause that was never my intention.
    I really hope your reply on this post is going to be somewhat less childish
    Last edited by gptsven; 12-14-2008 at 11:49 AM.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Hybrid's HTML Lessons
    By Hybrid in forum Tutorials
    Replies: 18
    Last Post: 11-28-2009, 02:12 PM
  2. Help with PayPal button code...
    By componentwarehouse in forum Programming Help
    Replies: 3
    Last Post: 06-17-2008, 06:22 AM
  3. BB Code Guide
    By Jober68 in forum Tutorials
    Replies: 1
    Last Post: 01-10-2008, 05:12 PM
  4. New x10 ad code
    By yahia in forum Feedback and Suggestions
    Replies: 23
    Last Post: 01-02-2007, 12:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers