Jump to content

Recommended Posts

Hi Im new here..

 

Im a PHP noo-b i have this simple code with sorting and pagination with dummy data (firstname,lastname,age)

 

I would like to add some simple search to it..im not sure if im doing this right

 

currentlty the search is not working properly

 

for testing purpose, right now i limit 3 records per page

a. when i search record and search result is display..Pagination link is still display even i have only 1record search result

b.  if i have 4 records found, when i click the 2nd page, the search result is gone and table is back to default view

c. in table default view, clicking 2nd page and try to search record, records are not found because its looking under the 2nd page and not all of the table

 

sorry for my  English

 

 

 

<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Paging</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">

<form method="post" action="" >

<br />Search <input type="text" name="search" />
<input type="submit" value="Search"/></form><br />
<?php
require "connect.php";           // All database details will be included here

// define values the rest of the code uses
$table = 'person'; // database table name
$sorts = array('firstname'=>'First Name','lastname'=>'Last Name','age'=>'Age'); // list of permissible sort choices
$sort_bys = array('asc','desc'); // list of permissible order by choices
$limit = 3; // No of records to be shown per page.

// condition inputs/set default values
$start = (isset($_GET['start'])) ? (int)$_GET['start'] : 0; // default to starting row 0 if not specified
$sort = (isset($_GET['sort'])) ? $_GET['sort'] : 'firstname'; // default to firstname if not specified
$sort_by = (isset($_GET['sort_by'])) ? $_GET['sort_by'] : 'asc'; // default to asc if not specified





// validate sort input (used as a keyword in query statement)
if(!array_key_exists($sort,$sorts)){
    $sort = 'firstname'; // default to firstname
}

// validate sort_by input (used as a keyword in query statement)
if(!in_array($sort_by,$sort_bys)){
    $sort_by = 'asc'; // default to asc
}

$eu = $start;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;

// get opposite sort_by value for producing toggle links in the table heading (only)
if($sort_by == 'asc'){
    $sort_order = 'desc';
} else {
    $sort_order = 'asc';
}















/////////////// WE have to find out the number of records in our table. We will use this to break the pages///////
$query="SELECT COUNT(*) FROM $table";
$result=mysql_query($query);
//echo $query, mysql_error();
list($nume) = mysql_fetch_row($result);
/////// The variable nume above will store the total number of records in the table////

/////////// Now let us print the table headers ////////////////
$bgcolor="#f1f1f1";
echo "<table border='1'>"  ;
echo "<tr> <th>ID</th>";
// dynamically produce choices/columns
foreach($sorts as $key=>$value){
    echo "<th><a href='?sort=$key&sort_by=$sort_order'>$value</a></th>";
}
echo "</tr>";

////////////// Now let us start executing the query with variables $eu and $limit  set at the top of the page///////////
//$query="SELECT * FROM $table ORDER BY $sort $sort_by limit $eu, $limit";

$query="SELECT * FROM $table where firstname like '%" .  $_POST['search']  .  "%' or lastname like '%" .  $_POST['search']  .  "%' or age like '%" .  $_POST['search']  .  "%'               ORDER BY $sort $sort_by limit $eu, $limit";

$result=mysql_query($query);
//echo $query, mysql_error();


$count = (isset($eu) && $eu > 0) ? $eu+1 : 1;

//////////////// Now we will display the returned records in side the rows of the table/////////
while($rows = mysql_fetch_array($result)){
    // toggle bgcolor
    if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
    else{$bgcolor='#f1f1f1';}

    echo "<tr >";
    echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>";
    echo $count++;
    echo "</font></td>";
    echo "<td>$rows[firstname]</td>";
    echo "<td>$rows[lastname]</td>";
    echo "<td>$rows[age]</td>";
    echo "</tr>";
}
echo "</table>";
////////////////////////////// End of displaying the table with records ////////////////////////


