FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » display data from mysql db in text box??
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: display data from mysql db in text box?? [message #169377 is a reply to message #169374] Wed, 08 September 2010 20:04 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
PAkerly wrote:
> I want to create a simple page to edit a record, and when submit is
> clicked I want to update the record.
>
> First I want to display all the data for the record, based on ID, on
> the page
> Here is what I am doing:
>
> <?php
> $txtid= $_POST[txtid];
>
> $sql = "SELECT date, user1, user2, user3, role, id
> FROM myuserdata
> WHERE id= $txtid
> ORDER BY id";
>
> And so then I have text boxes on the page and I want to fill those in
> based on the current ID
>
> I tried to do this:
>
> <input type="text" name="txtdate" id="txtdate" value=<?php echo
> [date];?> />
>
> <input type="text" name="txtuser1" id="txtuser1" value=<?php echo
> [user1];?> />
>
> this did not work. How would I display the actual db fields in the
> textboxes?

$sql = "SELECT date, user1, user2, user3, role, id
FROM myuserdata
WHERE id= $txtid
ORDER BY id";
/* add these bits */

$result=mysql_query($sql);

$date=mysql_result($result,'date',0);
$user1=mysql_result($result,'user1',0);
....etc.

Then
<input type="text" name="txtdate" id="txtdate" value=<?php echo
> $date;?> />

etc..
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Php code for ajax encoding
Next Topic: Re: get_object_vars ($this) and member visibility
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 11:35:55 GMT 2024

Total time taken to generate the page: 0.03665 seconds