0

i am using following code to insert data into mysql database

<?php
$refselect  = $_POST['refselect'];
$refname    = $_POST['refname'];
$refemail   = $_POST['refemail'];
$refcnt     = $_POST['refcnt'];
$refdes     = $_POST['refdes'];
$referror   = $cberror = "<h1>Data not Added</h1><br/><br/><h3>Please Follow The Instructions</h3>";
$urefdb     = "INSERT INTO refdb(reftype,refname,refemail,refcnt,refdes) VALUES ('$refselect','$refname','$refemail','$refcnt','$refdes');"; 

include_once("db.php");

if ($refselect == "Select Type") die ("$referror");

if (empty ($refname)) die ("$referror");

if (mysql_query("$urefdb"))

{
echo "<h3>One Record Updated Successfully with the following Details </h3><br/>";
echo "Reference Type =$refselect <br/><br/>";
echo "Reference Name = $refname <br/><br/>";
echo "Reference E-Mail = $refemail <br/><br/>";
echo "Reference Description = $refdes <br/><br/>";

}
else
{
echo mysql_error();
}

?>

"refselect" data is coming from a drop down menu at the page now i want that as i add data through this form another form located at another page pic "refname" from database as i update "refdb" that drop down menu pick data accordingly

what to do now ?

2
  • What? It would help if you used more than one sentence to describe what you're doing. Commented Jan 4, 2010 at 17:02
  • Make sure to sanitise the user input! Commented Mar 31, 2011 at 9:26

1 Answer 1

2

You have to fill the dropdown menu on that another page using MySQL select like:

$request = mysql_query("SELECT refselect FROM refdb");

then iterate through all the results to fill your combobox:

echo "<SELECT>";
while ($drow = mysql_fetch_assoc($request))
{
   echo "<OPTION>" . $drow['refselect'] . "</OPTION>";
}
echo "</SELECT>";

Or something like this

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.