Jump to content

show only the ID chosen from DB?


derrick1123

Recommended Posts

I need to get them to get the ID I want from the database so I can update that row only.

<?php
include("db_settings.php");
$id = $_POST['id'];
$step = $_POST['step'];
$name = $_POST['name'];
$msg = $_POST['msg'];
$email = $_POST['email'];
$website = $_POST['website'];
$time = time();
$result = mysql_query("SELECT * FROM remember");

	if($step==0 || $step==""){
			echo "Choose your id";

			echo "<form method='POST' action='update.php'>";
			echo "<input type='hidden' value='1' name='step'>";
			echo "ID #:<input type='text' name='id' size=30><br>";
			echo "<input type='submit' value='Update Memo'>";
			echo "</form>";
while($row = mysql_fetch_array($result))
  {
  $name = $row['name'];
  $email = $row['website'];
  $msg = $row['msg'];
		if($step==1){
			//show input
			echo "<b>Remember Information:<br></b>"; 

			//form
			echo "<form method='POST' action='update.php'>";
			echo "<input type='hidden' value='2' name='step'>";
			echo "A Name:<input type='text' name='name' value='$name' size=30><b>*</b><br>";
			echo "An Email:<input type='text' name='email' value='$email' size=30><br>";
			echo "A Website:<input type='text' name='website' value='$website' size=30><br>";
			echo "Memo:<br><textarea cols='30' rows='6' name='msg' wrapping='virtual'>$msg</textarea><b>*</b><br>";
			echo "<input type='submit' value='Update Memo'>";
			echo "</form>";
			echo "* required";
			echo "<br><br><br>Created by <a href='http://smfhost.info'>derrick1123</a>";
		}
	}
	if($step==2){
				//show the thumbs up
				$q = "UPDATE remember SET msg=$msg, name=$name, email=$email, website=$website, time=$time WHERE id=$id";
				$go = mysql_query($q);

				if(!$go){
				echo "SHIT!!! Something went wrong.";
				echo "<br><br><br>Created by <a href='http://smfhost.info'>derrick1123</a>";
				} else {
				echo "YAY!!! Your message got updated!";
				echo "<br><br><br>Created by <a href='http://smfhost.info'>derrick1123</a>";
				}
		}
	}
?>

Link to comment
https://forums.phpfreaks.com/topic/97203-show-only-the-id-chosen-from-db/
Share on other sites

Lets say I want to edit only 1 name...I would select only 1 of the $id. But right now it shows all of them.

 

http://smfhost.info/my_site/remember/update.php <this is were I am having the problem...

http://smfhost.info/my_site/remember/forgot.php <this is the list of ID's

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.