linkedin facebook linkedin facebook nod32

Cat_qarang.php faylini yaratish usuli

Muallif: Mengliyev Sh.

Qo`shilgan sana: 2015-12-23

Cat_qarang.php faylini yaratish usuli

Video darslik

Data bazani phpMyadmin ga baza hosil qilib ushbu bazanomi yaratilgandan so`ng sql qismiga joylashtiring

CREATE TABLE `data` (
`id` int( 10 ) NOT NULL AUTO_INCREMENT ,
`cat` int( 2 ) NOT NULL default '0',
`title` varchar( 255 ) NOT NULL default '',
`meta_d` varchar( 255 ) NOT NULL default '',
`meta_k` varchar( 255 ) NOT NULL default '',
`text` text NOT NULL default '',
`author` varchar( 255 ) NOT NULL default '',
`date` date ,
`mini_img` varchar( 255 ) NOT NULL default '',
`view` int( 7 ) NOT NULL default '0',

KEY `id` ( `id` )
)

Jаdvаl (nоmi data), qоldirilgаn mа’lumоtlаrni o‘z ichigа оlib, quyidаgi tаrkibgа egа:
id - yozuvning identifikаtsiоnn unikаl nоmeri;
cat- categoriyalarni tanlash bo`limi;
title– sahifa mavzusi;
meta_d – qidruv tizimi bo`yicha sarlavha so`zlar;
meta_k – qidruv tizimi bo`yicha kalit so`zlar;
text– mavzu bayonini kiritish bo`limi;
author – mavzu bayonining muallifini kiritish bo`limi;
date– mavzu bayonini vaqt bo`yicha kiritish bo`limi;
mini_img – mavzu bayonini kichik rasmni kiritish bo`limi;
view – mavzu bayonini necha marta o`qish bo`limi son hisobida;

Cat_qarang.php faylni yuqori qismiga ya’ni <html> yuqori qismiga quyidagi kodni joylashtiramiz.

<?php
if (isset($_GET['cat'])) {$cat = $_GET['cat']; }
if (!isset($cat)) {$cat = 1;}

 

if (!preg_match("|^[\d]+$|", $cat)) {
exit ("<p>So`rov noto`g`ri! URL tekshiring!");
}

$result = mysql_query("SELECT * FROM cat WHERE id='$cat'",$db);

if (!$result)
{
echo "<p>Tanlangan so`rov bazaga yuborilmadi. Adminstratorga xat yozing admin@tami.uz <br> <strong>Kodda xato:</strong></p>";
exit(mysql_error());
}

if (mysql_num_rows($result) > 0)

{
$myrow = mysql_fetch_array($result);
}
else
{
echo "<p>Axborot so`rovi bazaga saqlanmadi bazada jadval yo`q.</p>";
exit();
}
?>
Ososiy matn chiqariladigan qismiga quyidagi koddi joylashtiring.
<?php
echo $myrow["text"];
$num = 3;
/* Url sahifadan ko`chirma olish*/
@$page = $_GET['page'];
/* ma’lumotlar bazasidan catlar sonini aniqlaymiz*/
$result00 = mysql_query("SELECT COUNT(*) FROM data WHERE cat='$cat'");
$temp = mysql_fetch_array($result00);
$posts = $temp[0];
/* umumiy sahifalar sonini topamiz*/
$total = (($posts - 1) / $num) + 1;
$total = intval($total);
/* Ushbu sahifa uchun catlar boshini aniqlaymiz*/
$page = intval($page);
/* Agar $page imkoniyati 1 ta inkor bo`lsa
Ilk birinchi sahifaga o`tish
Agar juda kata bo`lsa, oxirgisiga o`tish */
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
/* Catning qaysidir nomeridan hisoblab boshlaydi
catni ochmoq */
$start = $page * $num - $num;
/* $start nomeri boshidan $num nomeri boshini tanlash */

$result = mysql_query("SELECT id,title,date,author,mini_img,view FROM data WHERE cat='$cat' ORDER BY date DESC,id DESC LIMIT $start, $num",$db);

