Login | Register | FAQ
Anonymous

How to extract data from sql DB into the form

+ Post a reply

3 posts Page 1 of 1


How to extract data from sql DB into the form

by girish.farkade » Tue Feb 21, 2012 8:12 am

Hi All,

I am looking for the solution of following case.
I am trying to get the data from SQL DB in the form fields which i have created in the form. I am able to input through these fields but I also want to retrieve the data in the same form.
Please help me out as soon as possible. I attached the code for input form.

INPUT AND OUTPUT PAGE CODE (MAINPAGE.PHP)

<html>
<head>
<!-- @@@@@@@@@@@@@@@@@@@@@@@@@ date Picker script @@@@@@@@@@@@@@@@@@@@@@@@@@@ -->
<style>

label{

width: 6em;

float: left;

text-align: right;

margin-right: 8em;

display: block

}

</style>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jsDatePick Javascript example</title>

<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />
<!--
OR if you want to use the calendar in a right-to-left website
just use the other CSS file instead and don't forget to switch g_jsDatePickDirectionality variable to "rtl"!

<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.css" />
-->
<script type="text/javascript" src="jquery.1.4.2.js"></script>
<script type="text/javascript" src="jsDatePick.jquery.min.1.3.js"></script>
<!--
After you copied those 2 lines of code , make sure you take also the files into the same folder :-)
Next step will be to set the appropriate statement to "start-up" the calendar on the needed HTML element.

The first example of Javascript snippet is for the most basic use , as a popup calendar
for a text field input.
-->
<script type="text/javascript">
window.onload = function(){
new JsDatePick({
useMode:2,
target:"inputField",
dateFormat:"%Y-%m-%d"
/*selectedDate:{ This is an example of what the full configuration offers.
day:5, For full documentation about these settings please see the full version of the code.
month:9,
year:2006
},
yearsRange:[1978,2020],
limitToToday:false,
cellColorScheme:"beige",
dateFormat:"%m-%d-%Y",
imgPath:"img/",
weekStartDay:1*/
});
};
</script>
<!-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -->
<title>Org Details</title>
</head>
<body>
<form method="post" action="insert5.php">

<h1>Insert the Following Details</h1>
DATE: <input type="text" size="12" name="date" id="inputField" />
<form method="post" action="">
<table cellspacing="35">
<tr><td><font face="verdana,arial" size=-1><Span><strong>Utilization:</strong></Span><td>
<textarea rows="10" cols="50" name= "utilization">

</textarea>
</td></tr>
</table>

<table cellspacing="20">
<tr><td><font face="verdana,arial" size=-1><Span><strong>Weekly Status:</strong></Span><td>
<textarea rows="10" cols="50" name= "weekly_status">

</textarea>
</td></tr>
</table>



<table cellspacing="30">
<tr><td><font face="verdana,arial" size=-1><Span><strong>DESUCCESS:</strong></Span><td>
<textarea rows="10" cols="50" name= "desuccess">

</textarea>
</td></tr>
</table>



<table cellspacing="5">
<tr><td><font face="verdana,arial" size=-1><Span><strong>ACCOMPLISHMENT:</strong></Span><td>
<textarea rows="10" cols="50" name= "accomplishment">

</textarea>
</td></tr>
</table>



<table cellspacing="45">
<tr><td><font face="verdana,arial" size=-1><Span><strong>ONCALL:</strong></Span><td>
<textarea rows="10" cols="50" name= "oncall">

</textarea>
<br><br>
<input type="submit" name="Submit" value="Submit">
</form>
<?php

?>
</body>
</html>



INSERT.PHP



<?php
$con = mysql_connect("localhost","root","Oracle");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("test", $con);

$sql="INSERT INTO empinfo (orgdate, utilization, weekly_status, DE_sucess, accomplishment, oncall)
VALUES
('$_POST[date]','$_POST[utilization]','$_POST[weekly_status]','$_POST[desuccess]','$_POST[accomplishment]','$_POST[oncall]')";


if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";

mysql_close($con)
?>
User avatar

girish.farkade

  • Posts: 1
  • Joined: Tue Feb 21, 2012 7:58 am

Re: How to extract data from sql DB into the form

by zakariadza » Tue Jun 26, 2012 10:38 am

As I understood, you want to get the data from your database and write it in the inputs?
<input type="text" value="<?php echo $data['column']; ?>" />
or
<textarea value="<?php echo $data['column']; ?>"></textarea>
Is that what you want?
User avatar

zakariadza

  • Posts: 24
  • Joined: Wed Oct 12, 2011 9:44 am

Re: How to extract data from sql DB into the form

by XainPro » Wed Jun 27, 2012 5:30 am

connect to Database Server
Select The Database
Query into datbase and use its data in form fields value attribute
just like zakariadza said
<input type="text" value="<?php echo $data['column']; ?>" />

That's what i understand and agreed with zakariadza !
User avatar

XainPro

  • Posts: 3669
  • Joined: Fri Feb 17, 2012 8:10 pm


+ Post a reply

Page 1 of 1