dbaudais Posted April 30, 2007 Share Posted April 30, 2007 Hi there and good morning, I am looking for a way to dynamically populate a label in HTML. A snippet of my code is: <label> $Descr </label>I would like to be able to have the contents of $Descr be displayed on the webpage inbetween the label closing and opening tags.I will pull the $Descr from a database using php and place the description into the $Descr variable.Any help would be appreciated in solving this problem.Thanks.David. Link to comment Share on other sites More sharing options...
astralaaron Posted April 30, 2007 Share Posted April 30, 2007 Hi there and good morning, I am looking for a way to dynamically populate a label in HTML. A snippet of my code is: <label> $Descr </label>I would like to be able to have the contents of $Descr be displayed on the webpage inbetween the label closing and opening tags.I will pull the $Descr from a database using php and place the description into the $Descr variable.Any help would be appreciated in solving this problem.Thanks.David.you want to store informormation in the variable $Descr from a database? Link to comment Share on other sites More sharing options...
astralaaron Posted April 30, 2007 Share Posted April 30, 2007 If i understood your question correctly I think this is all you need <?phpmysql_connect("host", "username", "password") or die("cannot connect");mysql_select_db("database")or die("cannot select db");$sql="SELECT * FROM tablename";$result=mysql_query($sql);$rows=mysql_fetch_array($result);$Descr = $rows['descr'];mysql_close()?><html><body><label><?php echo $Descr ?></label></body></html> this is assuming you have a database named 'database' and a table named 'tablename' and a field on that table named 'descr'.of course you can call that stuff whatever you want Link to comment Share on other sites More sharing options...
dbaudais Posted May 1, 2007 Author Share Posted May 1, 2007 Thanks a lot, this worked just fine. Link to comment Share on other sites More sharing options...
astralaaron Posted May 1, 2007 Share Posted May 1, 2007 Thanks a lot, this worked just fine.no problem!do you need a form on your page that will update that field? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.