how can i make work this table..???for add autos in database..???

Discussion in 'PHP' started by HACKER TOM, Jan 24, 2008.

  1. #1
    CODE TABLE PROBLEMS!!!!!
    I want to add a car in my table.
    For example new car id:0023 name : nissan price:20000euro
    ok?


    add_autos.php


    <html>
    <head>
    <title>ADD AUTOS</title>
    </head>
    <body bgcolor=#FFCC00>
    <?
    include("mysql.php");
    $link=mysql_connect($host,$user,$password);
    mysql_select_db($database);
    $sql="select * from car_view";
    $result=mysql_query($sql);
    $row=mysql_fetch_array($result,MYSQL_BOTH);
    $name=$row['id'];
    $name=$row['name'];
    $price=$row['price'];
    echo "<center>";
    echo "<h1> Προσθήκη Αυτοκινήτου</h1>";
    echo "<form method=\"post\"action=\"add.php?id=$id\">";
    echo "<table border=1>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>Κωδικός</td><td><input type=\"text\"name=\"id\"value=\"$id\"></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>Όνομα</td><td><input type=\"text\"name=\"name\"value=\"$name\"></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>Τιμή</td><td><input type=\"text\"name=\"price\"value=\"$price\"></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>Πατήστε εδώ για συνέχεια</td><td><input type=\"submit\"value=\"ok\"></td>";
    echo "</tr>";
    echo "</table>";
    echo "</form>";
    echo "</center>";
    mysql_close($link);
    ?>
    </body>
    </html>


    add.php


    <html>
    <head>
    <title>FINAL ADD</title>
    </head>
    <body bgcolor=#FFCC00>
    <?
    include("mysql.php");
    $id=$_GET['id'];
    if(!$id) die("Πρεπει να δώσετε κωδικό");
    $name=$_GET['name'];
    if(!$name) die("Πρεπει να δώσετε όνομα");
    $price=$_GET['price'];
    if(!$price) die("Πρεπει να δώσετε τιμή");
    $name=$_POST['id'];
    $name=$_POST['name'];
    $name=$_POST['price'];
    if(!$id || !$name || !$price)
    die("Δεν έχουν συμπληρωθεί όλα τα πεδία");
    $link=mysql_connect($host,$user,$password);
    mysql_select_db($database);
    $sql="update car_view set name='$name' and price=$price where id=$id";
    if(mysql_query($sql))
    echo "<h1>Eπιτυχής προσθήκη$id</h1>";
    echo "<a href=autos.php>Επιστροφή</a>";
    else
    echo "<h1>Ανεπιτυχής ενημέρωση</h1>";
    echo "<a href=autos.php>Επιστροφή</a>";
    mysql_close($link);
    ?>
    </body>
    </html>
     
    HACKER TOM, Jan 24, 2008 IP
  2. HACKER TOM

    HACKER TOM Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Please Help!!!!!!!
     
    HACKER TOM, Jan 24, 2008 IP
  3. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #3
    greatlogix, Jan 24, 2008 IP
  4. HACKER TOM

    HACKER TOM Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    No Work.....something Else.....???
     
    HACKER TOM, Jan 24, 2008 IP