Page 1 of 1

how do you paginate and sort in this scheme?

Posted: Fri Sep 10, 2010 4:20 pm
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

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

Posted: Sat Sep 11, 2010 7:42 pm
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.

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

Posted: Sun Sep 12, 2010 2:10 am
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.