Welcome to my BLOGGING space...


I'm surprised I have not come across this earlier.

Often when writing scripts for paging between sets of results or lists of products I have processed two queries. The first runs the required query with no limit clause and COUNT(*) and the second with a set of column names and a LIMIT clause.

NO MORE!

SQL_CALC_FOUND_ROWS (released in MySQL 4.0.0 onwards) tells MySQL to calculate how many rows would be returned if the limit clause was missing. If you want to get the result you can do Select FOUND_ROWS().

Check out the following code example if you dont believe me!
<?php
//Running the query here. Lets assume the products table has 100+ entries
$result = mysql_query(“SELECT SQL_CALC_FOUND_ROWS * FROM `products` LIMIT 20”);

//Lets get the number of results actually returned (20)
$iRows = mysql_num_rows($result);

$totalResult = mysql_query(“Select FOUND_ROWS()”);
$totalRow = mysql_fetch_assoc($totalResult);

//The following will return the number of rows that our first query returned if the LIMIT clause has been missing
$iTotalRows = $totalRow[“FOUND_ROWS()”];

?>

This was actually introduced to MySQL to help with paging and solve the two query problem.

I know some people still prefer using two queries, but if you didn't know this existed. Then use it as you wish...

Posted by epic at 22:24pm


I am by no means surprised, and I guess this post has been a long time coming but its been announced on the Netscape blog that support for Netscape web browsers is being discontinued. Security releases will end on February 1st 2008.

It is a shame, once one of the great leaders in the browser market now gone to the grave.

Oddly enough, ive always been a fan of Netscape Navigator whilst not necessarily using the product... which I guess is why its odd. Navigator9 has some pretty nifty tools included which are great for web developers alike. I guess their biggest problem was the lack of innovation achieved by the company over the years which essentially lead to the browsers death - in my opinion years ago.

Oh the bright side... thats one less browser us web developers have to worry about!

Posted by epic at 20:15pm


I was asked the other day what development environment I prefer and why.

Why is a hard question. Its mostly what I have been taught to use over the last few years and includes a collection of tools that are invaluable.

Im always adding and/or changing my development environment to suit the needs of whatever I am working on but it mostly consists of the following:

Hardware:
  • Right now im working on a 2.4GHz Dual core AMD Athlon 64. Ive only got 1GB of RAM but it does the job. I gave my other gig stick away (for free) so that makes me a nice person.
  • Ive got a double monitor setup. Any developer that tells you its un-necessary does not know what they are doing and needs a slap. Seriously though, double monitors are the way forward. Three would be the perfect setup but thats excessive and greedy. Documentation and browsers open on one, code open on the other.
  • Wireless keyboard, wired mouse. But it makes no difference.
  • UPS: Belkin un-interruptible power supply. Lasts 40min with everything switched on.

Software:
  • Operating system is Windows XP (sp2) although I have Linux UBUNTU installed which I love using when I can.
  • Eclipse with PHPEclipse plugin. PDT I will get around to trying one day. Development for PHPEclipse has pretty much ground to a halt so I will migrate away sooner rather than later. I have a few random Eclipse plugins installed but nothing that helps much with development.
  • Browser of choice is Firefox. As a developer you should have other browsers such as Opera, IE (Of course) and Safari. The more the merrier.
  • Firefox plugins: ColorZilla (great tool), British English Dictionary (corrects spelling), SearchStatus (Displays Google PageRank and Alexa ranking), Web Developer toolbar (YOU NEED THIS)
  • FTP Client: I use FireFTP. Its okish...
  • Image Editing: Adobe Photoshop (love it or hate it)
  • Email: I use Mozilla Thunderbird. It is amazing.
  • Other tools: UltraMon (Gives me multiple taskbars across both screens). Skype (Its good and cheap).
  • Music: WinAMP. Cant live without it. Plus the Last.FM plugin to keep track of things.

Im always looking for new hardware/software that makes life and development easier so drop me a message if you think im missing something.
  1. ColorZilla
  2. Last.FM
  3. Web Developers Toolbar
  4. Winamp
  5. Mozilla Thunderbird
  6. Adobe Photoshop
  7. Skype (VOIP)
  8. Ultramon
  9. FireFTP
  10. SearchStatus
  11. Firefox Add-ons: Dictionaries
  12. Mozilla Firefox
  13. Apple Safari
  14. Opera
  15. PHPEclipse
  16. Eclipse PDT
  17. Eclipse
  18. Linux UBUNTU
  19. Windows XP

Posted by epic at 14:28pm


The following is a simple method to set your timezone within PHP. You need to do this at the start of each of your pages. If your using OOP (Object-Oriented Programming) in PHP then put this in one of your main objects. Otherwise just include the line at the start of each file. If thats not possible, just include it at the top of any file that uses the built in date or time functions.
<?php
echo "Original Time: ". date("h:i:s") ."n";
date_default_timezone_set("Europe/London");
echo "New Time: ". date("h:i:s") ."n";
?>

As you can see, you need to use the date_default_timezone_set() function along with a timezone identified.

You can find a list of valid timezones at http://uk2.php.net/manual/en/timezones.php

Posted by epic at 16:03pm


I have recently completed an upgrade to the EpicArena system. The blogs have been rewritten so that it is now possible to easily post.

I have also added comments which is something I have been meaning to add for quite a while.

Ill try and start posting a little more frequently now!

Ollie
Edit: We also validate!

Posted by epic at 00:16am


To use the double-click mouse action you need to use the ondblclick() event handler.

In this example, we will use the double click action to display selected text in a SELECT in another field.

First, you will need to add the following Javascript to the HEAD section of your HTML document. Ensure the code is between the script tags.
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--

function move_selected()
{
var w = document.form.selected_list.selectedIndex;
document.form.new_text.value = document.form.selected_list.options[w].text;
}

//-->
</SCRIPT>
Now, you must create a selection list and a text field.

NOTE: ondblclick() will only work if the size of the selection list is greater than 1.
<FORM NAME="form">
<SELECT NAME="selected_list" ondblclick="move_selected()" SIZE="2">
<OPTION VALUE="1">Item One
<OPTION VALUE="2">Item Two
<OPTION VALUE="3">Item Three
</SELECT>
<BR />
<INPUT TYPE="TEXT" VALUE="" NAME="new_text" SIZE="15">
</FORM>
Thats it. Now all you have to do, is double click one of the list item, and it'll magically appear in the text box.

Posted by OLLIE at 10:16am