///////////////////////////////
if($nume > $limit ){ // Let us display bottom links if sufficient records are there for paging
    /////////////// Start the bottom links with Prev and next link with page numbers /////////////////
    echo "<table align = 'center' width='50%'><tr><td  align='left' width='30%'>";
    //// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
    if($back >=0){
        $_GET['start'] = $back; // only modify the 'start' value, all others left as is
        $q = http_build_query($_GET,'','&');
        print "<a href='?$q'><font face='Verdana' size='2'>PREV</font></a>";
    }
    //////////////// Let us display the page links at  center. We will not display the current page as a link ///////////
    echo "</td><td align=center width='30%'>";
    $i=0;
    $l=1;
    for($i=0;$i < $nume;$i=$i+$limit){
        if($i <> $eu){
            $_GET['start'] = $i; // only modify the 'start' value, all others left as is
            $q = http_build_query($_GET,'','&');
            echo " <a href='?$q'><font face='Verdana' size='2'>$l</font></a> ";
        } else {
            echo "<font face='Verdana' size='4' color=red>$l</font>";}        /// Current page is not displayed as link and given font color red
        $l=$l+1;
    }
    echo "</td><td  align='right' width='30%'>";
    ///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
    if($this1 < $nume){
        $_GET['start'] = $next; // only modify the 'start' value, all others left as is
        $q = http_build_query($_GET,'','&');
        print "<a href='?$q'><font face='Verdana' size='2'>NEXT</font></a>";
    }
    echo "</td></tr></table>";
}// end of if checking sufficient records are there to display bottom navigational link.
include "menu.php";
?>

Edited by mulaus
Link to comment
https://forums.phpfreaks.com/topic/276091-help-with-search-sorting-and-pagination/
Share on other sites

 heres what i come up with so far

 

1 problem - when my search result is > page limit

 

search result is display in a single page not following the page limit  and the pagination is display..

 

if my search result <  page limit

it is working ok..


<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Paging</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
 
<form method="post" action="" >
 
<br />Search <input type="text" name="search" />
<input type="submit" value="Search"/></form><br />
<?php
require "connect.php";           // All database details will be included here
 
// define values the rest of the code uses
$table = 'person'; // database table name
$sorts = array('firstname'=>'First Name','lastname'=>'Last Name','age'=>'Age'); // list of permissible sort choices
$sort_bys = array('asc','desc'); // list of permissible order by choices
$limit = 3; // No of records to be shown per page.
 
 
// condition inputs/set default values
$start = (isset($_GET['start'])) ? (int)$_GET['start'] : 0; // default to starting row 0 if not specified
$sort = (isset($_GET['sort'])) ? $_GET['sort'] : 'firstname'; // default to firstname if not specified
$sort_by = (isset($_GET['sort_by'])) ? $_GET['sort_by'] : 'asc'; // default to asc if not specified
 
 
// validate sort input (used as a keyword in query statement)
if(!array_key_exists($sort,$sorts)){
$sort = 'firstname'; // default to firstname
}
 
// validate sort_by input (used as a keyword in query statement)
if(!in_array($sort_by,$sort_bys)){
$sort_by = 'asc'; // default to asc
}
 
$eu = $start;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
 
// get opposite sort_by value for producing toggle links in the table heading (only)
if($sort_by == 'asc'){
$sort_order = 'desc';
} else {
$sort_order = 'asc';
}
 
 
 
/////////////// WE have to find out the number of records in our table. We will use this to break the pages///////
$query="SELECT COUNT(*) FROM $table";
$result=mysql_query($query);
//echo $query, mysql_error();
list($nume) = mysql_fetch_row($result);
/////// The variable nume above will store the total number of records in the table////
echo "Totals of records: $nume | Page limit: $limit<br />";
/////////// Now let us print the table headers ////////////////
echo "<table border='1'>"  ;
echo "<tr> <th>ID</th>";
// dynamically produce choices/columns
foreach($sorts as $key=>$value){
echo "<th><a href='?sort=$key&sort_by=$sort_order'>$value</a></th>";
}
echo "</tr>";
 
////////////// Now let us start executing the query with variables $eu and $limit  set at the top of the page///////////
//$query="SELECT * FROM $table ORDER BY $sort $sort_by limit $eu, $limit";
 
