Adsense
Shankar wins Indian of the year 2010
Every Year CNN-IBN honored the most successful people by Indian of the year award.Today it has announced Indian of the year in entertainment category.Shankar wins Indian of the year 2010.Aamir khan and rajini are the other important competitor in the entertainment category.
Sun network to start TV in Marathi, Benagli
The most viewed south India TV sun network plans to launch TV channels in north region.It was founded and currently owned by Kalanidhi Maran. Already it has joined with Network 18 and created SUN 18.Except Hindi , It has planned to start all north Indian language like Marathi, Bengali channels soon.
Reliance launched 3G service
Features of 3G:
- Video Call
- Mobile TV
- Fast Mobile Internet
Welcome message in drupal
<?php global $user; ?>
Welcome <?php print l($user->name,'user/'.$user->uid); ?>
<?php ?>
Welcome <?php print l($user->name,'user/'.$user->uid); ?>
<?php ?>
PHP file handling - functions Add, Edit, Update Image file
Functions.php
<?php
include("../db_connection/db_config.php");
if(isset($_POST["add"]))
{
header("location:../add.php");
}
if(isset($_POST['submit']))
{
$news_title=$_POST['news_title'];
$news_desc=$_POST['news_desc'];
$news_sdate=$_POST['news_sdate'];
$news_edate=$_POST['news_edate'];
$news_status=$_POST['news_status'];
if ($_FILES["file"]["size"] == 0)
{
$fileName="";
}
else
{
if (($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
$fileName= $_FILES["file"]["name"];
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
$fileName= $_FILES["file"]["name"];
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
}
mysql_query("INSERT INTO news (news_title, news_desc, news_sdate, news_edate, status, image)
VALUES ('$news_title', '$news_desc', '$news_sdate', '$news_edate', '$news_status', '$fileName' )");
if(mysql_query)
{
//header("location:../news.php");
}
}
if(isset($_POST['update']))
{
$news_title=$_POST['news_title'];
$news_desc=$_POST['news_desc'];
$news_sdate=$_POST['news_sdate'];
$news_edate=$_POST['news_edate'];
$news_status=$_POST['news_status'];
if ($_FILES["file"]["size"]==0)
{
$result= "UPDATE news SET news_title='$news_title',news_desc='$news_desc', news_sdate='$news_sdate', news_edate='$news_edate', status='$news_status'
WHERE news_id=".$_POST['newsid'];
mysql_query($result);
if(mysql_query)
{
header("location:../news.php");
}
}
else
{
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 90000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
$fileName= $_FILES["file"]["name"];
//unlink("upload/" . $_FILES["file"]["name"]));
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
$fileName= $_FILES["file"]["name"];
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
$result= "UPDATE news SET news_title='$news_title',news_desc='$news_desc', news_sdate='$news_sdate', news_edate='$news_edate', status='$news_status',image='$fileName'
WHERE news_id=".$_POST['newsid'];
mysql_query($result);
if(mysql_query)
{
header("location:../news.php");
}
}
}
if(isset($_POST['delete']))
{
$news_id=$_POST['delchk'];
foreach ($news_id as $value)
{
$result="DELETE FROM news WHERE news_id =".$value;
//echo $result ."</br>";
mysql_query($result);
}
header("location:../news.php");
}
if(isset($_POST['display']))
{
echo "display"."</br>";;
$newsid=$_POST['newsid'];
foreach ($newsid as $value)
{
$result="UPDATE news SET status=0 WHERE news_id=".$value;
mysql_query($result);
// echo $result ."</br>";
}
echo "updated"."</br>";;
$news_id=$_POST['dischk'];
foreach ($news_id as $value)
{
$result="UPDATE news SET status=1 WHERE news_id=".$value;
mysql_query($result);
//echo $result ."</br>";
}
header("location:../news.php");
}
?>
Ajax form suggestion
schform.php
<html>
<head>
<script type="text/javascript">
var url = "getagenttel.php?param=";
function getagenttel()
{
var idValue = document.getElementById("agtel").value;
var myRandom = parseInt(Math.random()*99999999); // cache buster
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("hiddenDIV2").style.visibility="visible";
document.getElementById("hiddenDIV2").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", url + escape(idValue) + "&rand=" + myRandom,true);
xmlhttp.send();
}
function loadrecord(record) { document.schform.telno.value = record; }
</script>
</head>
<body>
<form name="schform" onReset="this.telno.value='';getagenttel()">
<table>
<tr>
<td>Tel Number:</td>
<td><input id="agtel" type="text" name="telno" onKeyUp="getagenttel();">
<input type="reset" value="Clear Entry Field"></td></tr>
</table>
</form>
<div id="hiddenDIV2" style="position:relative; top: -22px; left: 85px;width: 200; visibility:hidden; background-color:white; border: 1px solid black;"> </div>
</body>
</html>
getagenttel.php
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="suggest"; // Database name
$con = mysql_connect("$host","$username","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$db_name", $con);
//mysql_close($con);
if(strlen($param)>0)
{
$result = mysql_query("SELECT * FROM contact WHERE ContactTel LIKE '$param%'");
if(mysql_num_rows($result)>0)
{
while($myrow = mysql_fetch_array($result))
{
$agenttel = $myrow["ContactTel"];
$agentid = $myrow["ContactID"];
$textout .= "<table><tr style=\"border: 0px solid black\"> <td style=\"border: 0px solid black; padding: 0px 10px 0px 10px\"> <a href=\"javascript:loadrecord('".$agenttel."')\">" .$agentid."</a></td> <td style=\"border: 0px solid black; padding: 0px 10px 0px 10px\">" .$agenttel."</td></tr></table>";
}
}
else { $textout=""; }
}
echo $textout;
?>
database: suggest
-- Table structure for table `contact`
--
CREATE TABLE `contact` (
`ContactTel` double NOT NULL auto_increment,
`ContactID` varchar(50) NOT NULL,
PRIMARY KEY (`ContactTel`),
UNIQUE KEY `ContactTel` (`ContactTel`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1778 ;
--
-- Dumping data for table `contact`
--
INSERT INTO `contact` (`ContactTel`, `ContactID`) VALUES
(1122, 'ATTORNEY'),
(1223, 'FAYE'),
(1234, 'ANNE'),
(1777, 'BOSS');
<html>
<head>
<script type="text/javascript">
var url = "getagenttel.php?param=";
function getagenttel()
{
var idValue = document.getElementById("agtel").value;
var myRandom = parseInt(Math.random()*99999999); // cache buster
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("hiddenDIV2").style.visibility="visible";
document.getElementById("hiddenDIV2").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", url + escape(idValue) + "&rand=" + myRandom,true);
xmlhttp.send();
}
function loadrecord(record) { document.schform.telno.value = record; }
</script>
</head>
<body>
<form name="schform" onReset="this.telno.value='';getagenttel()">
<table>
<tr>
<td>Tel Number:</td>
<td><input id="agtel" type="text" name="telno" onKeyUp="getagenttel();">
<input type="reset" value="Clear Entry Field"></td></tr>
</table>
</form>
<div id="hiddenDIV2" style="position:relative; top: -22px; left: 85px;width: 200; visibility:hidden; background-color:white; border: 1px solid black;"> </div>
</body>
</html>
getagenttel.php
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="suggest"; // Database name
$con = mysql_connect("$host","$username","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$db_name", $con);
//mysql_close($con);
if(strlen($param)>0)
{
$result = mysql_query("SELECT * FROM contact WHERE ContactTel LIKE '$param%'");
if(mysql_num_rows($result)>0)
{
while($myrow = mysql_fetch_array($result))
{
$agenttel = $myrow["ContactTel"];
$agentid = $myrow["ContactID"];
$textout .= "<table><tr style=\"border: 0px solid black\"> <td style=\"border: 0px solid black; padding: 0px 10px 0px 10px\"> <a href=\"javascript:loadrecord('".$agenttel."')\">" .$agentid."</a></td> <td style=\"border: 0px solid black; padding: 0px 10px 0px 10px\">" .$agenttel."</td></tr></table>";
}
}
else { $textout=""; }
}
echo $textout;
?>
database: suggest
-- Table structure for table `contact`
--
CREATE TABLE `contact` (
`ContactTel` double NOT NULL auto_increment,
`ContactID` varchar(50) NOT NULL,
PRIMARY KEY (`ContactTel`),
UNIQUE KEY `ContactTel` (`ContactTel`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1778 ;
--
-- Dumping data for table `contact`
--
INSERT INTO `contact` (`ContactTel`, `ContactID`) VALUES
(1122, 'ATTORNEY'),
(1223, 'FAYE'),
(1234, 'ANNE'),
(1777, 'BOSS');
Javascript checkbox select all
<input name="dischk[]" type="checkbox">
<input name="disall" onclick="checkedAll(document.myform['dischk[]']);" type="checkbox" >
function checkedAll(field) {
if(document.myform.disall.checked)
{
for (i = 0; i < field.length; i++)
field[i].checked = true;
}
else
{
for (i = 0; i < field.length; i++)
field[i].checked = false;
}
}
PHP interview questions - Part 3
How will you get an size of array ?
ans:count()
Cookies - temp file in user computer.it will user information to server.
cookie function?
ans: set cookie(name, value, expire, path, domain)
cookie variable?
ans: $_cookie.
how will you destroy cookie?
ans: giving past date in expire.
Session -temp file in server to identify a user
-to carry user information to entire application
session variable?
ans:$_session
How to destroy session?
ans:using unset and destroy.
PHP string handling
How to search a word?
ans:strpos-if a string(word is available it will return a position of string or it will return FALSE)
Primary key
diff b/w primary and unique key?
Index,constraint
PHP oops
Constructor, create class
SQL
Joins
inner-atleast one match in both table.
left-return all rows from left even there is no match in right table.
right- return all rows from right table even there is no match in left table.
Javascript
DOM, onselect
CSS
diff b/w class and id?
ans:count()
Cookies - temp file in user computer.it will user information to server.
cookie function?
ans: set cookie(name, value, expire, path, domain)
cookie variable?
ans: $_cookie.
how will you destroy cookie?
ans: giving past date in expire.
Session -temp file in server to identify a user
-to carry user information to entire application
session variable?
ans:$_session
How to destroy session?
ans:using unset and destroy.
PHP string handling
How to search a word?
ans:strpos-if a string(word is available it will return a position of string or it will return FALSE)
Primary key
diff b/w primary and unique key?
Index,constraint
PHP oops
Constructor, create class
SQL
Joins
inner-atleast one match in both table.
left-return all rows from left even there is no match in right table.
right- return all rows from right table even there is no match in left table.
Javascript
DOM, onselect
CSS
diff b/w class and id?
Subscribe to:
Posts (Atom)