Jump to content

Paging script


raghukalia2005

Recommended Posts

Dear friends ...

I am new in php.. I am making website based on JOKES..I have 15 Jokes categories...I have 15 directoris for each category of joke...and each direcotry has some txt files,,,through while loop i read directory and fetch files from directory and disply page..I want paging script,,i want only 5 jokes txt files on one page...Please tell me how can i solve my problem..I am sending you my whole code please read it and put paging script in my code...I will be very thankful to you,,chk my website www.sms2friends.co.cc

 

 

<table width="100%" border="1">

  <tr>

    <td width="20%" valign="top">

<table>

<tr>

<td valign="top"><?php

$dbname = 'space_3211329_message';

$link = mysql_connect("localhost,"root","vertrigo") or die("Couldn't make connection.");

$db = mysql_select_db($dbname, $link) or die("Couldn't select database");

$result = mysql_query("SELECT * FROM categories");

while($row=mysql_fetch_array($result))

{

echo "<a href='index.php?app=1'>".$row['anniversary']."</a>";

echo "<br />";

echo "<a href='index.php?app=2'>".$row['birthday']."</a>";

echo "<br />";

echo "<a href='index.php?app=3'>".$row['christmas']."</a>";

echo "<br />";

echo "<a href='/index.php?app=4'>".$row['exam']."</a>";

echo "<br />";

echo "<a href='index.php?app=5'>".$row['friendship']."</a>";

echo "<br />";

echo "<a href='index.php?app=6'>".$row['good_morning']."</a>";

echo "<br />";

echo "<a href='index.php?app=7'>".$row['good_night']."</a>";

echo "<br />";

echo "<a href='index.php?app=8'>".$row['gudgudi']."</a>";

echo "<br />";

echo "<a href='index.php?app=9'>".$row['insult']."</a>";

echo "<br />";

echo "<a href='index.php?app=10'>".$row['life']."</a>";

echo "<br />";

echo "<a href='index.php?app=11'>".$row['love']."</a>";

echo "<br />";

echo "<a href='index.php?app=12'>".$row['miss']."</a>";

echo "<br />";

echo "<a href='index.php?app=13'>".$row['punjabi']."</a>";

echo "<br />";

echo "<a href='index.php?app=14'>".$row['santa']."</a>";

echo "<br />";

echo "<a href='index.php?app=15'>".$row['sorry']."</a>";

echo "<br />";

}

?>

</td>

</tr>

</table>

</td>

    <td width="80%">

<?php

switch($_GET['app'])

{

case 1:

$dir = 'anniversary';

break;

 

case 2:

$dir = 'birthday';

  break;

 

case 3:

$dir = 'christmas';

  break;

 

case 4:

$dir = 'exam';

  break;

 

case 5:

$dir = 'friendship';

  break;

 

case 6:

$dir = 'good morning';

  break;

 

  case 7:

$dir = 'good night';

  break;

 

  case 8:

$dir = 'gudgudi';

  break;

 

  case 9:

$dir = 'insult';

  break;

 

  case 10:

$dir = 'life';

  break;

 

  case 11:

$dir = 'love';

  break;

 

  case 12:

$dir = 'miss';

  break;

 

  case 13:

$dir = 'punjabi';

  break;

 

  case 14:

$dir = 'santa banta';

  break;

 

  case 15:

$dir = 'sorry';

  break;

 

default:

$dir = 'blank';

}

 

if($dir!='blank'){

$dh=opendir($dir);

while (($file = readdir($dh)) !== false)

        {

        if ($file != "." && $file != "..") {

              $fulfile=$dir ."/". $file;

              $subtotal=file_get_contents($fulfile);

  count($subtotal);

    echo "<hr>";

          }

                     

}

  closedir($dh);

}

?>

</td>

  </tr>

</table>

 

 

Thanks with regards.

www.rakhe.com

 

Link to comment
https://forums.phpfreaks.com/topic/167508-paging-script/
Share on other sites

Try using php as the dynamic language it is and find a better structure for your code. That huge switch is not a good idea for example. Learn basic programming procedure, that will be of great benefit to you in the future.

 

Heard of Google?  :P Simply search for php paging and you will find plenty of examples and tutorials. LIMIT is the sql command to look into as suggested.

Link to comment
https://forums.phpfreaks.com/topic/167508-paging-script/#findComment-883367
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.