PDA

View Full Version : Order a table without header



helenp
11-26-2013, 06:11 PM
Hi,
I have a searchbox, wich uses a table to display the result, however the result is not displayed as a normal table,
ie, with headers to order by.
I want to be able to reorder the result that I got from the database without doing the query to the database again.
I know how to order a normal table with headers,
but on this I dont have any header to order by.
This is the html output with php:

echo "<table class='tabla>;
do {
echo "<tr>";
echo "<td><p><a href=".$row["link_ingles"].">".$row["id_propiedad"]."</a><br>".$row["text_eng"]."<br>Pool: ".$row["pool"]."<br>Bedrooms: ".$row["bedrooms"]."<br>Bathrooms: ".$row["bathrooms"]."<br>Air-conditioning: ".$row["air"]."<br>Sleeps max.: ".$row["duermen"]." persons.<br>Internet: ".$row["internet"]."<br>Prices from: ".$row["price_eng"]."<br><br><a href=".$row["link_ingles"].">View details</a></p><p></p></td>";
echo "<td><a href=".$row["link_ingles"]."><img class=borderfotos src=".$row["image"]." border=\"0\"></a></td>";
echo "</tr>";
echo "<td class='result'>&nbsp;</td>";
echo "<td class='result'>&nbsp;</td>";
} while ($row = mysql_fetch_array($result));

echo "</table> \n";

I would like to be able to reorder by bedrooms, prices from etc.
Thanks in advance.

traq
11-27-2013, 12:25 AM
I'm not sure what you mean by "with[out] headers to order by" …?


I want to be able to reorder the result that I got from the database without doing the query to the database again. [...]
I would like to be able to reorder by bedrooms, prices from etc.

To clarify:

Do you want the user to be able to sort the data on the webpage, after you output it? or,

Do you want to sort/display the data in a different order than it comes from the DB? or,

Do you want to be able to display the same results (possibly in a different order), on subsequent requests, without having to query the DB again?

helenp
11-27-2013, 10:07 AM
I'm not sure what you mean by "with[out] headers to order by" ?



To clarify:

Do you want the user to be able to sort the data on the webpage, after you output it? or,

Do you want to sort/display the data in a different order than it comes from the DB? or,

Do you want to be able to display the same results (possibly in a different order), on subsequent requests, without having to query the DB again?

Thanks,
Without headers I mean, a traditional table has columns and rows and are displayed like this:
Header1, Header2, Header3
result, result, result
Where Header is the name of the column, (title)
My query is not displayed with the name of the columns,
In my intrandet the results are displayed with headers and I can order the tables in my intranet.

But on my website, the results are displayed like this:
Header 1, result
header 2, result
Header 3 result, Header 5 result (an image)
Header 4, result.
The script I have in my intranet to order by the header (column name) does not work on this script.
This is another searchscript and it does not work on this either:

echo "<table>";
echo "<tr>";
echo "<td><p><a href=\"http://www.mysite.com/sales/properties_for_sale_marbella.htm?id=".$row["id"]."\">".$row["propertytitle"]."<br>Property ref.: ".$row["id"]."</a><br><p>".$row["text_eng"]."<br><br>Bedrooms: ".$row["bedrooms"]."<br>Price : ".$row["price"]."<br><br><a href=\"http://www.mysite.com/sales/properties_for_sale_marbella.htm?id=".$row["id"]."\">View details</a></p><p></p></td>";
echo "<td><a href=\"http://www.mmysite.com/sales/properties_for_sale_marbella.htm?id=".$row["id"]."\"><img class='border' src=".$row["image"]." border=\"0\"></a></td>";
echo "</tr>";
} while ($row = mysql_fetch_array($result));

echo "</table> \n";

On the second question,
I want answer 1 and 3, cant see much difference on them, I want to reorder the search withoug having to do a new query to the database:
Yes: Do you want the user to be able to sort the data on the webpage, after you output it? or,

NO: Do you want to sort/display the data in a different order than it comes from the DB? or,

Yes: Do you want to be able to display the same results (possibly in a different order), on subsequent requests, without having to query the DB again?

Thanks a lot