doudi2833 2016-06-01 10:50
浏览 74

php回声边框颜色

This seems reletively simple compared to what I have done so far but it doesn't appear to work!

I want to define the border-bottom as a colour that is specified in the database. Lets say for example I want the border colour to be RED.

My row in the db is border_colour and my recordset is recorded as $row_club.

My page layout is as follows:

<?php 
    require_once('../Connections/cl25theuclone.php');

$club_id = $_GET['club_id'];


mysql_select_db($database, $db_table);
$query_club = "SELECT * FROM clubs WHERE club_id=$club_id";
$club = mysql_query($query_club, $cl25theuclone) or die(mysql_error());
$row_club = mysql_fetch_assoc($club);
$totalRows_club = mysql_num_rows($club);
?>
<!DOCTYPE html>
    <head>
        <title></title>
        <style type="text/css">
            #header{
               border-bottom: 15px solid; /* This bit works as per normal */
               border-bottom-color: <?php echo $row_club['border_colour']?>; 
            }
       </style>
    </head>
    <body>
          <div id="header">

          </div>
    </body>
</html>

What is happening is its displaying the border-bottom as 15px and solid but it's just coming out the default black and not the specified value in the mySQL db.

I have so far pulled out all other info from the db using this method without any issues, aswell as creating the dynamic URL.

Any help is greatly appreciated. I want to keep it as simple as possible really

  • 写回答

2条回答 默认 最新

  • dongzhaoshi8497 2016-06-01 11:10
    关注

    Try this:

    <style type="text/css">
            #header{
               border-bottom: 15px solid <?php echo $row_club['border_colour']; ?>; 
            }
    </style>
    

    Or even better:

    <?php $color = $row_club['border_colour']; ?>
    
    <style type="text/css">
                #header{
                   border-bottom: 15px solid <?php echo !empty($color) ? $color : 'red'; ?>; 
                }
     </style>
    
    评论

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本