Jump to content

Recommended Posts

Yep im still unsure on how you do this, i have followed x ammount of tutorial to try do this and i cant find it. Can you do it with strict php ? or do you need java along side it? All i need to do is this. I wanna search my user, say in a drop down box, then have the feilds which will update each row if the information is changed in the text feild. Can anyone help me please, been looking for good part of a week :(

If you're talking about dynamically filling in the fields once the user is selected in a drop down box, it will need to be javascript. If you'll "submit" the information and load up a new page, PHP will do just fine. If you can answer that I should be able to direct you to the correct place/tutorial.

Ye i have looked at this site before, thats where i got the insert using html form but it doesnt show you how to update it using a html form. Thanks for trying tho, really appreciate it

 

i would like somthing like this, but in a html form

 

mysql_select_db("roberts_work", $connect);

mysql_query("UPDATE tblbasicform SET location = 'Harlow'
WHERE name = 'chris' AND email = 'chris@chris.com'");

mysql_close($connect);

 

 

I see where you're having the issue. Okay then what you need is this tutorial:

 

http://www.tizag.com/phpT/forms.php

 

Basically you do a standard HTML form with the target into a PHP page. That PHP page loads the variables that you "POSTED" with the form, and then you use PHP to update the MySQL.

Not completly sure how to adapt my current form to that, currently i have

 

<?php  require_once("includes/db_connection.php");  ?>

<html>
<head></head>
<body>
  <form name="form1" method="post" action="process.php">
<select id="names" name="name">

<?php

  $nameQry = "SELECT * FROM tblbasicform";
      $result = mysql_query($nameQry) or die(mysql_error());
  
  while($row = mysql_fetch_array($result)){
echo "<option>". $row['name'];
        echo "</option>";
$name = $row['name'];
    $email = $row['email'];
    $location = $row['location'];
    $id = $row['id'];
  }

?>

</select> 
<br>
  Input First Name: <input name="name" type="text" name="firstname" value="<? echo $name ?>" /><br />
  Input Email: <input type="text" name="email" value="<? echo $email ?>" /><br />
  Input Location: <input type="text" name="location" value="<? echo $location?>" /><br />
  Input ID Number: <input type="text" name="id" value="<? echo $id?>" /><br />
<input type="submit" name="submit" value="Update Data" />
</form>

</body>
</html>

 

not sure what needs to go into the process.php bit

process.php will contain variables that draw the posted variables, e.g.:

 

<?php
$firstname = $_POST['firstname'];
$email = $_POST['email'];
$location = $_POST['location'];
$id = $_POST['id'];
?>

 

And after getting the variables like that, you use the variables ($firstname, $email, etc.) to update using the code you posted for MySQL. For instance, if you were going to just update a location:

 

mysql_select_db("roberts_work", $connect);

mysql_query("UPDATE tblbasicform SET location = '" . $location . "'
WHERE name = '". $firstname . "' AND email = '" . $email . "'");

mysql_close($connect);

 

Understand it now?

That's probably the best route, some trial and error. It's actually very simple once you know the process and I'm sure you'll take off from there. If you have any other issues or specific questions, feel free to post or contact me directly and I'll do what I can.

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.