I'm trying to return data from a Mysql db to fill a javascript dropbox on a php page.
I can get the data fine, and I can fill the list ok.
Basically I need to create an array like thus.
var pages = new makeArray("Select a ship on this page",
"Aguilar (1824)",
"Andromeda (1823)",
"Australasia (1855)",
"Atlanta (1866)",
"America (1855)",
"Admiral Cockburn (1827)",
"Aurora Australis (1862)"
);
I'm using the following code...
var pages = new makeArray("Select a ship on this page",
<?php
$getlist = mysql_query("SELECT * FROM imgships WHERE ship like '$currsltr%' ORDER BY shipsort",$db);
while ($row = mysql_fetch_array($getlist)) {
$lship = $row["ship"];
echo "\"$lship\"";
echo ",\n";
}
echo "\n";
?>
The trouble is that the last ship variable shouldn't include the comma on the end. (As per the list above).
Anyone have any ideas on how I can leave the comma off the last returned entry.
I can get the data fine, and I can fill the list ok.
Basically I need to create an array like thus.
var pages = new makeArray("Select a ship on this page",
"Aguilar (1824)",
"Andromeda (1823)",
"Australasia (1855)",
"Atlanta (1866)",
"America (1855)",
"Admiral Cockburn (1827)",
"Aurora Australis (1862)"
);
I'm using the following code...
var pages = new makeArray("Select a ship on this page",
<?php
$getlist = mysql_query("SELECT * FROM imgships WHERE ship like '$currsltr%' ORDER BY shipsort",$db);
while ($row = mysql_fetch_array($getlist)) {
$lship = $row["ship"];
echo "\"$lship\"";
echo ",\n";
}
echo "\n";
?>
The trouble is that the last ship variable shouldn't include the comma on the end. (As per the list above).
Anyone have any ideas on how I can leave the comma off the last returned entry.