|
Posted by UKuser on 10/13/66 11:39
Hi Guys,
I am playing with a PHP/MySQL script at
http://nana46.coconia.net/test4.php
What I have done is placed every record from the table in an input box,
so that each box can be edited. I've given each field a unique name,
and then assigned the overall name in the update query. However when I
update, it does update everything but not with the information I've
typed in. In short I'm hoping for users to be able to type in any
boxes/fields, click Update and the record update, rather than editing a
record at a time.
Any thoughts would be great.
Thanks
A
I am using the following code:
<HTML>
<TITLE>test 4</title>
<form method='post' action='test4.php'>
<?php
function check_mysql()
{
if (mysql_errno() > 0)
{
die("<BR> MySQL error " . mysql_errno() . ": " .
mysql_error());
}
}
$db = mysql_connect("coconia.net", "nana46_nana46", "hello");
if (!$db)
{
die("Failed to open connection to MySQL server.");
}
mysql_select_db("nana46_nana46");
check_mysql();
$requete = "SELECT id,lowerval,upperval,result FROM fig_lookup";
$resulta = mysql_query($requete) or die (mysql_error());
if($mode == "Update")
{
$query = "UPDATE fig_lookup SET lowerval ='$Lid', upperval='Uid',
result='$Rid'";
$req = mysql_query($query);
check_mysql();
}
echo '<table border="2" cellpadding="0" cellspacing="0" width="100%">';
$edit = "<img src='edit.gif' border='0' alt='Edit record'>";
echo "<table border='2'>";
echo "<td> </td>";
echo "<td>id</td>";
echo "<td>Lowerval</td>";
echo "<td>Upperval</td>";
echo "<td>Result</td>";
while ($line = mysql_fetch_array($resulta, MYSQL_ASSOC))
{
$id = $line["id"];
{
$num = "0.$id";
$Lid = "1.$id";
$Uid = "2.$id";
$Rid = "3.$id";
$clinec = "<TD><input name=$num type=text value=";
$clined = "<TD><input name=$Lid type=text value=";
$clinee = "<TD><input name=$Uid type=text value=";
$clinef = "<TD><input name=$Rid type=text value=";
}
echo "<tr>";
echo ("<TD WIDTH=15><B><A
HREF=\"test5.php?id=$id\">$edit</A></B></TD>\n");
// Affichage des champs sur une line
echo $clinec.$line["id"]."></td>";
echo $clined.$line["lowerval"]."></td>";
echo $clinee.$line["upperval"]."></td>";
echo $clinef.$line["result"]."></td>";
}
echo "</tr>";
echo "</table>";
?>
<input type='submit' name=mode value='Update'>
</form>
</HTML>
Navigation:
[Reply to this message]
|