July 24, 2008 by Alex Polski | No Comments »
I guess every web developer has ever had a situation when he needed to get the dump of MySQL table but standard tools like phpMyAdmin or mysqldump were unavailable, but you had an ability to run PHP script. Some days ago I had similar situation and now I want to share this solution with you.
First of all, let’s get the table structure. It’s more simpler.
$sql = "show create table test_table";
$res = mysql_query($sql);
$data = mysql_fetch_assoc($res);
echo $data['Create Table'];
This PHP script prints SQL string for ‘test_table’ table creation.
And now let’s get the table data.
$sql = "select * from test_table";
$res = mysql_query($sql);
while ($row = mysql_fetch_assoc($res)) {
$fields = array();
$values = array();
foreach ($row as $key => $value) {
array_push($fields, addslashes($key));
array_push($values, '\'' . addslashes($value) . '\'');
}
$fields = implode(', ', $fields);
$values = implode(', ', $values);
echo "insert into test_table ($fields) values ($values);\n";
}
Note, if the table contains a lot of data, you will need to call set_time_limit(0) function.
July 14, 2008 by Alex Polski | No Comments »
July 11, 2008 by Alex Polski | 1 Comment »
Yesterday I found a great article about adding a drop shadow to images by Brian Williams and decided to implement this method on my blog. After that I though if my readers want to have the stylish drop shadows on their blogs too and decided to develop a wordpress plugin which will automatically add a drop shadow to each posted image.
Wanna to have the image drop shadows on your blog like on my one? ;-)

Just download the plugin, install it, activate it and enjoy!
Download Image Drop Shadow wordpress plugin now (zip, 4.4 kb)
July 10, 2008 by Alex Polski | No Comments »
If you use wordpress plugin like runPHP and All in One SEO Pack plugin, you can have a problem. This thing can take place if you insert php tags at the beginning of the post. In this case All in One SEO Pack will truncate the text of the autogenerated meta description tag.
For example, if the beginning of your post is
My <a href="<?php echo get_permalink(15); ?>">previous post</a> was about wordpress.
the autogenerated meta description will not be “My previous post was about wordpress” as you expect, but it will be “My”. This is because of strip_tags php function does not support php tags inside html tags.
To fix this issue just insert the row:
$text = preg_replace('/<\?php.+?\?>/i', '', $text);
in the beginning of the functions trim_excerpt_without_filters and trim_excerpt_without_filters_full_length.
July 9, 2008 by Alex Polski | 1 Comment »
Do you remember I was going to develop my iGoogle gadget? Yeah, I did it! :)
The idea of a gadget was taken from the famous “50 films to see before you die” list by Film4. This is a list of the 50 best movies which Film4 recommend everybody to see. My gadget shows the information about each film from this list like film’s title, year, plot, thumbnail, links to the film’s trailer, IMDB page and Amazon page and has handy navigation bar which allows to move from one film from the list to another, mark the film as seen, move through unseen movies.
Here is the preview:
To add this gadget to your iGoogle page just click on this button: 
P.S.: BTW, I’ve already seen 12 films and keep seeing the others. The list is really great!
« Older Entries