User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 455,967 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,741 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2838 | Replies: 2 | Solved
Reply
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

get database values in text box

  #1  
Nov 26th, 2007
i have a form which will display the details in a table,when edit button is clicked all the content in the table should come in a form(ie inside the textboxes)..so that the user can edit and save the content again in the database.
1st page
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
$line = $_GET['name'];

echo "<table width='50%' border='1'>";
$result=mysql_query("SELECT * FROM hi where name='$line'");
for ($i = 0; $i < 1; ++$i)
{
$line = mysql_fetch_row($result);
print "<tr><td>Name</td><td> $line[0]</td></tr>";
print "<tr><td>age</td><td> $line[1]</td></tr>";

}
echo "</table>";


mysql_close($link);
?>
<form method="post" action="red11.php">
<input type="submit" name="submit" value="submit">
</form>


2nd page
echo "<table width='50%' border='1'>";
$result=mysql_query("SELECT * FROM hi where name='$line'");
for ($i = 0; $i < 1; ++$i)
{
$line = mysql_fetch_row($result);

echo '<input type="text" value="'.$_get[name].'">';
?>
Age<input type="text" name="age">
<input type="submit" name="update" value="update">
<?
}
echo "</table>";
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2007
Posts: 23
Reputation: ezb is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
ezb ezb is offline Offline
Newbie Poster

Re: get database values in text box

  #2  
Nov 26th, 2007
Is this meant to be a question or are you simply showing that you can do this?
Reply With Quote  
Join Date: Nov 2007
Location: Arkansas
Posts: 416
Reputation: buddylee17 will become famous soon enough buddylee17 will become famous soon enough 
Rep Power: 3
Solved Threads: 81
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro in Training

Re: get database values in text box

  #3  
Nov 26th, 2007
In order to submit variables to the second page, you'll have to find a way to get them inside of the form on the first page. On the first page, your form is empty, i.e. no variables actually make it in between the <form> and </form> tags. Use your loop to populate the table rows and columns. Then echo or print them into the form similar to this:
  1. <?php
  2. $link=mysql_connect($hostname, $username, $password);
  3. mysql_select_db($dbid) or die("unable to connect");
  4. $line = $_GET['name'];
  5. $result=mysql_query("SELECT * FROM hi where name='$line'");
  6. $content="";
  7. while($row=mysql_fetch_array($result))
  8. {
  9. $strRow=$row[0];
  10. $content .="<tr><td>Name</td><td><input type="text" name="Name" value="$strRow[0]" /> </td></tr> \n";
  11. $content .="<tr><td>age</td><td> <input type="text" name="Age" value="$strRow[1]" /></td></tr>";
  12. }
  13. ?>
  14. <html>
  15. <body>
  16. <form method="post" action="red11.php">
  17. <table width='50%' border='1'>
  18. <?php echo $content;?>
  19. </table>
  20. <input type="submit" name="submit" value="submit">
  21. </form>
  22. </body>
  23. </html>
Last edited by buddylee17 : Nov 26th, 2007 at 5:06 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:08 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC