2 в 1

_4efo_

Registered
Искам да направя от 2скрипта 1... но не се получи желания ефект, че ви моля за помощ :)
script1:
Код:
<?php

include"connect.php";
include"functions.php";

list_categories();

switch($_GET['cat']) {

case"$row[id]";
if(!isset($_POST['$row[id]'])) {
if($_GET['id']) {
$id = (int)$_GET['id'];
$query3 = mysql_query("SELECT * FROM tutorials WHERE valid = '1' AND cat_id = '$id' ORDER BY id DESC");
while($row = mysql_fetch_array($query3)) {
echo"
<table width='100%'>
<tr>
<td width='52'>
<img src='$row[image]' alt=''>
</td>
<td>

<b><a href='viewtut.php?action=view&id=$row[id]'>$row[tutname]</a></b>
$row[shortdes].
Author: <b>$row[authname]</b> | Views: <b>$row[views]</b> | Date: <b>$row[date]</b> |
</td>
</tr>
</table>";

}
}
}

}

?>
script2:
Код:
<?php

include"connect.php";
include"functions.php";






if(!isset($_GET['pagenum'])){
    $page = 1;
} else {
    $page = $_GET['pagenum'];
}


$max_results = 6;
$from = (($page * $max_results) - $max_results);

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM tutorials"),0);

$total_pages = ceil($total_results / $max_results);

echo "<center><p><br />";

if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\" class='style3'><<Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i ";
        } else {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\" class='style3'>$i</a> ";
    }
}


if($page < $total_pages){
    $next = ($page + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\" class='style3'>next>></a>";
}
echo "</p></center>"; 
}



}

}


?>
А това е което получих аз...
Код:
<?php

include"connect.php";
include"functions.php";



list_categories();

switch($_GET['cat']) {

case"$row[id]";
if(!isset($_POST['$row[id]'])) {
if($_GET['id']) {
$id = (int)$_GET['id']; 


if(!isset($_GET['pagenum'])){
    $page = 1;
} else {
    $page = $_GET['pagenum'];
}


$max_results = 6;



$from = (($page * $max_results) - $max_results);



$sql = mysql_query("SELECT * FROM tutorials WHERE valid = '1' LIMIT $from, $max_results");
while($row = mysql_fetch_array($sql))
 {

echo "<table width='100%'>
<tr>
<td width='1%'>
$row[id]
</td>
<td width='70%'>
<b><a href='viewtut.php?action=view&id=$row[id]' class='style3'>$row[tutname]</a></b> - $row[email]<br><b>$row[shortdes]</b></br>
</td><font color='#FFFFFF'>.</font><td width='18%'>Views: <b>$row[views]</b></td></td> <td width='1%'>
<a href='viewtut.php?action=view&id=$row[id]' class='style3'><img src='$row[image]' alt='Click Here!' width='103' height='80'></a>
</td>
</tr>
</table>";

}


$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM tutorials"),0);


$total_pages = ceil($total_results / $max_results);


echo "<center><p><br />";

if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\" class='style3'><<Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i ";
        } else {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\" class='style3'>$i</a> ";
    }
}


if($page < $total_pages){
    $next = ($page + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\" class='style3'>next>></a>";
}
echo "</p></center>"; 
}



}

}


?>
:roll:
 
първия е за новини може би уроци ... да ги изкарвакато последни втория е за страници 1,2,3, и т.н. или греша ?
 
Код:
<?php 

include"connect.php"; 
include"functions.php"; 

list_categories(); 