if (isset($_POST['search']))  {
$_POST['search'] = mysql_real_escape_string($_POST['search']);  
 
//run the query for searching
$result= mysql_query("SELECT * FROM $table where firstname like '%" .  $_POST['search']  .  "%' or lastname like '%" .  $_POST['search']  .  "%' or age like '%" .  $_POST['search']  .  "%' ORDER BY $sort $sort_by");
 
//$query="SELECT * FROM $table ORDER BY $sort $sort_by limit $eu, $limit";
//$result=mysql_query($query);
//echo $query, mysql_error();
$search_result=mysql_num_rows($result);
$nume=$search_result;
echo "Totals of record search: $nume | Page limit: $limit<br />";
if ($_POST['search'] =='')
{
echo "Please input Keyword";
 
$query="SELECT COUNT(*) FROM $table";
$result=mysql_query($query);
//echo $query, mysql_error();
list($nume) = mysql_fetch_row($result);
 
$query="SELECT * FROM $table ORDER BY $sort $sort_by limit $eu, $limit";
$result=mysql_query($query);
 
}
else
{
 
 
echo "$search_result";
echo " record of <b>" . $_POST['search'] . "</b> found";
 
}
 
//Show all if result 0
if ($search_result=='0')
{
$query="SELECT COUNT(*) FROM $table";
$result=mysql_query($query);
//echo $query, mysql_error();
list($nume) = mysql_fetch_row($result);
 
$query="SELECT * FROM $table ORDER BY $sort $sort_by limit $eu, $limit";
$show=mysql_query($query);
 
 
$count = (isset($eu) && $eu > 0) ? $eu+1 : 1;
 
//////////////// Now we will display the returned records in side the rows of the table/////////
while($rows = mysql_fetch_array($show)){
 
echo "<tr >";
echo "<td> <font face='Verdana' size='2'>";
echo $count++;
echo "</font></td>";
echo "<td>$rows[firstname]</td>";
echo "<td>$rows[lastname]</td>";
echo "<td>$rows[age]</td>";
echo "</tr>";
}
 
 
}
 
 } 
 
 else
{
 
$query="SELECT COUNT(*) FROM $table";
$result=mysql_query($query);
//echo $query, mysql_error();
list($nume) = mysql_fetch_row($result);
 
$query="SELECT * FROM $table ORDER BY $sort $sort_by limit $eu, $limit";
$result=mysql_query($query);
 
//$nume=$result;
 
}
 
 
 
 
$count = (isset($eu) && $eu > 0) ? $eu+1 : 1;
 
//////////////// Now we will display the returned records in side the rows of the table/////////
while($rows = mysql_fetch_array($result)){
 
echo "<tr >";
echo "<td> <font face='Verdana' size='2'>";
echo $count++;
echo "</font></td>";
echo "<td>$rows[firstname]</td>";
echo "<td>$rows[lastname]</td>";
echo "<td>$rows[age]</td>";
echo "</tr>";
}
 
echo "</table>";
////////////////////////////// End of displaying the table with records ////////////////////////
 
///////////////////////////////
if($nume > $limit ){ // Let us display bottom links if sufficient records are there for paging
/////////////// Start the bottom links with Prev and next link with page numbers /////////////////
echo "<table align = 'left' width='50%'><tr><td  align='left' width='30%'>";
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
if($back >=0){
$_GET['start'] = $back; // only modify the 'start' value, all others left as is
$q = http_build_query($_GET,'','&');
print "<a href='?$q'><font face='Verdana' size='2'>PREV</font></a>";
}
//////////////// Let us display the page links at  center. We will not display the current page as a link ///////////
echo "</td><td align=left width='30%'>";
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
$_GET['start'] = $i; // only modify the 'start' value, all others left as is
$q = http_build_query($_GET,'','&');
echo " <a href='?$q'><font face='Verdana' size='2'>$l</font></a> ";
} else {
echo "<font face='Verdana' size='4' color=red>$l</font>";}        /// Current page is not displayed as link and given font color red
$l=$l+1;
}
echo "</td><td  align='right' width='30%'>";
///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
if($this1 < $nume){
$_GET['start'] = $next; // only modify the 'start' value, all others left as is
$q = http_build_query($_GET,'','&');
print "<a href='?$q'><font face='Verdana' size='2'>NEXT</font></a>";
}
echo "</td></tr></table>";
}// end of if checking sufficient records are there to display bottom navigational link.
include "menu.php";
?>
 
  • 2 weeks later...


<html>
<head>
<title>Paging</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">

<form method="post" action="" >

<br />Search <input type="text" name="search" />
<input type="submit" value="Search"/></form><br />
<?php
require "connect.php"; // All database details will be included here

// define values the rest of the code uses
$table = 'person'; // database table name
$sorts = array('firstname'=>'First Name','lastname'=>'Last Name','age'=>'Age'); // list of permissible sort choices
$sort_bys = array('asc','desc'); // list of permissible order by choices
$limit = 5; // No of records to be shown per page.

