Jump to content

Updating Member Profile()


tobimichigan

Recommended Posts

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
Share on other sites

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
Share on other sites

$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.