显示网页中突出显示的记录的匹配列

发布于 2024-10-08 03:23:27 字数 410 浏览 0 评论 0原文

我正在尝试使用 CGI 和 postgres 数据库创建基于网络的电话簿搜索。我的选择查询是:

(select * from tel_dir 
 where
   name ~* '$var1' or 
   city ~* '$var1' or
   state ~* '$var1' or
   telno ~* '$var1')
INTERSECT
(select * from tel_dir
 where
   name ~* '$var2' or
   city ~* '$var2' or
   state ~* '$var2' or
   telno ~* '$var2');

连同执行上述查询后获得的结果集,如何获取 $var1 或 $var2 匹配的第一个列名称在获得的每一行中,这样我就可以显示网页中突出显示的列值。

I'am trying to create a web based telephone directory search using CGI and postgres database.My select query is:

(select * from tel_dir 
 where
   name ~* '$var1' or 
   city ~* '$var1' or
   state ~* '$var1' or
   telno ~* '$var1')
INTERSECT
(select * from tel_dir
 where
   name ~* '$var2' or
   city ~* '$var2' or
   state ~* '$var2' or
   telno ~* '$var2');

Along with the result set obtained after executing the above query,how to get the first column name against which $var1 or $var2 matches in each row obtained.so that I can show that column value highlighted in the web page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在梵高的星空下 2024-10-15 03:23:27

从你的问题来看并不太清楚,但假设你可以比较

<?php 
if ($var1 == $var2)
     {
      $cssClass = 'foobar';
     }
?>

你的css的两个值(我将作为php来执行此操作)...

.foobar{
   background-color: #cccccc; /* or any colour you like */
}

在显示结果的网页中...(您将需要引用php或与页面顶部的第一个代码示例类似,您将在其中显示其工作结果)

<div class="<?php echo $cssClass; ?>" >
     <p>matched results output</p>
</div>

It's not too clear from your question but assuming you can compare the two values (I'll do this as php)

<?php 
if ($var1 == $var2)
     {
      $cssClass = 'foobar';
     }
?>

for your css...

.foobar{
   background-color: #cccccc; /* or any colour you like */
}

in your web page where the results are display... (you will need to reference the php or similar as the first code example in the top of the page where you are displaying the results for this to work)

<div class="<?php echo $cssClass; ?>" >
     <p>matched results output</p>
</div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文