2021年2月2日星期二

New to MYSQL/PHP and need help rendering a MYSQL array output in to a PHP numbered list

Code posted below. I currently get the correct results as the code would call for below.

- Fred Jones. Walked to the store.
- Nancy Schmitt. Went to the airport.
- Tom Smith. Mowed the yard.

What i'm trying to do is get output like so. Sometimes there are multiple tasks. A list is generated every day so the number of tasks and customers may change.

1) Fred Jones. Walked to the store.
2) Nancy Schmitt. Went to the airport.
3) Tom Smith. Mowed the yard.

Is there any way to generate a "numbered list" of my output?

$sql = "SELECT * FROM tasks WHERE taskDate = curdate()";                  if($result = mysqli_query($link, $sql)){                      if(mysqli_num_rows($result) > 0){                              while($row = mysqli_fetch_array($result)){                                  $html .= " \n ". "- " . $row["customer"]. ". " . $row["task"]. " \n ";                               }                                               // Free result set                          mysqli_free_result($result);                      } else{                          echo "<p class='lead'><em>No records were found.</em></p>";                      }                  } else{                      echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);                  }                    // Close connection                  mysqli_close($link);  
https://stackoverflow.com/questions/66020186/new-to-mysql-php-and-need-help-rendering-a-mysql-array-output-in-to-a-php-number February 03, 2021 at 09:53AM

没有评论:

发表评论