it dsplays correct data from the database in this format:
abc33bar avenue
which refer to (name abc, location 33bar avenue ).
how make it like this?
name : (here is the dynamic data -name- from database)
location : location
I have construct a textfield with inital value like this :
echo <input name="name" type="text" value="<?php echo $entry['name']; ?>"> ;
however it doesn't work.
thanks for your help
Last edited by peter_budo; Jun 11th, 2009 at 7:51 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
according to me there will be no need of while loop here. bec. here only i row is coming from database according to your condition it should be like this:
like this you can do as per your requirement if you want fetch only one row that time no need of while loop ok $entry=mysql_fetch_array($query);
Thanks
mysql_connect("host", "user", "pwd") or die(mysql_error());
mysql_select_db("dbName") or die(mysql_error());
// Query some data from the MySQL database
$sql = "SELECT field1, field2 FROM myTable";
$result = mysql_query($sql) or die(mysql_error());
// Display the results of the query
while($row = mysql_fetch_assoc($result)){
echo$row['field1'], " - ";
echo$row['field2'], "<br />";
}
?>
If you want to put the fields in <input> or <textbox> tags, simply alter the echo statements on lines #12 and #13 to reflect what you want to print.
Like:
mysql_connect("host", "user", "pwd") or die(mysql_error());
mysql_select_db("dbName") or die(mysql_error());
// Query some data from the MySQL database
$sql = "SELECT field1, field2 FROM myTable";
$result = mysql_query($sql) or die(mysql_error());
// Display the results of the query
while($row = mysql_fetch_assoc($result)){
echo$row['field1'], " - ";
echo$row['field2'], "<br />";
}
?>
If you want to put the fields in <input> or <textbox> tags, simply alter the echo statements on lines #12 and #13 to reflect what you want to print.
Like:
Thanks Atli, You answered my question. I wanted to display the result in textbox or textarea. The dynamic data from the database was displayed before but not in proper textbox.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.