Sep 25 2008

how to backup a mysql table

Category: SQL, Snippetslotsofcode @ 8:18 am

A nice and simple way of backing up a mysql table without renaming / exporting is to create a new table with the same structure and copy across the data for the current table.

This can be done without having to copy and paste the structure of the table.

Simply replace the [NEW_TABLE] and [OLD_TABLE] markers with your new / old table names.

CREATE TABLE [NEW_TABLE] LIKE [OLD_TABLE];
INSERT INTO [NEW_TABLE] SELECT * FROM [OLD_TABLE];

For example.

CREATE TABLE products_backup LIKE products;
INSERT INTO products_backup SELECT * FROM products;

This will create the table and maintain any indexes / keys.

I hope this helps.


Sep 24 2008

It’s been a while ….

Category: Websiteslotsofcode @ 8:18 pm

I haven't writted here in a long while, i have been whay too busy working and haven't had a chance to see what's happening.

I'v changed the style, not really sure what difference it's going to make, but it makes me feel asif i have done my part as a web-publisher, hopefully someone will read this just so this doesn't feel like a complete waste of time, if you have read this i will be really interested to know, seriously i would!


Aug 07 2008

xbox360 Gamer Tag

Category: Generallotsofcode @ 10:04 am

My xbox360 Gamer Tag

I'm a newb online (ps3 is my first love), if anyone wants to add me then please feel free too.


Jun 02 2008

Market Music

Category: Websiteslotsofcode @ 11:36 am

Yesterday was the launch of the new market music website, the sellers of official music merchandise such as Misfits, Breaking Benjiman, Inflames and Many more. It was decided that the site would go live with only a few products that have been cleaned up from the old site and now they are hoping to add many products over the next couple of months.

Please take a look, let me know what you think.

- Music Band T-Shirt

Tags:


Mar 25 2008

Three Columns with Header, Menu and Footer

Category: CSS, Templateslotsofcode @ 8:41 pm

Simple template for inclusion into your website.

Tags: ,


Mar 24 2008

Simple Smarty Pagination

Category: PHP, Tutorialslotsofcode @ 2:45 am

With the combined effort of my PHP Array Pagination script and this tutorial you will be able to pagination results (database & non database driven results) and intergrate it easily with the smarty template engine.

So, to start download the PHP Pagination script and then put it into a directory within your smarty setup.

During this example i am going to be using some test data, a basic PHP array with 10 sub array's, like so:

$myArray = array(
array('id' = > 1, 'title' => 'Test Item 1'),
array('id' = > 2, 'title' => 'Test Item 2'),
array('id' = > 3, 'title' => 'Test Item 3'),
array('id' = > 4, 'title' => 'Test Item 4'),
array('id' = > 5, 'title' => 'Test Item 5'),
array('id' = > 6, 'title' => 'Test Item 6'),
array('id' = > 7, 'title' => 'Test Item 7'),
array('id' = > 8, 'title' => 'Test Item 8'),
array('id' = > 9, 'title' => 'Test Item 9'),
array('id' = > 10, 'title' => 'Test Item 10'),
);

Then assign the pagination class to an object called pagination and assign the array and the amount of page numbers and assign this information into the smarty template vars, one for the listing of the items and another for the actual pagination.

$pagination = new pagination();
$myArray = $pagination->generate($myArray, 10);
$smarty->assign('listing', $myArray);
$smarty->assign('pagination', $pagination->links());

Then go into the template side of your setup and add the following code

{if !empty($listing)}
{if !empty($pagination)}
<div class="pagination">{$pagination}</div>
{/if}
{foreach item="item" from="$listing"}
<tr>
<td>{$item.id}</td>
<td>{$item.title}</td>
{/foreach}
{/if}

It's a pretty quick and simple solution to get you going as a beginner, good luck!

One of the main issues i found with using the smarty template engine is that there isn't enough documentation online!

Tags: ,


Mar 24 2008

Simple Modular Arithmetic with Smarty Template Engine

Category: PHP, Snippetslotsofcode @ 2:37 am

Something i take for granted in PHP is the use of Modular Arithmetic when display results in a grid like format.

Usually in php, i would do something like this to display three items per row

if ($count % 3 == 0) {

// Add Break / Clear here

}

So i assumed something like this would be available in smarty. After googling for a while i found a couple of solutions to this, however none of them were as simple as the PHP code above, so by playing about with the Smarty Template Engine, i managed to figure out a nice simple way, and here it is.

{assign var="mycount" value="1"} {*Initiate the mycount variable*}
{if $mycount++ % 3 == 0} {*Simular syntax to the above*}
// Add Break / Clear here
{/if}

So, as i found this so useful for displaying products on a current project, i thought it would be something other would really like to know about.

Tags: ,


Mar 20 2008

jQuery - Skinning HTML Select Boxes

Category: Javascript & AJAX, Projectslotsofcode @ 12:51 am

Had enough of the same old operating system based select field style? Why not skin it up, this script allows you to apply a skin to a select box.

This tutorial is based on the original code i wrote, however this version is less buggier and has support for non JS enabled browsers!

