Jump to content


Staff Alumni
  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by CroNiX

  1. extract($str) is what you're looking for. Takes an array and breaks it up into individual variables using the keys of the array as the variable names. http://php.net/manual/en/function.extract.php
  2. The first variable in a query string follows a ?, which you are doing. Subsequent variables get added using the ampersand (&), but you are using a plus (+) which means a space character in URLs. .../pes/mimo.php?rack=1&jobs=0&hosts=1 $rack = $_GET['rack']; $jobs = $_GET['jobs']; $hosts = $_GET['hosts'];
  3. Since this is a comparison, you need to use double == here instead of assigning the value: if($_POST['page'] = $total_number_of_page) {
  4. Did the owner give you (written) permission to take their copyrighted material and use it for your own purposes?
  5. Lots of ways. How about posting your schema? Is everything properly indexed, especially fields that are being joined on, used in WHERE's, etc? 30,000 records is nothing...
  6. CroNiX

    wysiwyg textarea

    We need to know what javascript wysiwyg editor you are using on these textareas, and also the js code you are using.
  7. http://php.net/manual/en/function.array-unique.php
  8. And databases are highly optimized to quickly store/search/sort/retrieve data. That's their sole purpose. It's the right tool for the job. Coding is also about using the right tool for the job. You will make this a LOT more complex if you do it the way you are wanting to as you will not only have to hand code each html page to enter you data (room for error there) but you also now have to read them in and parse the HTML to get the data back out. That's really a waste and prone to error unless everything is perfect. It also has more wasteful overhead, will take longer and consume more memory than just using a database. Again, a database is the right tool for the job you describe... If you are really new to php this will be a lot more challenging for you to get working, especially the parsing of the HTML, than learning the database stuff.
  9. What does the css for the class errorPrint look like, which are used in the spans after each input?
  10. Here's a better approach though, that uses more pure jquery than you are using. It also tremendously simplifies things. <div id='dialog' title='Blog Post Viewer'></div> //Just use the href, and create a html data attribute to hold the "url_data". Give them all the same class and jQuery will pick it all up using my function which is automatically invoked. <a href='?a=a&b=b' data-urldata="data a" class="modalize"> link text a</a> <a href='?c=c&d=d' data-urldata="data b" class="modalize"> link text b</a> $(function() { //create a click event for all links with class of "modalize" $('a.modalize').on('click', function(e) { e.preventDefault(); //jQuery equiv for return false for click event var link = $(this); //the clicked link //grab the link href var href = link.attr('href'); //grab the link urldata var urldata = link.data('urldata'); alert('href: ' + href + "\nData: " + urldata); //now do the ajax, open dialog box, etc $( "#dialog" ).dialog({ autoOpen: false }); }); }); Example: https://jsfiddle.net/tagwgLch/1/
  11. Try removing the return false for the onclick event and moving the run_modal() to the onclick event. If you need to you can return false at the end of your run_modal() function. <a href='? $url_data ' onclick='run_modal ( \" $href \" , \" $url_data \" );' > $link_txt </a>
  12. You can also use array_search() to look for a value in the array and if it exists it will return the associated key (or FALSE if not). You can then use the key to unset the index from the array. if (($key = array_search($value_to_delete, $your_array)) !== false) { unset($your_array[$key]); }
  13. Sure you can use AJAX to retrieve any "new" records and return the data back to your script where you would insert it at the bottom of your table. It's a lot more complex than just using the page refresh method though. You're going to have to do some homework to get this running, and we can help you along the way once you start posting code that you're having problems with. I'll give you the basic steps you'd need. 1) Include the jQuery js framework in your pages. 2) You will need to store the timestamp for each item in your html code so you can use js to get the largest timestamp which will be used to send back to laravel. I would suggest adding a data attribute to each of your <tr> tags that would be the timestamp. Ex: <tr data-timestamp="1234567890"> where 1234567890 is the timestamp from your db. 3) Create a js function that will be called using setInterval() -grabs all data-timestamp data attributes from the <tr>'s, and compares them getting the highest value -use ajax to send the newest timestamp via POST to your laravel controller --in the "success" event of the ajax call, check to see whether any json data was returned and if so use jQuery to create new table elements with the returned json data and insert them after the last <tr> in your <table>. This would just be a javascript array that you'd loop over to create the elements. 4) Create laravel controller, or add a new method to an existing controller, to receive the POSTed timestamp from the ajax call. Use the timestamp to grab all new entries from the db > timetamp, json encode the returned entries and output them so your ajax script can receive them, which will be the "success" event of the ajax call mentioned above. So this will basically just send the latest timestamp every x seconds back to laravel, laravel checks to see if any new entries exist greater than the supplied timestamp and returns them and then your jQuery will insert them into the table.
  14. There are many jQuery plugins that will do that. here is one: https://github.com/acornejo/jquery-cropbox just google "jQuery image crop" for many others. Most will do zoom in addition to crop and other functions.
  15. I use filemtime() to get the files last modified date to use for a timestamp. Then whenever the file gets updated, it automatically bumps the timestamp and forces the browser to download the new file, otherwise it will download it whether it was updated or not, which is kind of a waste. $file = '/home/user/public_html/assets/css/my_css.css'; //path to raw file $asset = '/assets/css/my_css.css'; //to be used for asset link //If the file existed, grab it's last modified time and append it to the asset for cache-busting purposes if (file_exists($file)) { $asset .= '?v=' . date ('ymdHis', filemtime($file)); } echo $asset; //something like '/assets/css/my_css.css?v=150815090530'
  16. And the reason for the error, "syntax error, unexpected '$result2' (T_VARIABLE)", is because you don't have a semicolon terminating your $sql2 string, just before you try to perform the 2nd query. $sql2 = "SELECT blog.content, article_comments.blog_id FROM blog LEFT OUTER JOIN article_comments ON blog.content_id = article_comments.blog_id WHERE blog.content != ''" // need semicolon here!!
  17. In your query, you aren't selecting "blog_id", you're selecting "content_id", which I assume is what you're after for your ID.
  18. What do you mean "do not want to manually insert the blog_id value". You'd use the same code that you are using to display the blog article, which presumably returns the blogs ID with the rest of the article data when retrieving from the database? So you'd just output the article_id in the hidden form input just like you are outputting the article text.
  19. You could also sort() the array to get them in (1,2,3) order.
  20. if ($_POST['active'] != '1' && $_POST['active'] != '0') { Your condition here should be OR, not AND. AND means it has to be 1 AND 0 at the same time, which it obviously can't. It can be 1, OR can be 0. Another thing, what type of form control is named 'active'? Is it a checkbox? If so, only checked values get submitted with the form, not unchecked values. This is an HTML standard having to do with "successful form controls". For checkboxes, I usually do something like: <input type="checkbox" name="active" value="1"> And then when checking: $active = (isset($_POST['active'])) ? 1 : 0; If active was checked it will be set, and since we know it's value can only be 1, we just set it to 1. You could just as well use $_POST['active'] there forcing it's value to an int or something. If active wasn't checked, it won't be set so we set the value to 0.
  21. It's often helpful, especially when learning, to google your error messages. The message is pretty self explanatory. You are using the "mysql" driver, which is deprecated from PHP, meaning it will be removed in a future version of PHP so it's obsolete and its use is discouraged. Otherwise when you or your host upgrades the PHP version on the server one day, all your queries will suddenly stop working and you'll have to rewrite the whole db layer of your app to use a more modern db driver. You would want to use either the PDO driver, or mysqli (with an i at the end). PDO is the preferred driver.
  22. What does "not working" mean? It's not updated in the db? The email never gets sent? They don't receive the email?
  23. Google custom search rocks and is very easy to implement. It's very fast too.
  • 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.