用php输出额外的sql结果数据

时间:2014-04-16 15:38:06

标签: php

我在打印从我的数据库中获取的其他数据时遇到问题。

代码原样:

<?php
include 'connect.php';
error_reporting(0);
if(isset($_POST['search'])) {
$searchquery = $_POST['search'];
$searchquery = preg_replace("#[^0-9a-z]#i","",$searchquery);


$query = mysql_query("SELECT * FROM tbl_venues WHERE venue_name LIKE '%$searchquery%' OR venue_adress LIKE '%$searchquery%'") or die("Search failed!");
$count = mysql_num_rows($query);
if($count == 0){
    $output = 'No results found!';
    }else{
        while($row = mysql_fetch_array($query))
        {
            $vname = $row['venue_name'];
            $vadress = $row['venue_adress'];
            $id = $row['venue_id'];
            $type = $row['venue_type'];


            $output .= sprintf('<div id="searched"><a href="venue.php?venue=%d">%s</a></div>',
               $row['venue_id'],$vname);
        }
    }

}
?>

我输出并链接了venue_name或$ vname,但也想要$ vadress和其他人。 它必须在输出行上完成,我想显示的不仅仅是已经显示示例的$ vname:

$output .= sprintf('<div id="searched"><a href="venue.php?venue=%d">%s</a></div>',
               $row['venue_id'],$vname, $vadress, $type);

上述不起作用

任何人都可以提供帮助,谢谢

0 个答案:

没有答案