I’m trying to pull data from a range of rows in a table (the table called “pages” & the column called “name”), arrange the results alphabetically, and output the results along with the corresponding id (primary key). the output is supposed to be of the form (simplified for clarity):
here’s the PHP that fetches the array, minus error-checking:
$takebake = mysqli_query($link, 'SELECT id, name FROM pages WHERE id > 200 AND id < 401');
while ($row = mysqli_fetch_array($takebake)) {
$meals[] = $row['name'];
sort ($meals);
}
That gets the meal name to appear in the output, but I haven’t got a clue how to get the ids in there – especially in the sort order from the names.
First, let me thank you both for the speedy reply. I tried the examples, and I’m getting some pretty strange results. The values should be more like ID 201, NAME Macaroni & Cheese. Any Ideas?
the form processor is the php that will handle the form submission. i’ll have to ensure that each of these inputs has equivalent data handling in the processor, but i’ll cross that bridge after i get this working.
it’s getting closer, but the output is echoing twice. i sure don’t see why – the code for the output appears only once, and the fetch query doesn’t have anything in it that should cause it to iterate twice, at least, not to my novice eyes.
you can also see a more complete version of the form. i’ve turned off the JavaScript that runs client side checking & operates the accordion, while i’m testing. As you can see, the output appears twice here, too.