Posts

Showing posts with the label mysql

Select all rows in a table But except one in in that table?

You have a few options: SELECT * FROM table WHERE id != 4; SELECT * FROM table WHERE NOT id = 4; SELECT * FROM table WHERE id <> 4; Also, considering perhaps sometime in the future you may want to add/remove id's to this list, perhaps another table listing id's which you don't want selectable would be a good idea. In which case you would have: SELECT * FROM table WHERE id NOT IN (SELECT id FROM exempt_items_table); Source:-  http://stackoverflow.com/users/263467/tim

How to get database backup in your mailbox daily automatically

ew web host do not offer a daily backup of MySQL database while few offer extra charge for automatic backup.This PHP script will help you to get database backup in your mailbox daily automatically. This script  performs three tasks.First it creates backup of MySQL database and save it server in .sql format.In second step it compress the .sql file and convert it in .zip format.At last ,it sends an email to provided email id with attached backup.To use this script you just need to assign the values for the variables $db_host , $db_user , $db_pass , $db_name , $tables and $email. <?php //File name:backup.php //Date:20 November 2012 //By: Amit Singh< admin@megarush.net > //Title:How to get database backup in your mailbox daily automatically //settings for MySQL database //change these variables before using $db_host=" localhost ";   //mysql host $db_user=" rashed ";  //databse user name $db_pass=" dbpassword ";  //database password $d...

Simple Microsoft Excel file generation via PHP and Mysql

config.php :- <?php $host_name="localhost"; $username="root"; $password=""; $db_name="test"; //Database Connection $conn=mysql_connect($host_name,$username,$password); //Database Select mysql_select_db($db_name,$conn); ?> BuyerAssistReport.php :- <?php error_reporting (E_ALL ^ E_NOTICE); include("config.php"); $query  = "SELECT * FROM fruit "; $result = mysql_query($query) or die(mysql_error().'Error, query failed'); $tsv=""; $html=""; $xml = ""; while($row = mysql_fetch_array($result)) {         $xml .="<tr><td>".$row['id']."</td><td>".$row['name']."</td><td>".$row['price']."</td></tr>"; } $html .= "<table border=1 style='border-color:#CCCCCC'><tr><td><b>Fruit id</b></td><td><b>Fruit name</b></td>...

FUTURE DATABASE TECHNOLOGIES

Image
http://en.wikipedia.org/wiki/MongoDB http://en.wikipedia.org/wiki/HBase http://en.wikipedia.org/wiki/Redis http://en.wikipedia.org/wiki/Apache_Cassandra

How to find difference between (existing field time_stamp) and (current_time_stamp)?

‎1st insert current time into databse using time() function . after that retrive that time from data base and use there function  <?php $query = Select time from database; $clk = $row['time_databse']; ?> <?php $time_difference = time() -$clk ;  $seconds = $time_difference ;  $minutes = round($time_difference / 60 ); $hours = round($time_difference / 3600 );  $days = round($time_difference / 86400 );  $weeks = round($time_difference / 604800 );  $months = round($time_difference / 2419200 );  $years = round($time_difference / 29030400 );  if($seconds <= 60) { echo"$seconds seconds ago";  } else if($minutes <=60) { if($minutes==1) { echo"one minute ago";  } else { echo"$minutes minutes ago";  } } else if($hours <=24) { if($hours==1) { echo"one hour ago"; } else { echo"$hours hours ago"; } } else if($days <=7) { if($days==1) { echo"one day ago"; } else { echo"$days days ago"; } } else if($wee...

Stored Procedure Lesson ?

Are you writing Stored Procedures if not please take a look at this post. Stored procedures can help to improve web application performance and reduce database access traffic. In this post I want to explain how to create and call the stored procedures from database server. Database:- users table contains username and name. CREATE TABLE users ( id INT PRIMARY KEY AUTO_INCREMENT, username VARCHAR(50) UNIQUE, name VARCHAR(50), ); Results.php (Direct database server access):- Calling SQL statements directly. Here displaying the users content with PHP. <?php include('db.php'); // Check code below of the post. $sql=mysql_query("SELECT user,name FROM users"); while($row=mysql_fetch_array($sql)) { echo $row['user'].'--'.$row['name'].'</br>'; } ?> How to Create Stored Procedure? You can create stored procedures that run on your database server. Stored Procedure name users(). Just like SQL statements.  DELIMITER //  CREATE PROCEDURE ...