Friday, May 29, 2009

Does php have a built-in string function that converts underscores into spaces?

Does php have a built-in string function that converts underscores into spaces?
Not a function that specially only does that task. However to accomplish that goal is simple. All you need to do is use the function "str_replace", its can be used like this: $newstring = str_replace("_"," ",$oldstring); The function "str_replace" takes three arguments:
  • First is what you want to search for, and be replaced. It is called the "needle".
  • Secondly is the replacement, which is used to replace the needle when it is found.
  • Lastly you supply the "haystack", or the string in which you wish to find the needle(s).
It returns a string with the needles replaced with the replacement. You could even replace them with a blank string, which basically removes the needles from the haystack. You can find more information on this at php.net. http://us3.php.net/manual/en/function.str-replace.php

Monday, May 18, 2009

jQuery - Web Developers Best Friend

jQuery has been out now for three years. It was released in January 2006, by a fellow named John Resig. He is one year older than me! Anyways... jQuery has recently changed the way I write JavaScript. It has simplified some fairly complicated JavaScript tasks, and even simplified simple tasks. All in all, it is totally work a little investment in downloading, installing, and playing with it a bit. If anyone wants to give it a shot, please let me know, I will be here for you when you get stuck in the mud. Ask me a question about jQuery!

Thursday, May 14, 2009

DataTables: a jQuery solution

Recently I've been using a jQuery plugin from this site: http://datatables.net/index. It's fantastic! Easy to setup and use with *tons* of options. Here's a screenshot of it in action: The data values were hard-coded for simplicity. The column sorting and pagination is all created on-the-fly by the plugin. I also wrote some callbacks to handle deleting and editing the table contents. Sweet!

Wednesday, May 13, 2009

Sample Question: How do you create a simple mouse rollover?

Question:

How would you create a mouse rollover, such that I could quickly copy and paste the code into my code?
Answer: This can be done several ways. The quickest way is to do create an inline script; however a more acceptable solution is to create functions which you could reuse elsewhere. Since we want the quickest, or simplest solution, it may not exactly be the most ideal solution, but that is the price we pay for simplicy, and speed. First you will need to secure an image that will act as your base image, and an image that will act as your rollover image. The base image will be what is displayed when the mouse is not hovering over the image. The rollover image would be your image to replace the base image, while the mouse is hovering over the image. You will need to have your images in a directory that is accessible by your script. For example: /root/index.html /root/images/base.gif /root/images/rollover.gif For speed you would simply then use the basic image tag: <img src="images/base.gif" alt="base" title="base" /> You then add the JavaScript code for the two events. One for the mouse over the image, and mouse out (when the mouse is no longer over the image). onmouseover="this.src='images/rollover.gif';" onmouseout="this.src='images/base.gif';" add them together: <img src="images/base.gif" alt="base" title="base" onmouseover="this.src='images/rollover.gif';" onmouseout="this.src='images/base.gif';" /> This is a widely accepted solution. There may be many other ways of answering this question, however to me this is the quickest.

Welcome to the Web Developers Blog!

Welcome to the UCD Web Developers Question and Answers Blog, Dear visitor, Thank you for visiting the UCD Web Developers attempt at sharing our cache of knowledge, with you. We are taking time to answer questions related to web development in any way, shape, or form. No question is too much or too little. Some questions may require demonstrations, some might require research, but we are willing to answer your questions quickly, and accurately. Regards, Patrick Simpson To give you an idea on some of your questions could be related to, but not limited to the following: CSS CSS 2 CSS 3 JavaScript jQuery YUI MooTools Scriptaculous Prototype PHP Version 4 Version 5 ASP .NET C# Visual Basic HTML XHTML HTML 4 HTML 5 Web Development Tools Dreamweaver FTP SVN