I am working with my last unit assignment, I have already found the way to include the checkboxes into each row of my table. I am still working with the php code to display the records selected in the table to be modified. I am not sure if I need to use the foreach() according to my code or if I must use any other way such using a button for each record instead checkboxes. I don't want to give up myself with this one so here is what I have until now:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="php_styles.css" type="text/css" />
<title>Modifications</title>
</head>
<body>
<?php
include("admin.php");
?>
<h2 align="center">Modifying</h2>
<body>
<?php
//Varible declared to establish a connection
$connection = mysql_connect("localhost", "user1", "ryciorycio");
//Veryfing if connection is established
if (!$connection)
{
die('Could not connect: ' . mysql_error());
exit;
}
else
//Connecting to database and table
mysql_select_db("garcia", $connection);
//Declaring a variable to hold the requested values
$result = mysql_query("SELECT LastName, FirstName, AreaCode, PhoneNumber
FROM `contacts`
ORDER BY LastName ASC
LIMIT 0 , 30");
$i = 0;
$checkboxes = "<input type='checkbox' name='selected[]' value='$i++'/><br />";
//Presenting the values in a table
echo "<table align='center' border='1' width='40%'>";
echo "<tr><th>Modify</th><th>Name</th><th>Phone Number</th></tr>";
while($row = mysql_fetch_array($result))
{
$FixNumber = implode('-',str_split(substr($row['PhoneNumber'] , 0,-4),3)).'-'.substr($row['PhoneNumber'],-4);
echo "<tr><td>$checkboxes</td><td>{$row['LastName']}, {$row['FirstName']}</td><td>({$row['AreaCode']}) $FixNumber</td></tr>";
}
echo "</table><br />";
//Closing connection
mysql_close($connection);
?>
<form action="ModifySelected.php" method="get" enctype="application/x-www-form-urlencoded">
<p><input type="submit" value="Modify" tabindex="3"/>
</form></p>
<hr/>
<p>To modify any contact select it from the list and click <strong>"Modify"</strong> button.</p><hr width="35%"/>
</body>
</html>
I have include a picture of how it looks the webpage at the momment. I am sure this way will be much better to modify the existing records that one at a time. Please do not hesitate to ask for any other information, thanks in advance.

New Topic/Question
Reply




MultiQuote





|