stublackett Posted January 19, 2009 Share Posted January 19, 2009 Hi, I've got an Edit Form setup. It consists of 3 dropdown boxes. What I'd like to do is as one of the options to select is to have the data that is pulled from the Database, Surely this is possible? I've tried the standard <?php echo $dbfield ; ?> But had no joy. Its just showing that code in the browser. My Code : <?php if(isset($_POST['submitted'])) { // Set global variables to easier names // and prevent sql injection and apostrophe to break the db. extract($_POST); $pRef = $_GET['pRef']; $result = mysql_query("UPDATE property SET carname='$carname', description ='$description', price='$carsprice', feature1='$feature1', feature2='$feature2', feature3='$feature3', feature4='$feature4', feature5='$feature5' WHERE pRef='$pRef' "); echo "Thank you! The Property <h2><u>$pAddress1</u></h2>has been edited"; echo "<br><br>"; echo "<meta http-equiv=Refresh content=3;url=index.php>"; exit; } elseif(isset($_GET['pRef'])) { $result = mysql_query("SELECT * FROM $db_table WHERE pRef='$_GET[pRef]'"); while($myrow = mysql_fetch_assoc($result)) { $pRef = $_GET['pRef']; $pAddress1 = $myrow['pAddress1']; $pAddress2 = $myrow['pAddress2']; $pTown = $myrow['pTown']; $pPostCode = $myrow['pPostCode']; $pBuildingType = $myrow['pBuildingType']; $pBedRooms = $myrow['pBedRooms']; $pPriceType = $myrow['pPriceType']; $pPrice = $myrow['pPrice']; $pDescription = $myrow['pDescription']; } } ?> HTML Form <select name="pBuildingType" id="pBuildingType" > <option value="<?php echo $pBuildingType ; ?>"><?php echo $pBuildingType ; ?></option> <option value="Bungalow">Bungalow</option> <option value="Commercial">Commercial</option> <option value="Cottage">Cottage</option> <option value="Detached">Detached</option> <option value="End Terraced">End Terraced</option> <option value="Flat">Flat</option> <option value="Semi Detached">Semi Detached</option> <option value="Terraced">Terraced</option> </select> Any help appreciated *EDIT* I've managed, Spotted it was an HTML Coding error MODS If you could delete? Or otherwise I'll mark as SOLVED! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.