Jump to content

gristoi

Members
  • Posts

    840
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by gristoi

  1. dependancy injection is definately the way to go. if you need to use a blank object you can instantiate an instance of stdClass()
  2. sort($array, SORT_FLAG_CASE);
  3. 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
  4. i personally like to use this approach to make it stand out a little more : echo "<tr><td>$prog_name</td><td><a href={ htmlspecialchars($_SERVER["PHP_SELF"]) }?id={ $title }'>EDIT</a></td></tr>";
  5. remember you have to have jquery included at the top of your site. have a google on setting up jquery
  6. 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
  7. is your server set up to use smtp, also: <button type="submit" name="submit" class="btn btn-primary pull-right">Submit</button>
  8. you have said what you are trying to do, but what is the actual issue you are having?
  9. you need to learn how to use forms in php. mainly with the <form> tag. if you want to sumbit via ajax then you need to look at a jquery solution
  10. you need to make your path seperators language agnostic. use DIRECTORY_SEPERATOR
  11. wow, i wish i had an extension that wrote my OOP for me, damm all those years learning to write code.
  12. you're looking for a CRM not a CMS
  13. use jquery: var input = $('#someId'); var type = input.attr('type').val(); var name = input.attr('name').val(); var maxLength = input.attr('maxLength').val(); .... build json string
  14. 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
  15. 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.
  16. public function __clone() { throw new Exception( "you are not allowed to clone this object" ); }
  17. 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/
  18. It is 2014 , not 2004. use Jquery to create multiple instances of ajax calls
  19. <? 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(); ?>
  20. your opemning tag in vistors controller: <? class should be <?php class also check the filename does not have a typo
  21. 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.
  22. 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
  23. $points = array(34, 23, 96, 54, 44); $spike = max($points);
  24. class oop { private $_status; public function __construct() { $this->_status = false; } public function main() { $this->_status = true; } public function subone() { if($this->status) { // do stuff } } public function subtwo() { if($this->status) { // do stuff } } }
×
×
  • 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.