Search Results For : sample code

Delete data from database automatically at regular interval

Recently I attended a session where a few developers would discuss about the website they have done. One of the developers approached me and asked me if there is a way that you could delete data from MySQL database once a week / at regular interval. I thought this short tutorial will be useful for one who wish to do so on the LAMP stack.

Step 1: We will come up with the php file that will do the delete function, from MySQL database and upload it.

$link = mysql_connect(‘localhost’, ‘mysql_user’, ‘mysql_password’);

if (!$link) {
die(‘Could not connect: ‘ . mysql_error());


mysql_query(“DELETE FROM mytable WHERE WHERE dateInserted > ‘2012-9-9′”);

In my sample code above, i did, “DELETE FROM mytable WHERE WHERE dateInserted > ‘2012-9-9′”. It depends on what you want to do, you can always change the conditions on why it should be deleted. I have also saved it as DeleteData.php


Step 2: Since I have cPanel, i used cPanel and go into Cron Jobs








Step 3: I will setup the cron job to run at once a week.(Of course you can set otherwise)







Note that for Command, you have to specify where the file lies, after you upload.

You can download the mentioned, DeleteData.php here.

Delete records from mysql automatically

Hope this is helpful for those who are finding a quick tutorial on how this can done. If you have any questions, please feel free to email [email protected], use the contact us form or alternatively you can comment. 🙂

I will post a tutrial on how we can do this on WISA stack.

Detecting theme on Windows Phone 7

This blog post is going to teach you how do we detect if we are on dark or light theme on Windows Phone 7. I realised that this will be useful because I have quite some friends who are asking me about it because they didn’t get the right resources online. If you happened to come across a resource that asks you to get from App.xaml, that doesnt work anymore as its removed after the RC build.

Based on Theme Resources for Windows Phone, under Theme Visibility and Opacity.
By checking Resources, I am able to check if its Visible or Collapsed for the dark or White theme by doing this

Visibility isLight = (Visibility)Resources[“PhoneLightThemeVisibility”]; // for light theme
Visibility isDark = (Visibility)Resources[“PhoneDarkThemeVisibility”]; // for dark theme

Then we use if else to check,

if (isLight == System.Windows.Visibility.Visible)
//We are on light theme

Light Theme


if (isDark == System.Windows.Visibility.Visible)
//We are on dark theme

Dark Theme

Attached is a sample code to show how do I detect Windows Phone 7 theme, before the Mango buuild ( I am unsure if there is a change after Mango ).
Detect Theme on Windows Phone 7 Sample