Posted by: Anil Kumar Panigrahi in: ● August 15, 2010
Hi friends,
This post is to change the order in admin and display those content depends on order. Today i want to share with you all.
Take table that
CREATE TABLE tblOrder (
`post_id` int(11) ,
`sortorder` int(11) NOT NULL default ‘0′,
)
At the admin section: PHP Code
manageorder.php
<?php
$query = "SELECT * FROM tblOrder order [...]
Posted by: Anil Kumar Panigrahi in: ● March 25, 2010
Hi friends,
I got the requirement to display the list of table names from the database using php code. I got the solution for it, once check the below code.
1) Connect to database:
mysql_connect(“dbserver”,”dbuser”,”dbpassword”);
2)Get the list of tables from table
$result = mysql_list_tables(“dbname”);
3) Count the total number of tables
$num_tables = mysql_num_rows($result);
3) Display the tables names
for($i=0;$i<$num_rows;$i++)
{
echo “Table : <b>”.mysql_tablename($result,$i).”</b>”;
}
mysql_free_result($result);
In [...]
Posted by: Anil Kumar Panigrahi in: ● March 18, 2010
Hi friends,
In our php application some times we want to highlight the source code to user friendly , so the following function helped you to highlight the source code.
<?php
if (!empty($_POST[’text’])){
echo ‘<div style="border: solid 1px red; width:300px;height: 150px; padding: 20px; margin: 20px">’;
highlight_string(stripslashes($_POST[’text’]));
echo ‘</div>’;
}
?>
<form action="<?php echo $_SERVER[’PHP_SELF’]?>" method="post">
<textarea name="text" style="width: 300px; height: 150px;padding: 20px; margin: 20px"><?php echo [...]
Posted by: Anil Kumar Panigrahi in: ● March 16, 2010
Hi friends,
following code is very simple to get the friendly file size format using php code.
function frndlyfilesize($filesize){
if(is_numeric($filesize)){
$decr = 1024;
$step = 0;
$prefix = array(‘Byte’,’KB’,’MB’,’GB’,’TB’,’PB’);
while(($fileName / $decr) > 0.9){
$filesize = $filesize / $decr;
$step++;
}
return round($filesize,2).’ ‘.$prefix[$step];
} else {
return ‘Nothing’;
}
}
To call that function :
$ filesize = filesize(“test.jpg”);
$newSize = frndlyfilesize($filesize);
Expected output like the format :
5 MB or 5 KB or [...]
Comments