switch($_GET['cat']) { 

case"$row[id]"; 
if(!isset($_POST['$row[id]'])) { 
if($_GET['id']) { 
$id = (int)$_GET['id']; 
$query3 = mysql_query("SELECT * FROM tutorials WHERE valid = '1' AND cat_id = '$id' ORDER BY id DESC"); 
while($row = mysql_fetch_array($query3)) { 
echo" 
<table width='100%'> 
<tr> 
<td width='52'> 
<img src='$row[image]' alt=''> 
</td> 
<td> 

<b><a href='viewtut.php?action=view&id=$row[id]'>$row[tutname]</a></b> 
$row[shortdes]. 
Author: <b>$row[authname]</b> | Views: <b>$row[views]</b> | Date: <b>$row[date]</b> | 
</td> 
</tr> 
if(!isset($_GET['pagenum'])){ 
    $page = 1; 
} else { 
    $page = $_GET['pagenum']; 
} 


$max_results = 6; 
$from = (($page * $max_results) - $max_results); 

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM tutorials"),0); 

$total_pages = ceil($total_results / $max_results); 

echo "<center><p><br />"; 

if($page > 1){ 
    $prev = ($page - 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\" class='style3'><<Previous</a> "; 
} 

for($i = 1; $i <= $total_pages; $i++){ 
    if(($page) == $i){ 
        echo "$i "; 
        } else { 
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\" class='style3'>$i</a> "; 
    } 
} 


if($page < $total_pages){ 
    $next = ($page + 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\" class='style3'>next>></a>"; 
} 
echo "</p></center>"; 

</table>"; 

} 
} 
} 

} 

?>


незнам сигуно има грешка но пробвай :)
 
Ами...после отиди на категориите там SALE BUY RENT.....
апак иначе това което ми предлагаш бях го пробвал ама нищо...празна страница се получава :)
 
Код:
<?php

include"connect.php";
include"functions.php";


list_categories();

switch($_GET['cat']) {

$page=$_GET['page'];

if(!$_GET['page'])
{
$page="1";
}

$pp = "3";

$limit = ($pp*$page)-$pp;

$redove = mysql_query("SELECT * FROM tutorials WHERE valid = '1' AND cat_id = '$id'");
$max=mysql_numrows($redove);
$total=ceil($max/$pp);

case"$row[id]";
if(!isset($_POST['$row[id]'])) {
if($_GET['id']) {
$id = (int)$_GET['id'];
$query3 = mysql_query("SELECT * FROM tutorials WHERE valid = '1' AND cat_id = '$id' ORDER BY id DESC LIMIT $limit,$pp");
while($row = mysql_fetch_array($query3)) {
echo"
<table width='100%'>
<tr>
<td width='52'>
<img src='$row[image]' alt=''>
</td>
<td>

<b><a href='viewtut.php?action=view&id=$row[id]'>$row[tutname]</a></b>
$row[shortdes].
Author: <b>$row[authname]</b> | Views: <b>$row[views]</b> | Date: <b>$row[date]</b> |
</td>
</tr>
</table>";

}
}
}

$page=$_GET['page'];
//predi6na
if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><font face=\"Trebuchet MS\">««</font></a> ";
} 
//4islata
if(!$page)
{
$page="1";
} 
for($i=1 ; $i<=$total ; $i++)
{
if(($page)==$i)
{
echo "<b>$i</b> ";
}
else
{
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=".$i."\">".$i."</a> ";
}
}

//sledwa6ta
if($page < $total){
    $next = ($page + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\"><font face=\"Trebuchet MS\">»»</font></a>";
}

}

?>

Не е точно това страницирана което ти искаше ама :?
 
:)
ми...наистина това не е страницата която искам, защото нещо смао бяла страница ми дава :)
Ако не може да го направим в 1...бихте ли ми помогнали как го ги разделя в два ?
Мисля категориите да са етделно апак останалото листване да е на страници ама ... пфф цхе сложно стана..
 
здравейте аз имам този код за изкарване на новини от форума и изкам да го направя пак на странички 1.2.3.4... на страничка по 10 новини примерно ...


Код:
<?php

#############
## Edit Below
#############

// Where to take the topics from
// Always a number
$forum = '3';

// How many topics to show
$limit = '1';

// How to show the topics
// full or blank ('')
$show = 'full';

// How to display the date and time if used
// short or long
$date_time = 'short';

