<?php
function getwebpagelist(){
dbconnect();
$q = "SELECT referenceno FROM weblist";
$result = mysql_query($q);
while($row = mysql_fetch_assoc($result))
{
?><option value="<?php echo("$row[referenceno]"); ?>"><?php echo "$row[referenceno]"; ?></option><?php
}
}
That is the function I'm using as it stands. It retrieves all the referenceno's from the table and puts them in <option> tags (this function will be declared inside a <select> tag). It works fine at the moment. However when someone wishes to use this function, but doesnt know the reference number, then they can use the description field which is in the same table. I was wondering how i could get it to display the description in the option tags alongside the referenceno. I was thinking of doing it like this, but it didn't end up working 😕
<?php
function getwebpagelist(){
dbconnect();
$q = "SELECT referenceno FROM weblist";
$result = mysql_query($q);
while($row = mysql_fetch_assoc($result))
{
?><option value="<?php echo("$row[referenceno]"); ?>"><?php echo "$row[referenceno]" . " - " . "$row[description]"; ?></option><?php
}
}
Any ideas on how I could get it to display? I'm guessing i need to use a different array type than that of mysql_fetch_assoc, but I don't know which.
Any help is gladly appreciated.
Thanks
James