Jump to content

label in html and php


dbaudais
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...