MySQL and PHP 3

<?php
    
    $id = $_GET['id'];

    $con = mysql_connect("localhost","","");

    if(!$con){
        die("Could not connect " . mysql_error());
    }

    mysql_select_db("test",$con);

    $result = mysql_query("SELECT * FROM exercise WHERE ID = '$id' ");
    $row = mysql_fetch_array($result);
    $firstname = $row['FirstName'];
    $lastname = $row['LastName'];
    $age = $row['Age'] - 17;
    $link = $row['Link'];

?>

<html>
    <body>
    <form action = "2.php" method = "post">
        FirstName <input type = "text" name = "firstname" value = "<?php echo $firstname ?>"/> <br/>
        LastName <input type = "text" name = "lastname" value = "<?php echo $lastname ?>"/> <br/>
        <label>Age</label>
        <select name = "age" id = "age">
            <option value = "17">17</option>
            <option value = "18">18</option>
            <option value = "19">19</option>
            <option value = "20">20</option>
            <option value = "21">21</option>
            <script type="text/javascript">document.getElementById("age")['<?php echo $age ?>'] = true;</script>
        </select>

        <input type = "submit" value = "update"/>
        <input type = "file" name = "file" id = "file"/>
        <input type = "hidden" value = "update" name = "selection"/>
        <input type = "hidden" value = "<?php echo $id?> " name = "id1"/>
        <img src = "<?php echo $row['Link']?>"/>

    </form>
    </body>

</html>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容