Re: insert to DB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

       I think you should read a beginner tutorial about SQL. there are just
four things Insert, Delete, Update and select, that need to be known for
working with database in normal conditions, after that you can move to
create, drop, alter or much more like joins etc.

http://www.lmpx.com/mysql_ref.php


Zareef Ahmed



----- Original Message ----- 
From: "Anasta" <neretlis@xxxxxxxxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Sent: Sunday, December 18, 2005 7:41 AM
Subject:  insert to DB


> 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
>
>
>

====================================================
PHP Expert Consultancy in Development  http://www.indiaphp.com
Yahoo! : consultant_php MSN : consultancy@xxxxxxxxxxxx

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux