2021年1月22日星期五

How do I get the $row['id'] using mysqli_fetch_arrray

The ID column is blank The lines to display the Glyphs produce an error "Undefined index: id in ...". The data from 'clubs' displays correctly. I have cribbed the code below from a public example as I try and teach myself PHP and modified it for something that is useful to me (minor mods) but cannot figure out how to stop the undefined index error. Any help would be appreciated.

<?php  // Include config file  require_once "config.php";    // Attempt select query execution  $sql = "SELECT * FROM clubs";  if($result = mysqli_query($link, $sql)){  if(mysqli_num_rows($result) > 0){                          echo "<table class='table table-bordered table-striped'>";  echo "<thead>";  echo "<tr>";  echo "<th>#</th>";  echo "<th>ClubID</th>";  echo "<th>Club Name</th>";  echo "<th>Active</th>";  echo "<th>Cal Year</th>";  echo "</tr>";  echo "</thead>";    echo "<tbody>";    while($row = mysqli_fetch_array($result)){  echo "<tr>";  echo "<td>" . $row['id'] . "</td>";  echo "<td>" . $row['ClubID'] . "</td>";  echo "<td>" . $row['ClubName'] . "</td>";  echo "<td>" . $row['ActiveClub'] . "</td>";  echo "<td>" . $row['CalendarYr'] . "</td>";  echo "<td>";  echo "<a href='read.php?id=". $row['id'] ."' title='View Record' data-toggle='tooltip'><span   class='glyphicon glyphicon-eye-open'></span></a>";  echo "<a href='update.php?id=". $row['id'] ."' title='Update Record' data-toggle='tooltip'><span   class='glyphicon glyphicon-pencil'></span></a>";  echo "<a href='delete.php?id=". $row['id'] ."' title='Delete Record' data-toggle='tooltip'><span   class='glyphicon glyphicon-trash'></span></a>";  echo "</td>";  echo "</tr>";  }  echo "</tbody>";                        echo "</table>";  // 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/65855934/how-do-i-get-the-rowid-using-mysqli-fetch-arrray January 23, 2021 at 01:07PM

没有评论:

发表评论