html - PHP Table Columns -
so php displays mysql table, i'm aware can tyle these plan to. image below shows, add button adds column.
is possible make add button below 2 columns update , delete? if how can this. here code, sorry errors or being messy, i'm still learning.
while ($record = mysql_fetch_array($mydata)) { echo "<form action=usermanagement.php method=post>"; echo "<tr>"; echo "<td>" . "<input type=text name=id value=" . $record['id'] . " </td>"; echo "<td>" . "<input type=text name=rank value=" . $record['rank'] . " </td>"; echo "<td>" . "<input type=text name=username value=" . $record['username'] . " </td>"; echo "<td>" . "<input type=text name=password value=" . $record['password'] . " </td>"; echo "<td>" . "<input type=hidden name=hidden value=" . $record['id'] . " </td>"; echo "<td>" . "<input type=submit name=update value=update" . " </td>"; echo "<td>" . "<input type=submit name=delete value=delete" . " </td>"; echo "</tr>"; echo "</form>"; } echo "<form action=usermanagement.php method=post>"; echo "<tr>"; echo "<td><input type=text name=uid></td>"; echo "<td><input type=text name=urank></td>"; echo "<td><input type=text name=uusername></td>"; echo "<td><input type=text name=upassword></td>"; echo "<td>" . "<input type=submit name=add value=add" . " </td>"; echo "</form>"; echo "</table>";
pay attention closing tags of inputs.. hidden inputs can put anywhere in table not being displayed:
while($record = mysql_fetch_array($mydata)) { echo '<form action=usermanagement.php method=post> <tr> <td> <input type=text name=id value="' . $record['id'] . '" /> </td> <td> <input type=text name=rank value="' . $record['rank'] . '" /> </td> <td> <input type=text name=username value="' . $record['username'] . '" /> </td> <td> <input type=text name=password value="' . $record['password'] . '" /> </td> <td> <input type=hidden name=hidden value="' . $record['id'] . '" /> <input type=submit name=update value=update /> </td> <td> <input type=submit name=delete value=delete /> </td> </tr> </form>'; } echo '<form action=usermanagement.php method=post> <tr> <td> <input type=text name=uid /> </td> <td> <input type=text name=urank /> </td> <td> <input type=text name=uusername /> </td> <td> <input type=text name=upassword /> </td> <td colspan="2"> <input type=submit name=add value=add /> </td> </tr> </form>';
also, try stop using mysql_*
functions being deprecated. use pdo
, mysqli_
or mysqli
class instead.
Comments
Post a Comment