Web Masters Site All For Web Masters

4Oct/110

Delete Duplicate Rows In Mysql With PHP

$dupq = mysql_query("SELECT * FROM `db`");
$dups = mysql_fetch_array($dupq);
foreach($dups as $dup){
mysql_query("DELETE FROM db WHERE duplicate_COLUMN='".$dup['duplicate_column']."' AND id!='".$dup['id']."'");
}

duplicate_COLUMN - Name of column and $dup['column_name'] delete duplicates which include same column data.

Filed under: MySQL, PHP, Programming No Comments
12Jan/110

Geotargeting with PHP

Its really important some time to use geo targeting for your web site users for example if you have e-commerci  site or for any other sites, I'll show example which give you opertunety to use geo ip with php scrip lets start.

18Mar/090

Country Drop Down List for Web Forms

ddcl

Here is Country Drop Down List for Web Forms, you can use it for registration page or for something else.

13Aug/080

Read From Files In PHP

Read from open file can be done with function fread

  • string fread(int file, int length)

This function returning string with size of length from file which you want to read, for example

<?
 
$file = fopen("c:\file.txt", "r"); // File which must be opened
 
if(!$file) //if file have not been loaded
 
{
 
echo "Error";
 
}else{
 
$buff = fread($file, 100); // Read from $file(file.txt) maximum 100 characters
 
print $buff; // Print content of file which was read
 
}
 
?>
Filed under: PHP, Programming No Comments
28May/080

JavaScript And PHP

For example you want to use javascript in php and want to get for example alert message with this javascript code

<strong><script language="Javascript">alert ("This is a Javascript Alert")</script>

Now how to use it in echo here is example

echo"
<script language=\"Javascript\">alert(\"This is a Javascript Alert\")</script>";
Filed under: PHP No Comments
29Apr/080

PHP File Upload

This is small example for beginners, how to upload files with PHP, this method is very simple and it can be used at every server which supports PHP. We will use 2 files upload.html, and upload.php, by default files uploaded in /upload directory, make sure that upload directory is writable.

upload.html

<html>
<body>
 
      <form action='upload.php' method='post' enctype='multipart/form-data' />
      <input type='file' name='filename' /><br />
      <input type='submit' value='submit' /><br />
      </form>
 
</body>
</html>

upload.php

<?
//Test file size which must not be more then 3MB
if($_FILES['filename']['size'] > 1024*3*1024)
{
echo "File is more then 3MB!";
exit;
}
 
//Test File Input
if($_FILES['filename']['name'] == ''){ 
 
echo "You must browse the file!";
 
}else{
 
//If file pointed start Upload In /upload Path
 
if(move_uploaded_file($_FILES['filename']['tmp_name'], "upload/" .$_FILES['filename']['name'])){ 
         	echo "File Uploaded!";
}else{
        	echo "Can't upload file!";
}// End of Upload Code
 
}
 
?>
Filed under: PHP, Programming No Comments
30Mar/080

Flash & W3C

W3C & Flash

Few days ago, I was worked on design of my site, I wanted to include flash slide show into it, I added flash normally. my work was perfect, everything worked fine, but W3C has founded some error in my site, this errors were because of flash <embed> element, later I have read this blog http://alistapart.com/articles/flashsatay, here is written about, one of the most used and popular technique, how to add flash movie in your content with W3C specification.
This technique is simple, <embed> element was created by Netscape, it’s not part of the XHTML specification and because of that W3C has found there errors. We can remove <embed> element and all will be ok there will be no errors, but movie will be displayed only in IE, not in Mozilla or Netscape what to do ? here is example