শুক্রবার, ৮ নভেম্বর, ২০১৩

Make Data base

CREATE TABLE IF NOT EXISTS `post` (
   `id` int(11) NOT NULL auto_increment,
   `title` varchar(255) NOT NULL,
   `detail` text NOT NULL,
   PRIMARY KEY  (`id`)
 )


Insert data in database

INSERT INTO `test`.`post` (`id`, `title`, `detail`)
 VALUES (NULL, 'Concept', 'Web Technologies'),
 (NULL, 'HTML', 'Basic HTML, Special Tags, Formatting Tags, HTML Forms'),
 (NULL, 'CSS', 'Basic CSS, Advanced Topics, '),
 (NULL, 'JAVASCRIPT', 'Syntax, Enable, Location, External, Operators, Variable'),
 (NULL, 'PHP BASIC PART1', 'Introduction To PHP'),
 (NULL, 'PHP Basic 2', 'Arrays and Array Functions'),
 (NULL, 'MySQL Basic', 'Introduction To MySQL'),
 (NULL, 'CMS', 'What is Joomla'),
 (NULL, 'XML', 'What is XML'),
 (NULL, 'PHP Date', 'What''s a timestamp'),
 (NULL, 'Files', 'Reading Files'),
 (NULL, 'JavaScript', 'Ajax Basics'),
 (NULL, 'File Formats', 'Creating PDF Files'),
 (NULL, 'MySQL Database Administrators', 'Understanding MySQL Table Types'),
 (NULL, 'PHP OOP', 'Understanding OOP Concepts');



Make CSS File

page_links
 {
  font-family: arial, verdana;
  font-size: 12px;
  border:1px #000000 solid;
  padding: 6px;
  margin: 3px;
  background-color: #cccccc;
  text-decoration: none;
 }
 #page_a_link
 {
  font-family: arial, verdana;
  font-size: 12px;
  border:1px #000000 solid;
  color: #ff0000;
  background-color: #cccccc;
  padding: 6px;
  margin: 3px;
  text-decoration: none;
 }


Config file

<!--?php   //Host name   $host = "localhost";         //Username   $user = "root";         //Password   $password = "";         //Database Name   $database = "blogs";   $db = mysql_connect($host, $user, $password);   if($db)   {    $select_db = mysql_select_db($database);    if(!$select_db)    {     echo 'Database Error:'. mysql_error();    }   }else   {    echo 'Connection Error:'. mysql_error();   }  ?-->


PHP file 

<!--?php require_once "config.php"; ?-->





Pagination || http://www.w3programmers.com
 <link href="style.css" rel="stylesheet" type="text/css" /></pre>
<table style="border: 1px #000000 solid;" width="400" cellspacing="2" cellpadding="2" align="center">
<!--?php $perpage = 5; if(isset($_GET["page"])) { $page = intval($_GET["page"]); } else { $page = 1; } $calc = $perpage * $page; $start = $calc - $perpage; $result = mysql_query("select * from post Limit $start, $perpage"); $rows = mysql_num_rows($result); if($rows) { $i = 0; while($post = mysql_fetch_array($result)) { ?-->
<tbody>
<tr style="background-color: #cccccc;">
<td style="font-weight: bold; font-family: arial;"></td>
</tr>
<tr>
<td style="font-family: arial; padding-left: 20px;"></td>
</tr>
<!--?php } } ?--></tbody>
</table>
<pre>



</pre>
<table width="400" cellspacing="2" cellpadding="2" align="center">
<tbody>
<tr>
<td align="center">
<!--?php <br ?-->
if(isset($page))

{

$result = mysql_query("select Count(*) As Total from post");

$rows = mysql_num_rows($result);

if($rows)

{

$rs = mysql_fetch_array($result);

$total = $rs["Total"];

}

$totalPages = ceil($total / $perpage);

if($page <=1 )

{

echo "<span id="page_links" style="font-weight: bold;">Prev</span>";

}

else

{

$j = $page - 1;

echo "<span><a id="page_a_link" href="index.php?page=$j">< Prev</a></span>";

}

for($i=1; $i <= $totalPages; $i++)

{

if($i<>$page)

{

echo "<span><a id="page_a_link" href="index.php?page=$i">$i</a></span>";

}

else

{

echo "<span id="page_links" style="font-weight: bold;">$i</span>";

}

}

if($page == $totalPages )

{

echo "<span id="page_links" style="font-weight: bold;">Next ></span>";

}

else

{

$j = $page + 1;

echo "<span><a id="page_a_link" href="index.php?page=$j">Next</a></span>";

}

}

?></td>
<td></td>
</tr>
</tbody>
</table>
<pre>


<!--?php <br ?-->  if(isset($page))
  {
   $result = mysql_query("select Count(*) As Total from post");
   $rows = mysql_num_rows($result);
   if($rows)
   {
    $rs = mysql_fetch_array($result);
    $total = $rs["Total"];
   }
   $totalPages = ceil($total / $perpage);
   if($page <=1 )
   {
    echo "<span id="page_links" style="font-weight: bold;">Pre</span>";
   }
   else
   {
    $j = $page - 1;
    echo "<span><a id="page_a_link" href="index.php?page=$j">< Pre</a></span>";
   }
   for($i=1; $i <= $totalPages; $i++)
   {
    if($i<>$page)
    {
     echo "<span><a id="page_a_link" href="index.php?page=$i">$i</a></span>";
    }
    else
    {
     echo "<span id="page_links" style="font-weight: bold;">$i</span>";
    }
   }
   if($page == $totalPages )
   {
    echo "<span id="page_links" style="font-weight: bold;">Next ></span>";
   }
   else
   {
    $j = $page + 1;
    echo "<span><a id="page_a_link" href="index.php?page=$j">Next</a></span>";
   }
  }
 ?>



কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন