简体   繁体   中英

Value from database into html

I am a beginner to programming in PHP and HTML. I have made a progress bar in CSS and HTML which works great, but I want the pixels of the progress bar to be a value from my database. I got a database with one row and one value.

This is the code I have for the progress bar:

<div id="bar4" style="height: 50px;">
  <span style="width: 200px;"></span>
</div>

Is it possible to change the current value (the 200 in 200px ) to a value from my database? I have made a PHP file which echo the value which I thought might make the process easier.

you can change. Just assume, you are fetching width from database in a variable $widthVal. Then you have to use something like this

<div id="bar4" style="height: 50px;"> <span style="width: <?php echo $widthVal; ?>px;"></span>
<div id="bar4" style="height: 50px;"><span style="width: <?php HERE GOES YOUR PHP CODE THAT ECHO THE 200 ?>px;"></span>

用PHP扩展名保存文件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM