Archive for January, 2010

How to show data from database in php

//……………………….show.php…………………………..\\

<table>
<tr>
<td align=”center”>EDIT DATA</td>
</tr>
<tr>
<td>
<table border=”1″>
<?
$con = mysql_connect(“localhost”,””,””);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

mysql_select_db(“naogaon”, $con);
$order = “SELECT * FROM member”;
$result = mysql_query($order);
while ($row=mysql_fetch_array($result)){
echo (“<tr><td>$row[number]</td>”);
echo (“<td>$row[name]</td>”);
echo (“<td>$row[address]</td>”);
echo (“<td><a href=\”edit_form.php?id=$row[employees_number]\”>Edit</a></td></tr>”);
}
?>
</table>
</td>
</tr>
</table>

output:

Advertisements

Inserting Data in php MySQL database.

To inserting a data to database you have to create a database and a table in going to http://localhost/phpmyadmin..

suppose your database name is naogaon and table name is member with three fields number, name and address

then write the following code in a editor and save it as

//……………………insert.html……………………….\\

<form action=”Insert.php” method=”post”>
Number: <input type=”text” name=”M_number” />
Name: <input type=”text” name=”M_name” />
Address: <input type=”text” name=”M_address” />
<input type=”submit” />
</form>

now write another php code and save it as

//…………………insert.php……………………….\\

<?php
$con = mysql_connect(“localhost”,””,””);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

mysql_select_db(“naogaon”, $con);

$sql=”INSERT INTO member (number, name, address)
VALUES
(‘$_POST[M_number]’,’$_POST[M_name]’,’$_POST[M_address]’)”;

if (!mysql_query($sql,$con))
{
die(‘Error: ‘ . mysql_error());
}
echo “1 record added”;

mysql_close($con)
?>

How to Display Data from Database to selectbox

It is very easy. At first you have to insert some data to your database suppose its database name is naogaon and table name is member and there is colum name by number then.. write the following code and save you as your like.. ok done check it.

//    …………………Selectbox.php…………………….\\

<?php
$con = mysql_connect(“localhost”,””,””);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}
mysql_select_db(“naogaon”, $con);
$query = “SELECT number FROM member order by number “;

$result = mysql_query($query) or die(“Couldnt execute query.”);

echo ‘<select name=”number” id=”number”>’;
while($row = mysql_fetch_array($result))
{
$val = $row[‘number’];
echo “<option value=$val>$val</option>”;
}
echo ‘</select>’;

?>

 

How to upload a image in MySQL database in php

here I just tested the code.. at first you need to create a database and create a table with two field named by “fileloc” and “id” and also create a folder “pic” in apache htdocs.

then save the following code as    upload.html………..

<form action=”upload.php” method=”post”
enctype=”multipart/form-data”>
<label for=”file”>Upload a picture:</label>
<p>
<input type=”file” name=”file”  />
</p>
<p><br />
Enter id
<input name=”id” type=”text”>
</p>
<p>
<input type=”submit” name=”submit” value=”Submit” />
</p>
</form>

after saving this open a new window and write the following code and save as upload.php

<?php
if ((($_FILES[“file”][“type”] == “image/gif”)
|| ($_FILES[“file”][“type”] == “image/jpeg”)
|| ($_FILES[“file”][“type”] == “image/pjpeg”))
&& ($_FILES[“file”][“size”] < 400000))
{
if ($_FILES[“file”][“error”] > 0)
{
echo “Return Code: ” . $_FILES[“file”][“error”] . “<br />”;
}
else
{
echo “Upload: ” . $_FILES[“file”][“name”] . “<br />”;

if (file_exists(“pic/” . $_FILES[“file”][“name”]))
{
echo $_FILES[“file”][“name”] . ” already exists. “;
}
else
{
move_uploaded_file($_FILES[“file”][“tmp_name”],”pic/” . $_FILES[“file”][“name”]);
echo “Stored in: ” . “pic/” . $_FILES[“file”][“name”];
}
}
}
else
{
echo “Invalid file”;
}

?>

<?php include(“dbconnect.php”);?>

<? $id=$_POST[‘id’];
$fileloc=”pic”.”/”.$_FILES[“file”][“name”];
echo $id;
echo $fileloc;
$query=”INSERT INTO fileupload(id,fileloc) VALUES (‘$id’,’$fileloc’)”;
$d=@mysql_query($query);
if ($d)
echo “Success”;

?>

yaa done ! now try yourself..

How to upload a file in phpMySQL database

It is very easy just at first you have to  create a table in mysql under a database with five fields like as  description, data, filename, filesize, filetype and  write the following code

//…………………………………upload.html…………………………………………………\\

<html>
<body>
<form method=”post” action=”upload1.php” enctype=”multipart/form-data”>
Description:<br>
<input type=”text” name=”form_description” size=”40″>
<input type=”hidden” name=”MAX_FILE_SIZE” value=”1000000″>
<br>File to upload:<br>
<input type=”file” name=”form_data” size=”40″>
<p><input type=”submit” name=”submit” value=”submit”>
</form>
</body>
</html>

then write an another php program like as

//…………………………..upload.php………………………………………………\\

<?php
mysql_connect(“localhost”,”username”,”password”);
mysql_select_db(“database_name”);
$data = addslashes(fread(fopen($form_data, “r”), filesize($form_data)));
$result=MYSQL_QUERY(“INSERT INTO uploads (description, data,filename,filesize,filetype) “. “VALUES (‘$form_description’,’$data’,’$form_data_name’,’$form_data_size’,’$form_data_type’)”);
$id= mysql_insert_id();
print “<p>File ID: <b>$id</b><br>”;
print “<p>File Name: <b>$form_data_name</b><br>”;
print “<p>File Size: <b>$form_data_size</b><br>”;
print “<p>File Type: <b>$form_data_type</b><p>”;
?>

ok done.. you try yourself

Showing Cricket Score to Firefox Status bar

Many website are now used to show current cricket Score.. but if you don’t want enter those website and want to know the current score then this way is needed for you.. just go..https://addons.mozilla.org/en-US/firefox/addon/4699 and add a add-ons and then restart the firefox… yaaa it is done and enjoy..

ফায়ারফক্সের গতি বাড়ান খুবই সহজে

কিভাবে করতে হবে

১) এড্রেস বারে লিখুন about:config

২)স্ক্রল করে খুজে বের করুন এই এন্ট্রিগুলো

network.http.pipelining

network.http.proxy.pipelining network.http.pipelining.maxrequests

এইবার প্রথম এবং দ্বিতীয় টিকে true করে দিন তৃতীয়টির নাম্বার ভ্যালু সেট করে দিন 30

3) অবশেষে রাইট বাটনে ক্লিক করে নতুন একটি integer নিন নাম দিন nglayout.initialpaint.delay এটার ভ্যালু সেট করে দিন 0 ব্যাস হয়ে গেল

এবার দেখুন আপনার ফায়ারফক্সের গতি কেমন বেড়েছে।