// condition inputs/set default values
$start = (isset($_GET['start'])) ? (int)$_GET['start'] : 0; // default to starting row 0 if not specified
$sort = (isset($_GET['sort'])) ? $_GET['sort'] : 'firstname'; // default to firstname if not specified
$sort_by = (isset($_GET['sort_by'])) ? $_GET['sort_by'] : 'asc'; // default to asc if not specified


// validate sort input (used as a keyword in query statement)
if(!array_key_exists($sort,$sorts)){
    $sort = 'firstname'; // default to firstname
}

// validate sort_by input (used as a keyword in query statement)
if(!in_array($sort_by,$sort_bys)){
    $sort_by = 'asc'; // default to asc
}

$eu = $start;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;

// get opposite sort_by value for producing toggle links in the table heading (only)
if($sort_by == 'asc'){
    $sort_order = 'desc';
} else {
    $sort_order = 'asc';
}


if (isset($_POST['search'])) {
$_POST['search'] = mysql_real_escape_string($_POST['search']);
$search = $_POST['search'];
if($search != ''){
    // form a simple LIKE '%search term%' comparison
    $where_clause = "where firstname like '%" . $_POST['search'] . "%' or lastname like '%" . $_POST['search'] . "%' or age like '%" . $_POST['search'] . "%'";
    }
}

/////////////// WE have to find out the number of records in our table. We will use this to break the pages///////
$query="SELECT COUNT(*) FROM $table $where_clause";
$result=mysql_query($query);
//echo $query, mysql_error();
list($nume) = mysql_fetch_row($result);
/////// The variable nume above will store the total number of records in the table////

/////////// Now let us print the table headers ////////////////
$bgcolor="#f1f1f1";
echo "<table border='1'>" ;
echo "<tr> <th>ID</th>";
// dynamically produce choices/columns
foreach($sorts as $key=>$value){
    echo "<th><a href='?sort=$key&sort_by=$sort_order'>$value</a></th>";
}
echo "</tr>";

////////////// Now let us start executing the query with variables $eu and $limit set at the top of the page///////////
//$query="SELECT * FROM $table ORDER BY $sort $sort_by limit $eu, $limit";

$query="SELECT * FROM $table $where_clause ORDER BY $sort $sort_by limit $eu, $limit";

$result=mysql_query($query);
//echo $query, mysql_error();

$count = (isset($eu) && $eu > 0) ? $eu+1 : 1;
if($search =!''){
echo "Totals of records Found: $nume";
}

//////////////// Now we will display the returned records in side the rows of the table/////////
while($rows = mysql_fetch_array($result)){
    // toggle bgcolor

    echo "<tr >";
    echo "<td> <font face='Verdana' size='2'>";
    echo $count++;
    echo "</font></td>";
    echo "<td>$rows[firstname]</td>";
    echo "<td>$rows[lastname]</td>";
    echo "<td>$rows[age]</td>";
    echo "</tr>";
}
echo "</table>";
////////////////////////////// End of displaying the table with records ////////////////////////


///////////////////////////////
if($nume > $limit ){ // Let us display bottom links if sufficient records are there for paging
    /////////////// Start the bottom links with Prev and next link with page numbers /////////////////
    echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>";
    //// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
    if($back >=0){
        $_GET['start'] = $back; // only modify the 'start' value, all others left as is
        $q = http_build_query($_GET,'','&');
        print "<a href='?$q'><font face='Verdana' size='2'>PREV</font></a>";
    }
    //////////////// Let us display the page links at center. We will not display the current page as a link ///////////
    echo "</td><td align=center width='30%'>";
    $i=0;
    $l=1;
    for($i=0;$i < $nume;$i=$i+$limit){
        if($i <> $eu){
            $_GET['start'] = $i; // only modify the 'start' value, all others left as is
            $q = http_build_query($_GET,'','&');
            echo " <a href='?$q'><font face='Verdana' size='2'>$l</font></a> ";
        } else {
            echo "<font face='Verdana' size='4' color=red>$l</font>";} /// Current page is not displayed as link and given font color red
        $l=$l+1;
    }
    echo "</td><td align='right' width='30%'>";
    ///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
    if($this1 < $nume){
        $_GET['start'] = $next; // only modify the 'start' value, all others left as is
        $q = http_build_query($_GET,'','&');
        print "<a href='?$q'><font face='Verdana' size='2'>NEXT</font></a>";
    }
    echo "</td></tr></table>";
}// end of if checking sufficient records are there to display bottom navigational link.
include "menu.php";
?>

 

