Forum Moderators: open
More info is needed. Specifically, the actual HTML output.
In JavaScript, if you've got an array you can sort it using:
yourArrayInstance.sort();
You can then replace the innerHTML of some element with the values in the array. But without seeing your markup, it's hard to provide useful help.
In any case, start here:
[developer.mozilla.org...]
Thanks, will have a look.
This is the html output and the query I want to be able to order:
More info is needed. Specifically, the actual HTML output.
In JavaScript, if you've got an array you can sort it using:
yourArrayInstance.sort();
You can then replace the innerHTML of some element with the values in the array. But without seeing your markup, it's hard to provide useful help.
In any case, start here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
$result = mysql_query ("SELECT FORMAT(price_eng, 0) as price, propertytitle, text_eng, bedrooms, image, zona, id FROM ventas_buscador WHERE zona LIKE '%GM%'order by price_eng", $dbh);
if ($row = mysql_fetch_array($result)){
do {
echo "<table class='tabla' border='0'> \n";
echo "<tr>";
echo "<td class='searchertop'><p><a href=\"properties_for_sale_marbella.htm?id=".$row["id"]."\">".$row["propertytitle"]."<br>Property reference: ".$row["id"]."</a><br><p>".$row["text_eng"]."<br><br>Bedrooms: ".$row["bedrooms"]."<br>Price €: ".$row["price"]."<br><br><a href=\"properties_for_sale_marbella.htm?id=".$row["id"]."\">View details</a></p><p></p></td>";
echo "<td class='searchertop2'><a href=\"properties_for_sale_marbella.htm?id=".$row["id"]."\"><img class='borderfotos' src=".$row["image"]." border=\"0\"></a></td>";
echo "</tr>";
} while ($row = mysql_fetch_array($result));
echo "</table> \n";
In JavaScript, if you've got an array you can sort it using:
yourArrayInstance.sort();
You can then replace the innerHTML of some element with the values in the array. But without seeing your markup, it's hard to provide useful help.
In any case, start here:
[developer.mozilla.org...]
Let me see if I get somewhere with this,
so if I am correct, the array is in the php var from the mysql query, so to try to do some tests with the examples on the link you gave me, first I need to convert the php var to a javascript var?
A quick way would be to use a table that has sortable columns.
You can use jquery and plugins such as tablesorter.
1. The code you pasted is not HTML, it is the PHP that generates HTML.
2. The code you pasted contains a table even though you claim it doesn't, so I'm not sure what to believe. Either this isn't the code you're using, or you're mistaken about it not using tables.