Jump to content

label in html and php


dbaudais

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...