how do you paginate and sort in this scheme?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
emelianenko
Forum Commoner
Posts: 35
Joined: Thu Sep 09, 2010 11:49 am

how do you paginate and sort in this scheme?

Post by emelianenko »

Hello

The scenario is this:

I have a grid of pictures

When I click on a pic, an onclick event sends a parameter to an ajax function. This function forwards that parameter to a php script.

This php script contains both the sql and the echo for creating the table.

The result is that without actually leaving the page of the grid of pictures, a table is displayed below the grid of pictures.

That is cool, yes, but now, how do you sort and paginate that ?

I have the sort and paginate php code, but because of that scheme, it makes it more complicated. If I put al the sort and paginate code in the processing php file which had the sql and table creation code, that script calls itself, therefore, showing nothing upon refreshing, other than an empty table, as al the html was on the original page that sent it the parameter.

I dont even know whether this can be made like this.

thanks,

best regards
Bind
Forum Contributor
Posts: 102
Joined: Wed Feb 03, 2010 1:22 am

Re: how do you paginate and sort in this scheme?

Post by Bind »

the short answer is query string with var=value pairs to decide what code to execute depending on the request query string data.

other than that its all just guessing and theory unelss you can post all the source code so we can further help you troubleshoot.
emelianenko
Forum Commoner
Posts: 35
Joined: Thu Sep 09, 2010 11:49 am

Re: how do you paginate and sort in this scheme?

Post by emelianenko »

Hello,


well, here is part of the code, but this does well create the table and put the data inside, that is not a problem. What matters is to understand the scenario I have described above.

Code: Select all


<?php
$q=$_GET["q"]; // THIS IS THE PARAMETER THAT THE OTHER PAGE SENT IT

require_once('mysqli_connect.php'); // CONNECTING

$sql1="SELECT name, description,
			 town, region, country
	 FROM address
         //.....
	// WHERE ...
	 // ...
	 AND name= '".$q."'";

$result1 = @mysql_query($sql1);

echo '<table border='1' name = "mytable"> 
<tr>
<th>Name</th>
<th>Description</th>
<th>Town</th>
<th>Region</th>
<th>Country</th>
</tr>';

while($row = mysql_fetch_array($result1, MYSQL_ASSOC))
  {
  echo "<tr>";
  echo "<td>" . $row['name'] . "</td>";
//...MORE ROWS AND CELLS
// ETC
  
mysql_close($dbc);
?> 


Bind wrote:the short answer is query string with var=value pairs to decide what code to execute depending on the request query string data.

other than that its all just guessing and theory unelss you can post all the source code so we can further help you troubleshoot.
Post Reply