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.";
 }
}
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to