Re: insert to DB

From: Date: Tue, 27 Dec 2005 01:40:51 +0000
Subject: Re: insert to DB
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-227881@lists.php.net to get a copy of this message
pls could you point out which instruction should insert record in db thanks... 2005/12/18, Anasta <neretlis@westnet.com.au>: > > 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 > >

« previous php.general (#227881) next »