Jump to content

gristoi

Members
  • Posts

    840
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by gristoi

  1. well there is your problem, look at the method mysql_select_db 

    the clue is in the name, you are trying to set the db to use with your table name. set the correct db name. also PravinS is correct, you shouldnt be using variable strings in database connection. this leaves you wide open to sql injection and other vulnerabilities

  2. ok, first thing, bin off all of the XMLHttpRequest crap, is old hat. Nowadays pretty much everyone uses jquery to handle this. you want to do something like this:

    $(document).ready(function(){
    
    $('#shortlist').click(function(){
         var listId = $(this).attr('id');
         var self = $(this);
        $.ajax({
             url:"your url",
             data:{id:listId},
             type:'post',
             success:function(result){
             self.html(result);
             var divOnTheRight = $('#rightList');
             divOnTheRight.append(result);
              }});
    });
    // you can make as many ajax requests as you want this way

    hope it helps

  3. change

     

    <form id="contactform">

     

    to <form id="contactform" method = 'POST' action='contactform.php'>

     

    ( this is given that the index file and php file are in the same directory)

     

    but looking at the form it has onClick="return check_values();"

    this is a javascript event, so you need to make sure the form is not being submitted using AJAX

  4. try:

    //change this
    <input type="button" value="Submit" onclick="submit_info()" />
    
    // to this
    <a href="#" id="submitInfo">Submit</a>
    
    // then your javascript
    $(document).ready(function(){
    
    $('#submitInfo').click(function(e){
    
       e.preventDefault();
       var data = $('#genit').serialize();
        ..............
       // your ajax call here
    });
    });
    

    modern javascript should be event driven, s you shouldnt be polluting your html with stuff like onclick=... etc.

  5. MVC is just a design pattern. If you want to use this pattern along with a single page app then you want to seperate the client from the server side completely. You want to look at using a RESTful approach to getting your data. So your server side can be any kind of framework ( or bespoke ) such as zend / symfony / laravel. The Model part of the server side will hold all of the business logic ( communicating with the db etc), the Controller will take the rest request -> speak to the model -> return the models data to the view, and in your case this would be in a JSON response. So technically no view.

     

    heres a good tutorial for doing it using laravel and backbone:

     

    http://net.tutsplus.com/tutorials/javascript-ajax/combining-laravel-4-and-backbone/


  6. <? 

    include_once('includes/config.php'); 

     $increment = 1

     //get values of each member 

     $query="SELECT `name`, `price` FROM merchant"

     $result=mysql_query($query); 

     

     $num=mysql_num_rows($result); 

     while ($row = mysql_fetch_array($result)) 

     { 

        $value = (float)$row['price] + (float)$increment; 

        $query2 = "UPDATE merchant SET `price`='$value' WHERE `name`='Harvey Norman' and price ='141.00'"

        $result2 = mysql_query($query2); 

     } 

     // close connection 

     mysql_close(); 

     ?>

  7. I think your understanding of frameworks is slightly skewed. CakePHP is a framework in its own right, you dont need to add other frameworks into it. Frameworks help to make an application scalable, enforce standardisation in your code etc. 

     

    There are many frameworks out there, you just need to find your best fit. You want a quick blog then use drupal or wordpress. You want to code from the ground up using proven frameworks tend / Symfony / Laravel.

  8. it may work, but for readability it makes no sense. If you are going to asign the value to a variable then you must want to use it further on in the code. So assign first, then echo out the var. If your not using it anywhere else then it is pointless, just echo out the string

×
×
  • 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.