I am pulling results for each letter of the alphabet that sorts and lists in alphabetical order. The example here is for the letter M. The code is intended to pull all results that begin in M and list them alphabetically. Each row that results is used to populate the “echo section” listed and then repeat. I am unable to locate anywhere that explains how to pull row result and assign a variable without terminating the loop and only returning a single row (the first result). I can pull one row and have it display correctly, but I am stumped how to pull multiple row results and assign them to the Echo section and then move onto the next alphabetic result.
Any help is appreciated! A location with an explanation would also be appreciated.
[php]
<?php require("cnfgcnnt.php"); if($dbcon){ $query = "SELECT * FROM catalg ORDER BY name AND name LIKE 'M%'"; $results = mysqli_query($dbcon, $query); if($row = mysqli_fetch_array($results)){ // Should the if command be a while? and should there be a >0 in the previous command? // Returning all rows with an M in alphabetic order // Variables used in creating the output // If I assign the varaibles here, only the first row that meets the criteria is displayed // $date = $row['date']; // $name = $row['name']; // $define = $row['define']; // $submitter = $row['app_id']; // $website = $row['website']; // $email = $row['email']; } } else { die(mysqli_error()); } // The output variables populate some hyperlinks // There are several table enties that should repeatedly use the output below, until all the M's are used. // how do I assign the results to display in the echo without terminating the output after a single row? //{ // echo "Name: " .$row['name']; // echo "Definition: " . $row['define']; // echo "\n"; echo " $name - $submitter - $email/$define \n"; echo "
\n"; ?>[/php]