// How top display the topic link if usede
// topic or phpbb
$topic_link = 'topic';

// Comments link - how to send them to comments
// topic or reply
$comment = 'topic';

// Path to your forums directory
// Usually ./forum/ or ./phpBB/ or ./forums/
$phpbb_root_path = 'forum/';

#############################################
## No Editing unless you know what your doing
#############################################
if ( !defined('IN_PHPBB') )
{
define('IN_PHPBB', true);
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'config.'.$phpEx);
}

if ($show == '' || $show == 'full')
{
// Select the topic information from the correct forum and set it to $grab_topics
$grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' ORDER BY `topic_id` DESC LIMIT {$limit}");
}

else if ($show == 'topic')
{
$grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$_GET['t']}' ORDER BY `topic_id` DESC");
}

// Grab the information using an array and set it to $echo_topic
while ($echo_topic = $db->sql_fetchrow($grab_topics))
{
// Select the post information from the correct forum and set it to $grab_posts
$grab_posts = $db->sql_query("SELECT * FROM `{$table_prefix}posts` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$echo_topic['topic_id']}' ORDER BY `post_id` LIMIT 1");

// Grab the information using an array and set it to $echo_post
while ($echo_post = $db->sql_fetchrow($grab_posts))
{
// Now get the post_text using the post_id were looking at and sort it info $grab_posts_text
$grab_posts_text = $db->sql_query("SELECT * FROM `{$table_prefix}posts_text` WHERE `post_id` = '{$echo_post['post_id']}'");

// Grab the information using an array and set it to $echo_text
while($echo_text = $db->sql_fetchrow($grab_posts_text))
{
// Find the user the posted
$find_user = $db->sql_query("SELECT * FROM `{$table_prefix}users` WHERE `user_id` = '{$echo_post['poster_id']}'");

// Sort this users info into array for the post
while ($echo_user = $db->sql_fetchrow($find_user))
{

// Get rid of all those annoying characters from bbcode
$echo_text = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $echo_text);

// BBCode
$echo_text = str_replace("","<strong>",$echo_text);
$echo_text = str_replace("","</strong>",$echo_text);

$echo_text = str_replace("[i]","<em>",$echo_text);
$echo_text = str_replace("[/i]","</em>",$echo_text);

$echo_text = str_replace("[u]","<u>",$echo_text);
$echo_text = str_replace("[/u]","</u>",$echo_text);

$echo_text = str_replace("[b]","<b>",$echo_text);
$echo_text = str_replace("[/b]","</b>",$echo_text);

$echo_text = preg_replace('/\[quote="(.*)\"](.*)\[\/quote\]/Usi','<div style=\"Verdana: 7px\">$2</div>',$echo_text);

$echo_text = str_replace("[quote]","<strong>Quote</strong><em>",$echo_text);
$echo_text = str_replace("[/quote]","</em>",$echo_text);

$echo_text = str_replace("
","<strong></strong>",$echo_text);
$echo_text = str_replace("
","",$echo_text);

 $echo_text = preg_replace('/\[list\](.*)\[\/list\]/si',"<div style=\"Verdana: 7px\">$1</div>",$echo_text);
$echo_text = preg_replace('/\[list=(.*)\](.*)\[\/list\]/si',"<div style=\"Verdana: 7px\">$1</div>",$echo_text);

$echo_text = str_replace("[img]","<img src=\"",$echo_text);
$echo_text = str_replace("[/img]","\"href=\"asd\" alt=\"All mix here :: NEWS\" border=\"1\"/>",$echo_text);

$echo_text = preg_replace('/\[url\](.*)\[\/url\]/Usi','<a href="$1">$1</a>',$echo_text);
$echo_text = preg_replace('/\[url=(.*)\](.*)\[\/url\]/Usi','<a href="$1">$2</a>',$echo_text);
$echo_text = preg_replace("/\[color\=(.+?)\](.+?)\[\/color\]/s", '<span style="color:$1">$2</span>',$echo_text);
$echo_text = preg_replace('/\[size\=(.+?)\](.+?)\[\/size\]/s', '<div style="font-size:\\1">\\2</div>',$echo_text);
$echo_text = str_replace("\n", "\n<br />\n", $echo_text); 

// Way to display date and time
// long
if($date_time == "long")
{
$echo_topic['topic_time'] = strftime("%A %e %B %H:%M",$echo_topic['topic_time']);
}

// short
if ($date_time == "short")
{
$echo_topic['topic_time'] = strftime("%a %e %b %H:%M",$echo_topic['topic_time']);
}

// Way to display comment link
// Go right to the topic
if ($comment == 'topic')
{
$comment_link = "{$phpbb_root_path}viewtopic.php?t={$echo_topic['topic_id']}";
}

// Go right to the reply box
if ($comment == 'reply')
{
$comment_link = "{$phpbb_root_path}posting.php?mode=reply&t={$echo_topic['topic_id']}";
}

// Topic link types
// This link goes to the topic display
if ($topic_link == 'topic')
{
$topic_link = "?show1=topic&t={$echo_topic['topic_id']}";
}

// This link goes to the actual phpbb topic
if ($topic_link == 'phpbb')
{
$topic_link = "{$phpbb_root_path}viewtopic.php?t={$echo_topic['topic_id']}";
}

##################################
## Edit for look and feel of topic
##################################
// Display just the title

if ($show != 'full' && !isset($_GET['show1']))
{
echo "<a href='{$topic_link}'><font color=\"#CCCCCCF\" >{$echo_text['post_subject']}</a><br /></font>";
}

// Display many topics - for news, shoutbox etc
else if ($show == 'full')
{
echo "

</font><b><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">[ Заглавие:</b></font><a href=\"{$comment_link}\"  class='menu_link'><font face=\"Verdana\" color=\"#FFAAAA\" size=\"1\"> {$echo_text['post_subject']}</strong><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1.5\"> </font><b><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">]</b></font></a>
<br />
<br /><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">
{$echo_text['post_text']}
</front>
<br />
<br />
</font><b><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">[ написано от:</b></font><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\"> <strong> {$echo_user['username']}</strong><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1.5\"> </font><b><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">]</b></font>
<b><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">[ пуснато на: </b></font><strong>{$echo_topic['topic_time']}</strong> </font><b><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">]</b></font>
<a href=\"{$comment_link}\"  class='menu_link'> Коментари {$echo_topic['topic_replies']}</a><hr size=\"1\">

";
}

// Display the topic for when used with the one above, click link and go here
if ($_GET['show1'] == 'topic')
{
echo "
<strong><font color=\"#FFFFFF\" >{$echo_text['post_subject']}</font></strong>- <strong>{$echo_topic['topic_time']}</strong>
<br />
<br /><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#CCCCCC\" size=\"1\">
{$echo_text['post_text']}
</font>
<br />
<br />
написано от: <strong>{$echo_user['username']} </strong>
<a href=\"{$comment_link}\" target=\"_blank\">Comments {$echo_topic['topic_replies']}</a>
<hr size=\"1\">
";
}
}
}
}
}
?>
 
да ама до колкото чета не си оспя да оправиш проблема с страниците да ти показва страниците оправилиго ?
 
мале ако ти кажа ко стана додаха ми на проверка от НСБ хахаха и ми гепиха целия PC са сам с една пишешта машина едвам накарах нета да тръгне ....
 
Лошо са направили тия.

Сега по темата. Надявам се оценяваш, че ти давам моя код редактиран в продължение на 2-3 седмици до абсолютното му Усъвършенстване. За да ти е гадно обаче махнах всякакви визуални нещица :twisted:

Демо | Свали
 
така :) първо за незнам кой път ти благодаря :) за кога... както казах и погоре интересъвам се само от сменянето на страниците :) благодаря пак са 6те го слоа
 

Back
Горе