Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Next and Previous Buttons

By // No comments:
NEXT AND PREVIOUS BUTTONS

<?php
if(isset($_REQUEST['ind']))
 $sind = $_REQUEST['ind'];
else
 $sind = 0;
$totrec = 5;
mysql_connect("localhost","root","");
mysql_select_db("information_schema");
$data = mysql_query("select * from character_sets limit $sind, $totrec");
while($rec=mysql_fetch_row($data)){
 echo "<tr><td>$rec[0]<td>$rec[1]<td>$rec[2]";
}
echo "</table>";
if($sind!=0){
 $pind = $sind - $totrec;
 echo "<a href='demo.php?ind=$pind'>Previous</a>";
}
$nind = $sind + $totrec;
echo "<a href='demo.php?ind=$nind'>Next</a>";

//to stop display next button on last page
$data1 = mysql_query("select * from character_sets");
$trec = mysql_num_rows($data1);
if($nind < $trec){
 echo "next";
}
?>

Store images in database

By // No comments:
HOW TO STORE IMAGES IN DATABASES

<?php
mysql_connect("localhost","root","");
mysql_select_db("test");
$cont = file_get_contents("winter.jpg");
$cont = addslashes($cont);
if(mysql_query("insert into tbl_images values('','$cont')"))
 echo "IMage is added";
else
 echo "not";
?>

TABLE 
sno int auto_increment primary key, image BLOB or LONG BLOB

RETRIEVE IMAGES FROM DATABASE
<?php
header("Content-type:image/jpeg");
mysql_connect("localhost","root","");
mysql_select_db("test");
$data = mysql_query("select * from tbl_images where imgid=3");
$rec = mysql_fetch_row($data);
echo $rec[1];
?>

INSERT statement SQL

By // No comments:
insert into tbl_user (uname) values ('John');
insert into tbl_user values ('alex','alex123'),('rajesh','rajesh123');