tobimichigan Posted August 10, 2009 Share Posted August 10, 2009 Hi Code Gurus, <?php include("cn.php"); $pfno=$_GET['pfno']; $result=mysql_query("SELECT (*) FROM user_table WHERE pfno=$pfno"); //$result = mysql_fetch_assoc($select); $num=mysql_num_rows($result); //mysql_close(); $i=0; while ($i < $num) { $amountd=mysql_result($result,$i,"amountd"); $department=mysql_result($result,$i,"department"); $email=mysql_result($result,$i,"email"); $fname=mysql_result($result,$i,"fname"); $oname=mysql_result($result,$i,"oname"); $lname=mysql_result($result,$i,"lname"); $lga=mysql_result($result,$i,"lga"); $marital=mysql_result($result,$i,"marital"); $Nationalty=mysql_result($result,$i,"Nationalty"); $pfno=mysql_result($result,$i,"pfno"); $residentialadd=mysql_result($result,$i,"residentialadd"); $sex=mysql_result($result,$i,"sex"); $soorigin=mysql_result($result,$i,"soorigin"); $telno=mysql_result($result,$i,"telno"); //Space For Code $query = ("UPDATE user_table SET amountd = '$amountd', department = '$department', email = '$email', fname = '$fname', lga = '$lga', lname = '$lname',marital='$marital', Nationalty='$Nationalty',oname='$oname', residentialadd='$residentialadd', soorigin='$soorigin',telno='$telno', WHERE pfno = '$pfno'"); mysql_query($query); echo //"Record Updated"; mysql_close(); ++$i; } $amountd=$_POST['amountd']; $department=$_POST['department']; $email=$_POST['email']; $fname=$_POST['fname']; $lga=$_POST['lga']; $lname=$_POST['lname']; $marital=$_POST['marital']; $Nationalty=$_POST['Nationalty']; $oname=$_POST['oname']; $residentialadd=$_POST['residentialadd']; $soorigin=$_POST['soorigin']; $telno=$_POST['telno']; ?> There are 2 things I'd love to do. Firstly, display the existing member's profile data on an html form. Secondly, update the previous values stored by new ones with sql update as above. When I preview in an explorer on the form it gives me this-><? echo $lname; ?> as a form return value instead of showing the current member information and after clicking submit, updating the profile accordingly. This error: "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in line 24" is also coming out of the browser top page. Where line 24 = $num=mysql_num_rows($result); Please gurus help me out... Link to comment https://forums.phpfreaks.com/topic/169602-updating-member-profile/ Share on other sites More sharing options...
kartul Posted August 10, 2009 Share Posted August 10, 2009 if i get this right then to display current db values in input fields: $sql = "select * from users where id=$id"; $row = mysql_fetch_assoc($sql); //now the form echo "<input type="text" name="location" value="\".$row['location'].\"">" Link to comment https://forums.phpfreaks.com/topic/169602-updating-member-profile/#findComment-894763 Share on other sites More sharing options...
MasterACE14 Posted August 10, 2009 Share Posted August 10, 2009 $sql = "select * from users where id=$id"; $row = mysql_fetch_assoc($sql); //now the form echo "<input type=\"text\" name=\"location\" value=\"".$row['location']."\" />"; // missing a few slashes and a semi colon Link to comment https://forums.phpfreaks.com/topic/169602-updating-member-profile/#findComment-894801 Share on other sites More sharing options...
tobimichigan Posted August 10, 2009 Author Share Posted August 10, 2009 $sql = "select * from users where id=$id"; $row = mysql_fetch_assoc($sql); //now the form echo "<input type=\"text\" name=\"location\" value=\"".$row['location']."\" />"; // missing a few slashes and a semi colon How is " <input type=\"text\" name=\"location\" value=\"".$row['location']."\" />"; " supposed to be encapsed with <?php ?> tags? in the form? Link to comment https://forums.phpfreaks.com/topic/169602-updating-member-profile/#findComment-894979 Share on other sites More sharing options...
tobimichigan Posted August 10, 2009 Author Share Posted August 10, 2009 Please could someone tell how " <input type=\"text\" name=\"location\" value=\"".$row['location']."\" />"; " supposed to be encapsed in code tags? Link to comment https://forums.phpfreaks.com/topic/169602-updating-member-profile/#findComment-895033 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.