You are here: insert to DB « PHP « IT news, forums, messages
insert to DB

Posted by "Anasta" on 12/18/05 14:41

It just wont insert new data into DB--any ideas as i have gone over and
over.



<?
mysql_connect("localhost","anasta","silteren");

mysql_select_db("mytipperv1");

if(!isset($cmd))
{
$result = mysql_query("select * from leaderboard order by ID");

while($r=mysql_fetch_array($result))

{
//grab the title and the rating of the entry
$id=$r["ID"];//take out the id
$Name=$r["Name"];//take out the Name
$Rating=$r["Rating"];//take out the Rating


echo "$Name <a href='edit.php?cmd=edit&ID=$id'> Edit</a><br>";


}
}
?>
<?
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
if (!isset($_POST["submit"]))
{
$id = $_GET["ID"];
$sql = "SELECT * FROM leaderboard WHERE ID=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>

<form action="../craigs_DB/edit.php" method="post">
<input type=hidden name="ID" value="<?php echo $myrow["ID"] ?>">

Name: <INPUT TYPE="TEXT" NAME="Name" VALUE="<?php echo $myrow["Name"]
?>" SIZE=15 maxlength="15"><br><br>
Rating: <INPUT TYPE="TEXT" NAME="Rating" VALUE="<?php echo
$myrow["Rating"] ?>" SIZE=3 maxlength="3"><br><br>
<input type="hidden" name="cmd" value="edit">
<input type="submit" name="submit" value="submit">
</form>

<? } ?>
<?
if ($_POST["$submit"])
{
$Name = $_POST["Name"];
$Rating = $_POST["Rating"];

$sql = "UPDATE leaderboard SET Name='$Name', Rating='$Rating' WHERE
ID=$id";
//replace news with your table name above
$result = mysql_query($sql);
echo "Thank you! Information updated.";
}
}
?>

 

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

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