Question:
how do i display mysql data on a form that allows further editing?
2012-07-17 12:31:00 UTC
For my uni db assignment, I have been given the task of creating a form that is CRUD based using mysql database and will store the details below (which Im ok with) and then a user enquiry form to deal with existing problems. When someone calls in, they give their case reference id and this will then pull from the db the case - ie the name of the person, the problem, the state of the issue. My question is, how do I make this information display in the second form in a table format (name/user id/ reference/ problem/ resolved ?etc )which will also allow editing ? I understand it will be php and html but not sure of the correct command to place the db info in the relevant box.
Thanks
Three answers:
Hem Dagar
2012-07-17 12:51:25 UTC
You can do this by dynamically pre-populating the form data, search for how to prepopulate form values, the whole thing is too long to write here, I can give you some idea, you will require all three MYSQL, PHP and HTML



(*This is just an example)



Parse the form data and add information to the system



if (isset($_POST['update'])) {



$pid = mysql_real_escape_string($_POST['thisPID']);

$name = mysql_real_escape_string($_POST['name']);



Then:

Gather the full information for inserting automatically into the form

something like:

if (isset($_GET['pid'])) {

$targetID = $_GET['pid'];

$sql = mysql_query("SELECT .............continue the code here.......") or die (mysql_error());

$Count = mysql_num_rows($sql); // count the output amount



if ($Count > 0) {

while($row = mysql_fetch_array($sql)){



$name = $row["NAME"];

}

} else {

echo "No record found";

exit();

}

}



Then do the form like this:





Hope this helps, Best of Luck!!!
?
2016-10-17 09:09:23 UTC
the information superhighway web site might desire to by no ability connect rapidly with the database, yet with the aid of an middleman language (generally Hypertext Preprocessor.) The HTML style calls the Hypertext Preprocessor application, which formulates an sq. request that gets surpassed to the database. The ensuing tips will come returned to Hypertext Preprocessor, even though it in simple terms returns to the information superhighway web site in case you choose to incorporate it. The person won't be able to see Hypertext Preprocessor source. they are going to in simple terms see the HTML output of the Hypertext Preprocessor. there is not any might desire to record any tips you do no longer choose the viewer to be sure. of course, if there is tips you choose displayed, there is not any thank you to evade that being interior the source. (nicely, i will think of of a few sneaky AJAX tricks, yet something seen to the person will nevertheless be seen interior the source one way or yet another.) once you're apprehensive with regard to the information being transmitted interior the sparkling from the web site to the Hypertext Preprocessor, then you somewhat can inspect no rely in the adventure that your server helps SSL.
Adam Mac
2012-07-17 16:09:04 UTC
set the value of the input field with the desired variable


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...