Nice and simple to install, include the jQuery library and the select skin JS file and the CSS file like so.

<style>
<!--
@import url('./css/skinned-select.css');
//-->
</style>
<script src="./js/jquery.js" type="text/javascript"></script>
<script src="./js/jquery.skinned-select.js" type="text/javascript"></script>

Then just wrap a div with the class name of 'my-skinnable-select' around the select box, like so.

<div class="my-skinnable-select">
<select name="name">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
<option value="5">Five</option>
</select>
</div>

The form variables can be posted as usual, it's as easy as that, enjoy!

Please take a look at the demo or download the code and let me know what you think by using the contact form below.

Tags: ,


Mar 16 2008

jQuery for beginners

Category: Javascript & AJAX, Tutorialslotsofcode @ 10:21 pm

This is a little tutorial i put together to help people starting out with jQuery to learn the basics.

So, first things first. Pop over to http://docs.jquery.com/Downloading_jQuery and download the latest version in whatever form you prefer, Minified, Packed or Uncompressed. If you are not fussed then i would suggest the packed version.

No, the first thing you should do is create a specific testing area, for example c:jquery. Then in that folder extract the jquery file into it, if the name of the js file isn't jquery then i would suggest you rename it to jquery.js to make the name of the file nice and easy to remember.

Now, on to the html.

Create a file, with whatever name you prefer, i will call mine 'myfirstjquery.htm' in that file i have created basic html as follows, i have also included

the jquery js file.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My First jQuery Script with lotsofcode.com</title>
<script src="jquery.js"></script>
</head>
<body>
</body>
</html>

Now that we have the basic html we can start adding some Javascript.

Next, create a new div and assign an id to the div like so.

<div id="hello-lotsofcode">Hello LotsofCode</div>

Now, save the file, open it with a web browser and you should have a basic html page with the text 'hello Go back to your text editor and add the following

code to inbetween the opening and closing head tags.

<script>
$(document).ready(
function() {
// Code to be executed goes here ...
}
);
</script>

Everything that is called by jQuery needs to be wrapped in this loader above.

Now, to call the element we just created we simply use a CSS style declaration to call the element like so.

<script>
$(document).ready(
function() {
alert( $('#hello-lotsofcode').text() );
}
);
</script>

This should present you with an alert box with the words 'hello LotsofCode', now, we can change the text value by using a simular method like so

<script>
$(document).ready(
function() {
$('#hello-lotsofcode').text('Hello from the visitor');
}
);
</script>

Now, when you execute this code, you should see that your div has the content of hello from the visitor, this is because we used the method text with a value and assigned it to the id hello-lotsofcode element, it's pretty simple isn't it!

Now, to hide and display elements:

<script>
$(document).ready(
function() {
$('#hello-lotsofcode').text('Hello from the visitor').hide();
}
);
</script>

And to show ...

<script>
$(document).ready(
function() {
$('#hello-lotsofcode').text('Hello from the visitor').show();
}
);
</script>

The two above methods don't mean much on there own, but with an event handler we can have some fun.

So at the top of the page add two anchor links.

<a href="#" class="hide-text">Hide Text</a>
<a href="#" class="show-text">Show Text</a>

Then the jQuery code for this is as follows:

<script>
$(document).ready(
function() {
$('.hide-text').click(
function() {
$('#hello-lotsofcode').text('Hello from the visitor').hide();
}
);
$('.show-text').click(
function() {
$('#hello-lotsofcode').text('Hello from the visitor').show();
}
);
}
);
</script>

Nice results eh ... ? You can easily hide anddisplay elements on the page.

I did say this tutorial was for beginners and it is, i have emphasized on this because now i am going to show you some basic effects and i don't want you to assume they are going to be really complicated.

So, while working with the same file, we can add a nice fading effect to go along with our new text, like so:

<script>
$(document).ready(
function() {
$('#hello-lotsofcode').text('Hello from the visitor').hide().fadeIn('slow');
}
);
</script>

Note the chainability, all i have added is '.hide().fadeIn('slow')' to the end of the string so we hide the element and then immediately after we fade it in, take a look at the results.

Tags: , , , ,


Mar 12 2008

Wordpress TinyMCE Image Upload Plugin

Category: Javascript & AJAX, Projectslotsofcode @ 10:01 pm

After many hours looking and looking for a plugin for TinyMCE i finally found one that actually worked quite well and was what it said it is .. An actual image upload plugin for Wordpress's TinyMCE ... !

Take a look here: http://www.soderlind.no/archives/2006/01/03/imagemanager-20/

Untitled_1.gif

Download here: http://www.soderlind.no/download/ImageManager2.41.zip

I know someone will really appreciate this post as i would appreciate someone else posting a link to such a great resourse, if anyone knows of any other open source / free plugins for TinyMCE please post here.

If PHP safe_mode is enabled on server you may find problems with thumbnails ...

Tags: , ,


Next Page »


Powered by WordPress - Created by Tommaso Baldovino

-->
Comments   Web Developer
Firefox   Google Chrome