Could someone please point me towards a good tutorial on how to most effectively retreive data from my MySql databases and place it in a form for editing. I've done a search and maybe I just don't know how to phrase it, but I don't really see anything.
Thank you
Retreiving data and placing it in a form for editing
Moderator: General Moderators
-
PastorHank
- Forum Contributor
- Posts: 117
- Joined: Sat Jun 03, 2006 7:58 am
- Location: Texas Hill Country
- andym01480
- Forum Contributor
- Posts: 390
- Joined: Wed Apr 19, 2006 5:01 pm
1) Connect to your database
2) Get the data you want
Output to a form
The hard bit is working out what $query should contain to access one line of data from the database
Try googling "mysql select tutorial" there are plenty around!
2) Get the data you want
Code: Select all
$query="SELECT * from database_table WHERE criteria_is_met"; //make a query that will return one result from the mysql database
$result=mysql($query)or DIE ("Couldn't get a result");//do the search
$row=mysql_fetch_assoc($result);//put the result into an associative arrayCode: Select all
echo "<form action=\"processpage.php\" method=post>";
echo "<input type=text name=whatever value=\"$row[whatever]\"><br>";//puts the data from column whatever into a text box for editing, must be double quoted or only one word will appear!
echo "<textarea name=whatever1>$row[whatever1]</textarea><br>"; //puts the data from whatever1 column into a textarea box for editing
echo "<input type=submit value=submit></form>";Try googling "mysql select tutorial" there are plenty around!
-
PastorHank
- Forum Contributor
- Posts: 117
- Joined: Sat Jun 03, 2006 7:58 am
- Location: Texas Hill Country
-
PastorHank
- Forum Contributor
- Posts: 117
- Joined: Sat Jun 03, 2006 7:58 am
- Location: Texas Hill Country
I've got most of it working except for being able to put data into a drop-down box.
I select all the data and then
Gives me the drop down, but no data. there's no filter on the data, so all records should be showing up.
I select all the data and then
Code: Select all
echo "<form action='cgi-bin/getprocesstoedit.php' method=post>";
echo "<select name='fawnlist'>";
while ($row = mysql_fetch_array($result)) {
extract($row);
echo "<option value=$row[deernumber]><br>\n";
}
echo "</select>";
echo "<input type=submit value=submit>";
echo "</form>";-
PastorHank
- Forum Contributor
- Posts: 117
- Joined: Sat Jun 03, 2006 7:58 am
- Location: Texas Hill Country