【问题标题】:php find a specify word in a specific column from stored proc sql serverphp 在存储的 proc sql server 的特定列中查找指定单词
【发布时间】:2017-03-24 16:39:18
【问题描述】:

我是 php 的新手,我正在寻找一种方法来从我从 sql server 存储过程中获得的特定列中获取一些单词。这些“词”将我将它们用作我的 css 的样式

示例: HTML_CODE 列有时具有“粗体”、“绿色”或其他内容。有时它们在同一列中,并不总是以相同的顺序。我不知道如何在我的循环中使用它们。看看我到目前为止所拥有的:

    $result = sqlsrv_query($conn, $sql);
while ($row = sqlsrv_fetch_array($result)) 
{
    //print_r( $row );  // debug code
    if ($row['HTML_CODE'] == 'BOLD(), Green()'){
        $couleur='green';
        $font= 'bold';
    }
    else {
        $couleur='black';
        $font= 'normal';
    } 
?>
                            <tbody>
                                <tr>
                                    <?php echo "<tr style=\"font-weight:$font; color:$couleur;\">"; ?>
                                    <td><?php echo ($row['Nom']); ?></td>
                                    <td><?php echo ($row['Quantite']); ?></td>
                                    <td><?php echo ($row['Montant']); if (is_numeric($row['Montant'])) {
                                      echo ' $';
                                    }?></td>
                                    <td><?php echo ($row['#GL']); ?></td>
                                    <td><?php echo ($row['Debit']); if (is_numeric($row['Debit'])) {
                                      echo ' $';
                                    } ?></td>
                                    <td><?php echo ($row['Credit']); if (is_numeric($row['Credit'])) {
                                      echo ' $';
                                    }?></td>
                                </tr>
                            </tbody>

【问题讨论】:

  • 那么,你成功了吗?
  • 是的,使用 "strstr" 如下: if( strstr($row['HTML_CODE'], "BOLD()")){ $font= 'bold'; }

标签: php stored-procedures


【解决方案1】:

if( strstr($row['HTML_CODE'], "BOLD()")){ $font= 'bold'; }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-18
    • 1970-01-01
    • 2012-12-11
    • 2018-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-19
    相关资源
    最近更新 更多