if (!$result)
{
echo "<p>Tanlangan so'rov bazaga yuborilmadi. Adminstratorga xat yozing admin@shoydullo. <br> <strong>Kodda xato:</strong></p>";
exit(mysql_error());
}
if (mysql_num_rows($result) > 0)
{
$myrow = mysql_fetch_array($result);
do
{
printf (" <div class='zzzzz1'>

<tr>
<td class='post_title'>
<p class='post_name'>
<img class='mini' align='left' src='%s'>
<a href='matnga_qarang.php?id=%s'>%s</a></p>
</td>
</tr>

<tr>
<td > <p class='infopost' <span class='date'>Qo`shilgan sana: %s &nbsp;&nbsp;</span>

Axborot muallifi: %s &nbsp;&nbsp; <a href='#' class='com' <span> (%s) </span> marta o`qildi </a> </p>
</td>
</tr>
</div><br><br>",$myrow["mini_img"],$myrow["id"],$myrow["title"], $myrow["date"],$myrow["author"], $myrow["view"]);
}
while ($myrow = mysql_fetch_array($result));
/* Orqaga qaytish uchun belgi*/
if ($page != 1) $pervpage = '<a href=cat_qarang.php?cat='.$cat.'&page=1>

Birinchi</a> | <a href=cat_qarang.php?cat='.$cat.'&page='. ($page - 1) .'>Oldingi</a> | ';
/* Oldinga o`tish uchun belgi */
if ($page != $total) $nextpage = ' | <a href=cat_qarang.php?cat='.$cat.'&page='. ($page + 1) .'>

Keyingi</a> | <a href=cat_qarang.php?cat='.$cat.'&page=' .$total. '>Oxirgi</a>';
/* Ikki tomondan sahifalarni topamiz, agar ular bo`lsa */

if($page - 6 > 0) $page6left = ' <a href=cat_qarang.php?cat='.$cat.'&page='. ($page - 6) .'>'. ($page - 6) .'</a> | ';
if($page - 5 > 0) $page5left = ' <a href=cat_qarang.php?cat='.$cat.'&page='. ($page - 5) .'>'. ($page - 5) .'</a> | ';
if($page - 4 > 0) $page4left = ' <a href=cat_qarang.php?cat='.$cat.'&page='. ($page - 4) .'>'. ($page - 4) .'</a> | ';
if($page - 3 > 0) $page3left = ' <a href=cat_qarang.php?cat='.$cat.'&page='. ($page - 3) .'>'. ($page - 3) .'</a> | ';
if($page - 2 > 0) $page2left = ' <a href=cat_qarang.php?cat='.$cat.'&page='. ($page - 2) .'>'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = '<a href=cat_qarang.php?cat='.$cat.'&page='. ($page - 1) .'>'. ($page - 1) .'</a> | ';

if($page + 6 <= $total) $page6right = ' | <a href=cat_qarang.php?cat='.$cat.'&page='. ($page + 6) .'>'. ($page + 6) .'</a>';
if($page + 5 <= $total) $page5right = ' | <a href=cat_qarang.php?cat='.$cat.'&page='. ($page + 5) .'>'. ($page + 5) .'</a>';
if($page + 4 <= $total) $page4right = ' | <a href=cat_qarang.php?cat='.$cat.'&page='. ($page + 4) .'>'. ($page + 4) .'</a>';
if($page + 3 <= $total) $page3right = ' | <a href=cat_qarang.php?cat='.$cat.'&page='. ($page + 3) .'>'. ($page + 3) .'</a>';
if($page + 2 <= $total) $page2right = ' | <a href=cat_qarang.php?cat='.$cat.'&page='. ($page + 2) .'>'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href=cat_qarang.php?cat='.$cat.'&page='. ($page + 1) .'>'. ($page + 1) .'</a>';
/*Agar sahifa bittadan ko`p bo`lsa, menyuni chiqarish */
if ($total > 1)
{
Error_Reporting(E_ALL & ~E_NOTICE);
echo "<div class=\"pstrnav\" align='center'>";
echo $pervpage.$page6left.$page5left.$page4left.$page3left.$page2left.$page1left.'<b>'.$page.'</b>'

.$page1right.$page2right.$page3right.$page4right.$page5right.$page6right.$nextpage;
echo "</div>";
}
}

else
{
echo "<p>Axborot so'rovi bazaga saqlanmadi bazada jadval yo'q.</p>";
exit();
}

?>

2008 marta o`qildi.

Parol:
Eslab qolish.


Ro`yhatdan o`tish

testing

+998915878681

Siz o`z maxsulotingizni 3D reklama ko`rinishda bo`lishini xohlaysizmi? Unda xamkorlik qilamiz.

3D Reklama


Рейтинг@Mail.ru
Рейтинг@Mail.ru

Besucherzahler
счетчик посещений