Jump to content

Php View all Members but not Editing or Deleting?


gkishorekumarg

Recommended Posts

Firstly, and a little off topic, look into using CSS to style your table cells rather then the way you are doing it now.

 

Secondly, without seeing your editform.php and delete.php files, we cant help you.

 

delete.php would look something like:

include(connection.php);
$query = "DELETE FROM star WHERE id='$_GET[id]'";
$result = mysql_query($query);
if($result)
  echo "Deleted";
else
  echo "Not Deleted";

the editform.php would look similar to your add user form, but with some sql at the top and a few value="<?= $array['id'] ?>" in the form fields.

 

i have something very similer, try this ...

 

the view:

<?php
include 'connection.php';
include 'access.php';

$db = mysql_connect ($hostname, $username, $password) or die ('Failed to connect to database: ' . mysql_error());
mysql_select_db($database);

	$query = "SELECT * FROM table WHERE field = 1 ORDER BY field ASC";
$result = mysql_query($query) or die ('Failed to query ' . mysql_error());
?>
<form method="post" action="./process.php">
  <table>
    <tr>
      <th scope="col"> </th>
      <th scope="col">Field</th>
      <th scope="col">Field</th>
      <th scope="col">Field</th>
      <th scope="col"> </th>
    </tr>
    <?php
while ($row = mysql_fetch_assoc($result)) 
{
	$Field = $row['Field'];
	$Field = $row['Field']; 
	$Field = $row['Field'];
	$Field = $row['Field'];
?>
    <tr>
      <td><input type="radio" name="Field" id="radio" value="<?php echo "$Field";?>"></td>
      <td><?php echo "$Field";?></td>
      <td><?php echo "$Field";?></td>
      <td><?php echo "$Field";?></td>
      <td><?php echo "$Field";?></td>
    </tr>
    <?php
}
?>
  </table>
  <table>
    <tr>
      <td><input type="submit" name="submit[edit_confirm]" value="Edit"></td>
      <td><input type="submit" name="submit[delete_confirm]" value="Delete"></td>
    </tr>
  </table>
</form>
<?php
mysql_free_result($result);
mysql_close($db);
?>

 

the process.php

<?php
$submit_array = array_keys($_POST['submit']);
$action = $submit_array[0];
if ($_POST)
{
switch ($action)
{
	case 'edit':
		include('./includes/functions/edit_go.php');
		break;

	case 'edit_confirm':
		include('./includes/functions/edit.php');
		break;

	case 'delete':
		include('./includes/functions/delete_go.php');
		break;

	case 'delete_confirm':
		include('./includes/functions/delete.php');
		break;

}

}

?>

 

what happens.. there is a radio button next to each row, that is assigned to the ID of that row and when submitted it uses the case func to determin what to do with the submitted info. its a rather clean and easy way to do what you are wanting.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.