You are here: Re: Update all fields « PHP SQL « IT news, forums, messages
Re: Update all fields

Posted by UKuser on 10/08/80 11:39

My code now reads:

<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());

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>id</td>";
echo "<td>Lowerval</td>";
echo "<td>Upperval</td>";
echo "<td>Result</td></tr>";

if($mode == "Update")
{
for ($i=0; $i<count($_POST['id']); $i++)
{
$query = "UPDATE table SET lowerval='{'$_POST['lowerval'][$i]}',
upperval='{'$_POST['upperval'][$i]}', result='{'$_POST['result'][$i]}'
WHERE id='{'$_POST['id'][$i]}'";
$test = mysql_query($query);
}
}

while ($l = mysql_fetch_array($resulta, MYSQL_ASSOC))
{ ?>
<tr>
<td><input type="text" name="id[]" value="<?=$l[0]?>"></td>
<td><input type="text" name="lowerval[]" value="<?=$l[1]?>"></td>
<td><input type="text" name="upperval[]" value="<?=$l[2]?>"></td>
<td><input type="text" name="result[]" value="<?=$l[3]?>"></td></tr>
<?
} //end display

echo "</tr>";
echo "</table>";
?>
<input type='submit' name=mode value='Update'>
</form>
</HTML>

And I'm afraid it doesnt appear to work.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация