Jump to content

toivo

Members
  • Posts

    36
  • Joined

  • Last visited

Posts posted by toivo

  1. Hi,

     

    The first line checks if the form has been posted by a browser which identifies its type.  Mind you, it is possible to use cURL and fake any browser you want.

     

    The second line checks if the form has been posted.  If the method was GET, the form has probably been displayed by the code earlier and we can now exit.

     

    Regards,

     

     

  2. This is not an error but a notice only, and there are ways to turn them off if you want.  Depends on how tidy you want your code to be, of course.

     

    Before you refer to the value in the array, you need to check if it is set.  Not all user agents set the value for $_SERVER['HTTP_REFERER'].

  3. I need to do the comparison (generate a report) from a MySQL date field whose data type is DATETIME..

     

    Meaning it displays date and time as opposed to data type DATE which displays only the date.

     

    Did you try it?  My example compares dates, not times:

     

    ... WHERE DATE_FORMAT(Date, '%Y%m%d') = CURDATE();
  4. Even though a website built with PHP can have hundreds of thousands of lines of code, websites do not rely on PHP alone.  PHP scripts generate HTML pages which often have also javascript embedded.  There are javascript libraries like Mootools, Scriptaculous and jQuery which simplify the creation and manipulation of HTML documents. 

     

    You could first familiarise with the concept of MVC - Model, View and Controller, to see how websites can be structured.  From there it is an easy step to install a Content Management System (CMS) like Joomla and get a flying start in building sites.  Joomla has hundreds of extensions which are free.  You could run a site with a photo gallery, chat room and support forum in no time, using the application from the Open Source communities.  In due course, you can return the favor and publish something you have developed.

     

    It is a huge area, and lots of fun.  Even with lots of experience in IT in general, I learn new things every day  :-)

     

     

     

  5. Code:

    $sql2 = "INSERT INTO mailid (mailid, subject, message, from) VALUES ('".$insert."', '".$subject."', '".$message."', '".$from."')";

     

    Error:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from) VALUES ('4', 'et', '', 'demouser')' at line 1

     

    Hi,

     

    from is a reserved word and you need to quote it in backticks if you want to use it as an identifier:

     

    `from`

     

    Regards,

    toivo

  6. Your PHP script or HTML page renders the page where your javascript code resides with the current value of the embedded variables.  In the javascript example the value of those variables does not change inside the for loop.

     

    If you want to make different products accessible to javascript, you need to create an array containing product data and make the array available to javascript.  The way to do this is through AJAX queries, for example using the jQuery library.  You code can then send a request to a PHP script similar to your current PHP code which returns the data in XML format.  The response is then parsed by the jQuery code which makes the data available as a javascript array or variables.

     

    Here is an example of how it might work.  The PHP script will need to extract the input parameter from the $_POST variable, retrieve the data, build the XML file, issue the header command with 'Content-type: text/xml'  and echo the XML data back to the browser.

     

    function get_products() {
      var url = 'get_products.php';
      data = 'lines=' + '10'; // request data
    $.ajax({
      type: "GET",
      url: url,
      data: data,
      success: function(xml) {
        var output = '<p><ul>';
        var productid = '';
        var imageid = '';
        $("line", xml).each(function(i) {
            productid = $(this).find('ProductID').text();
            image = $(this).find('ImageID').text();
      	output += '<li>img/p/' + image + '-' + productid + '-home.jpg' + '</li>';
        });
        output += '</ul></p><hr />';
        $('#product_list').html(output); // write html to document
      }
    }); //ajax
    }
    

     

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.