Lee-Bartlett Posted October 28, 2008 Share Posted October 28, 2008 Ok, i have a page when you click update it goes to the code below. Each one is then echoed into a text feild which is then editable. At the bottom of my update page is a map, and the button down the bottom normally passes the values into the text boxxes, but, because im echoed previous ones it isnt over writing the old ones. Its hard to explain, here my code, lets see if you understand by that <?php require_once("includes/db_connection.php"); $id = $_POST['id']; echo "<form action=\"form3.php\" method=\"post\">"; $sql = "SELECT * from tblbasicform WHERE id = '$id'"; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($res)){ $id = $row['id']; $name = $row['name']; $email = $row['email']; $buissnes_name = $row['buissnes_name']; $location = $row['location']; $ct = $row['ct']; $website = $row['website']; $telephone = $row['telephone']; $longitude = $row['longitude']; $latitude = $row['latitude']; $type = $row['type']; ?> Input Name: <input type="text" name="name" value="<? echo $name ?>" /><br /> Input Email: <input type="text" name="email" value="<? echo $email?>" /><br /><br /> Input Buissnes Name: <input type="text" name="buissnes_name" value="<? echo $buissnes_name?>" /><br /> Input Street Name: <input type="text" name="location" value="<? echo $location?>" /><br /> Input City/Town: <input type="text" name="ct" value="<? echo $ct?>" /><br /> Input Website: <input type="text" name="website" value="<? echo $website?>" /><br /> Input Telephone: <input type="text" name="telephone" value="<? echo $telephone?>" /><br /> Free <input type="radio" name="type" id="type" value="free"<? echo ($type == "free")?" checked=\checked\"":""; ?>> Paid<input type="radio" name="type" id="type" value="paid"<? echo ($type == "paid")?" checked=\checked\"":""; ?>> <br /><br /> Input Longitude: <input type="text" name="longitude" value="<? echo $longitude?><? echo $_GET["lon"]; ?>" /><br /> ////////////////////////////////////////////////This is the code where i think im going wrong Input Latitude: <input type="text" name="latitude" value="<? echo $latitude?><? echo $_GET["lat"]; ?>" /><br /> <br /> <input type="hidden" name="id" value="<? echo $id?>"> <input type="submit" name="submit" value="Update Data" /> </form> <?php } ?> <style type="text/css"> v\:* { behavior:url(#default#VML); } </style> <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAgnVrcDn5i-V_BsqvXy3j8RQCD8zuE0iZXd_2kA-7WSZHyoK7QhQliKoQiF2wWHxZ_BabaaEkUj4yIg" type="text/javascript"></script> </p> <table width="223" border="0"> <tr> <td width="217"> </td> </tr> </table> <div id="map" style="width: 600px; height: 400px"></div> <div style="width: 600px;"> <script type="text/javascript">//<![CDATA[ var map = new GMap(document.getElementById("map")); map.centerAndZoom(new GPoint(-92.27722, 34.74875), ; // var point = new GPoint(-92.27722, 34.74875); // var marker = new GMarker(point); // map.addOverlay(marker); //GEvent.addListener(map, 'click', function(overlay, point) { // if (overlay) { // map.removeOverlay(overlay); // // } else if (point) { // map.recenterOrPanToLatLng(point); // var marker = new GMarker(point); // map.addOverlay(marker); //var message = "<HTML><HEAD></HEAD><BODY><FORM><b>Lat</b>: <INPUT TYPE='TEXT' SIZE='12' ID='latbox' VALUE=''><b>Lon</b>:<INPUT TYPE='TEXT' ID='lonbox' SIZE='12' VALUE=''></FORM><br><br><br><br></BODY></HTML>"; // marker.openInfoWindowHtml(message); //} //}); // Recenter Map and add Coords by clicking the map GEvent.addListener(map, 'click', function(overlay, point) { document.getElementById("latbox").value=point.y; document.getElementById("lonbox").value=point.x; }); function transferValues(){ if( document.getElementById('latbox').value != "" ) document.getElementById('latitude').value =document.getElementById('latbox').value if( document.getElementById('lonbox').value != "" ) document.getElementById('longitude').value =document.getElementById('lonbox').value } // add the controls map.addControl(new GSmallMapControl()); map.addControl(new GOverviewMapControl()); map.addControl(new GMapTypeControl()); map.addControl(new GZoomControl( /* first set of options is for the visual overlay.*/ { nOpacity:.2, sBorder:"2px solid red" }, /* second set of optionis is for everything else */ { sButtonHTML:"<img src='/images/zoom-button.gif' />", sButtonZoomingHTML:"<img src='/images/zoom-button-activated.gif' />", oButtonStartingStyle:{width:'24px',height:'24px'} }, /* third set of options specifies callbacks */ { buttonClick:function(){display("Looks like you activated GZoom!")}, dragStart:function(){display("Started to Drag . . .")}, dragging:function(x1,y1,x2,y2){display("Dragging, currently x="+x2+",y="+y2)}, dragEnd:function(nw,ne,se,sw,nwpx,nepx,sepx,swpx){display("Zoom! NE="+ne+";SW="+sw)} } )); //]]> </script> </div> <table> <form> <table> <tr> <td align="left"> Lat: </td> <td><input size=13 type="TEXT" id="latbox" name="lat" value="" /></td> </tr> <tr> <td align="left">Lon: </td> <td><input size=13 type="TEXT" id="lonbox" name="lon" value="" /></td> </tr> <tr> <td colspan="2" align="left"> Click map to get coordinates</td> </tr> <tr> <td colspan="2" align="left"><input type="button" onclick="transferValues()" value="Add longitude and latitude to your form."/></td> </tr> </table> </table> <table cellpadding="10"> <tr> <td> <td><a href="http://nexodom.com/website/wifi.php">Back to database</a></td> </tr> </table></td> </tr> <tr> <td height="20" colspan="2" bgcolor="#0099FF"> </td> </tr> </table> </form> </body> </html> <br> </td></tr></table> <!-- Start of StatCounter Code --> <script type="text/javascript" language="javascript"> var sc_project=796901; var sc_partition=6; var sc_security="573b1ff4"; var sc_invisible=1; </script> <script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><a href="http://www.statcounter.com/" target="_blank"><img src="http://c7.statcounter.com/counter.php?sc_project=796901&java=0&security=573b1ff4&invisible=1" alt="invisible hit counter" border="0"></a> </noscript> <!-- End of StatCounter Code --> Link to comment https://forums.phpfreaks.com/topic/130477-form-value-help/ Share on other sites More sharing options...
solon Posted October 29, 2008 Share Posted October 29, 2008 The problem is that you dont send the updated information to a query in your DB something like $qry = mysql_query("UPDATE `table_name` SET `field1`='$variable1', `field2`='$variable2' WHERE (where clause here)"; At the end of your code Link to comment https://forums.phpfreaks.com/topic/130477-form-value-help/#findComment-677057 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.