Upload
lotlot
View
2.231
Download
2
Embed Size (px)
DESCRIPTION
Citation preview
VIEW EDIT DELETE
View Data<?php
require_once ('../../mysql/mysql_connect.php');
$query = "SELECT * FROM Tablename";
$result = mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_ASSOC);
echo '<table cellspacing="2" cellpadding="2">';
echo '<table border="0" cellspacing="3" cellpadding="3" align="center">
<tr>
<td align="left" width=""><b>Name</b></td>
</tr>';
// Display all the URLs.
$result = mysql_query ($query);
$total = mysql_num_rows ($result);
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC))
{
// Display each record.
echo "<tr></tr>";
echo "<td align=left><a href=\"cooperator.php?coop=".$row['id']."\">{$row['name']}</font></td></td>";
echo "<td align=left><a href=\"edit-coop.php?coop_id=".$row['id']."\">Edit</font></td>";
} // End of while loop.
echo "<tr></tr>";
echo "<td align=\"left\"><b>$total</b></font></td>
";
echo '</table>'; // Close the table.*/
mysql_close(); // Close the database connection.
?>
View Single Data<?phprequire_once
('../../mysql/mysql_connect.php');
if (is_numeric ($_GET['coop'])) { // Make sure there's a print ID.
$query = "SELECT * FROM Table_name";
$result = mysql_query ($query);$row = mysql_fetch_array ($result, MYSQL_ASSOC);mysql_close(); // Close the database connection.
} else { // Redirect//header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php");exit("No Cooperator Id is Present");
}
echo "<TABLE> ";echo "<TR ><TD>{$row['last_name']}</td>";echo "</TABLE>";
?>
Edit<?php
require_once ('../../mysql/mysql_connect.php');
$coop_id = $_GET['coop_id'];
if(isset($_POST['submit']))
{
first_name = $_POST['first_name'];
$result = mysql_query("UPDATE table SET first_name='$first_name'",$connect);
echo "The Cooperator has been UPDATED Successfully!";
}
elseif($id)
{
$result = mysql_query("SELECT * FROM
table WHERE coop_id='$id' ",$connect);
while($myrow = mysql_fetch_assoc($result))
{
$first_name = $_POST["first_name"];
?>
Edit Cont.<h3 align="center">Edit <? echo
$myrow['first_name']?> <? echo $myrow['last_name']?> Information</h3>
<form method="post" action="<?php echo $PHP_SELF ?>">
<input type="hidden" name="coop_id" value="<? echo $myrow['coop_id']?>">
<table width="760" border="0" align="center">
<tr>
<td>First Name</td>
<td><input name="first_name" size="40" maxlength="255" value="<? echo $myrow['first_name']?>" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Update Information" /></td>
</tr>
</table>
</form>
<?
}//end of while loop
}//end else
?>
Delete
<?phprequire_once
('../../mysql/mysql_connect.php'); $id = $_GET[‘name_id'];$result = mysql_query("DELETE FROM table WHERE name_id=$id");echo 'Record has been deleted';
?>