any php master outhere can help a newbie correct his code

 

when searching, clicking 2nd Page or Next the search criteria is not followed..

 

im still trying to figure this out

Edited by mulaus
  • 2 years later...

 

 

Try this you will get result and make sure change it according to your database : if it not works please let me know. 

 

<html>

<head>

 <title>pagination</title>

</head>

<body>

           

   <form method="post" action="" >          

              <input type="text" value="<?php $input = isset($_POST['search'])?$_POST['search']:'';?>" name="search"  placeholder="search here"/>

         <input type="submit" value="search"/></form><br />         

          <?php

                $username = "root";

$password = "";

$hostname = "localhost"; 

$dbconnect = mysql_connect($hostname, $username, $password) 

    or die("Unable to connect to MySQL");

$selected = mysql_select_db("lovetran_lth",$dbconnect)  

    or die("Could not select examples");  

$sorts = array('User_ID'=>'User_ID','First_Name'=>'First_Name','Last_Name'=>'Last_Name');

$sort_bys = array('asc','desc');

$limit = 10; 

   $table = 'users';      

$start = (isset($_REQUEST['start'])) ? (int)$_REQUEST['start'] : 0;                 

$sort = (isset($_REQUEST['sort'])) ?  $_REQUEST['sort'] : 'First_Name'; 

$sort_by = (isset($_REQUEST['sort_by'])) ? $_REQUEST['sort_by'] : 'asc';

$eu = $start;

$this1 = $eu + $limit;

$back = $eu - $limit;

$next = $eu + $limit;

if($sort_by == 'asc')

