// sending query
$result = mysqli_query($connection,"SELECT * FROM {$which_table_to_dump}");
if (!$result) {
die("Query to show fields from table failed");
}
$fields_num = mysqli_num_fields($result);
echo "<h1>Table: {$which_table_to_dump} - with Edit and Delete buttons</h1>";
echo "<table border='1'><tr>";
// column headings for the buttons
echo "<td>Button1</td>";
echo "<td>Button2</td>";
// column headings for the table columns
for($i=0; $i<$fields_num; $i++){
$field = mysqli_fetch_field($result);
echo "<td>{$field->name}</td>";
}
echo "</tr>\n";
// printing table rows
while($row = mysqli_fetch_row($result)){
echo "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
echo "<form action=\"handle editdelete.php\" method=\"post\">";
echo "<input type=\"hidden\" name=\"param\" value=\"somevalue\" />"; // need primary key value here !!
echo "<td><input type=submit value=\"EDIT\" name=\"edit\"></td>";
echo "<td><input type=submit value=\"DELETE\" name=\"delete\"></td>";
foreach($row as $cell)
{
echo "<td>$cell</td>";
}
echo "</form></tr>\n";
}
mysqli_free_result($result);
| Subject | Written By | Posted |
|---|---|---|
| How to determine the value of a specific column in a row? | Bob Anonymous | 11/07/2012 06:26PM |
| Re: How to determine the value of a specific column in a row? | Barry Galbraith | 11/07/2012 08:13PM |
| Re: How to determine the value of a specific column in a row? | Bob Anonymous | 11/07/2012 10:25PM |
| Re: How to determine the value of a specific column in a row? | Barry Galbraith | 11/08/2012 02:21AM |
| Re: How to determine the value of a specific column in a row? | Bob Anonymous | 11/08/2012 10:09PM |
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.