{

$sort_order = 'desc';

                else 

                {

$sort_order = 'asc';

}

        echo "<table align='center' border='2'>"  ;

        echo "<tr>"; 

                echo "<tr> <th>ID</th>";

                foreach($sorts as $key=>$value)

                    {

                        if (isset($_REQUEST['search']))

                        {

                            $var=$_REQUEST['search'];                                                        

                            echo "<th><a href='?search=$var&sort=$key&sort_by=$sort_order&start=$eu '>$value $eu</a></th>";

                         }

                        else

                        {

                          echo "<th><a href='?sort=$key&sort_by=$sort_order&start=$eu'>$value $eu</a></th>";           

                        }                                                                            

            }

               echo "</tr>";                  

                //this is working// 

                 if (isset($_REQUEST['search']))                 

                   {

                        $result= mysql_query

                            ("SELECT * FROM $table where 

                                First_Name like '%" .  $_REQUEST['search']  .  "%' or 

                                    Last_Name like '%" .  $_REQUEST['search']  .  "%' or 

                                        User_ID like '%" .  $_REQUEST['search']  .  "%' 

                                             ORDER BY $sort $sort_by ");                     

                        $search_result=mysql_num_rows($result);

    $nume=$search_result;                       

       echo "Totals of record search: $nume | Page limit: $limit <br/>";    

                        if ($_REQUEST['search'] =='')

         {

            $query="SELECT COUNT(*) FROM $table ";

            $result=mysql_query($query);

            list($nume) = mysql_fetch_row($result);

            $query="SELECT * FROM $table ORDER BY $sort $sort_by limit $eu, $limit";                            

            $result=mysql_query($query);

                            $count = (isset($eu) && $eu > 0) ? $eu+1 : 1; 

                            while($rows = mysql_fetch_array($result))

                 {

                     echo "<tr >";

                                echo "<td>";

                                echo $count++;

                                echo "</td>";echo "<td >$rows[user_ID]</td>"; echo "<td>$rows[First_Name]</td>";echo "<td>$rows[Last_Name]</td>";

                echo "</tr>";

                 }                   

        }                                          

                        //i have to give input for this then //

                          else

                            {  

            echo "$search_result";

             echo " record of <b>" . $_REQUEST['search'] . "</b> found";  

                                echo "if input page".$eu;

$query="SELECT * FROM $table where 

                                First_Name like '%" .  $_REQUEST['search']  .  "%' or 

                                    Last_Name like '%" .  $_REQUEST['search']  .  "%' or 

                                        User_ID like '%" .  $_REQUEST['search']  .  "%' 

                                             ORDER BY $sort $sort_by limit $eu,$limit";

                                echo $query;                                            

                                $result= mysql_query($query); 

                                $count = (isset($eu) && $eu > 0) ? $eu+1 : 1;  

                                  while($rows = mysql_fetch_array($result))

                    {                    

                                    echo "<tr >";

                                    echo "<td>";

                                    echo $count++;

                                    echo "</td>";

                      echo "<td >$rows[user_ID]</td>";

                    echo "<td>$rows[First_Name]</td>";

                                    echo "<td>$rows[Last_Name]</td>";

                    echo "</tr>";

                    }

                                                     

                }

                                 if ($search_result=='0')

                                {     

                                 echo "<b> (NO Results) </b>";

     }

                          }                             

                          else

                          {

                                $query="SELECT COUNT(*) FROM $table";

                                $result=mysql_query($query);                                

                                list($nume) = mysql_fetch_row($result);

                                $query="SELECT * FROM $table ORDER BY $sort $sort_by limit $eu, $limit";

                                echo "sorting" .$query;

                                $result=mysql_query($query);

                                   $count = (isset($eu) && $eu > 0) ? $eu+1 : 1;       

                                while($rows = mysql_fetch_array($result)){                                 

                                echo "<tr >";

                                echo "<td>";

                                echo $count++;

                                echo "</td>";

                                echo "<td>$rows[user_ID]</td>";

                                echo "<td>$rows[First_Name]</td>";

                                echo "<td>$rows[Last_Name]</td>";                                

                                echo "</tr>";

                                }         

                          }    echo "</table>";

                          if($nume > $limit )

                  {

            echo "<table align='center' border='1'><tr><td>";            

            if($back >=0)

            {

               if(isset($_POST['search']))

                                {

            $_REQUEST['start'] = $back; $_REQUEST['search'] = $_REQUEST['search'];

                                }

                                {

                                    $_REQUEST['start'] = $back;   

                                }                                                              

                                $q = http_build_query($_REQUEST,'','&');                                

            print "<a href='?$q'>PREV</a>";

            }          

            echo "</td><td>";

            $i=0;

            $l=1;          

                        for($i=0;$i < $nume;$i=$i+$limit)

                {

                if($i <> $eu)

                {

                   if(isset($_POST['search']))

                                    {

                    $_REQUEST['start'] = $i;$_REQUEST['search'] = $_REQUEST['search'];

                                    }

                                        else

                                    {

                                         $_REQUEST['start'] = $i;

                                    }                                

                $q = http_build_query($_REQUEST,'','&');

                    echo " <a href='?$q'>$l</a> ";

                }

                                 else 

                {

                echo "<font color=red>$l</font>";

               }       

            $l=$l+1;

                      }

                    echo "</td><td>";                    

                    if($this1 < $nume)

                    {

                      if(isset($_POST['search']))

                                   {

                        $_REQUEST['start'] = $next; $_REQUEST['search'] = $_REQUEST['search']; 

                    }

                                    else

                                    {

                                        $_REQUEST['start'] = $next;

                                     }

                                    $q = http_build_query($_REQUEST,'','&');

                    print "<a href='?$q'>NEXT</a>";

                                }

                    echo "</td></tr></table>";

            }                          

              mysql_close($dbconnect); 

           ?>

Actually .... from last two dayz i worked on this for my project . Corrected that navigation problem and included in my project.  that'y i posted here.. check it if you find any problem let me know i ll try to correct that.even i don't know the posted date.i just upload it here.

The point is: This is a help forum, not a place to upload your code. If you want to help somebody, make sure the thread is still active (this one clearly isn't), and then give specific advice. The user should learn how to solve the problem, not just copy-and-paste somebody else's solution.

 

Regarding the problems of your own code: First of all, you have no security whatsoever. You stuff the user input right into your queries and the HTML markup, leaving your application wide open to SQL injection attacks and cross-site scripting. The mysql_* functions and HTML elements like <font> are also hopelessly outdated and have been replaced more than a decade ago. Nowadays, we access our database with something like PDO and style our pages with CSS.

 

So again: Please don't just post your code, especially if you're a beginner yourself.

  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.