在MySQL中,我如何编写变量?

时间:2014-02-20 00:22:42

标签: php mysql

我的php-mysql代码如下所示。

  <?

   $part[0] = htmlspecialchars($_GET['parta']);
   $lang[0] = htmlspecialchars($_GET['langa']);
   $search[0] = htmlspecialchars($_GET['search']);

   $con = mysqli_connect('localhost','root','autoset','my_db');
   if (!$con)
   {
     die('Could not connect: ' . mysqli_error($con));
   }

   mysqli_select_db($con,"ajax_demo");

    $sql = "SELECT code_co.code, code_co.disease_co, code_en.disease_en
    FROM code_co
    LEFT JOIN code_en ON code_en.code = code_co.code
    ...
    LEFT JOIN sx ON code_co.code = sx.code
    CROSS JOIN (
    SELECT CONCAT(  '%', $part[0]_word.$part[0]_en,  '%' ) AS pattern
    FROM $part[0]_word
    WHERE $part[0]_$lang[0] LIKE  '%".$search[0]."%'
    LIMIT 0 , 1
    )const
    WHERE note LIKE const.pattern
    OR ds_content LIKE const.pattern
    .... 
    OR inclusion LIKE const.pattern";
我想知道

$part[0]_word.$part[0]_en$part[0]_word$part[0]_$lang[0] LIKE '%".$search[0]."%'是正确的表达方式吗?

我的结果显示代码与下面相同

  $result = mysqli_query($con,$sql);

   while($row = mysqli_fetch_array($result))
 {
  echo "<table border='1' style='background:#dddddd;border-color:green;'>";

   echo "<tr>";
 echo "<th >"."<form action='search1.php' method='get'>"."<button type='submit' 

  name='code' value='".$row['family']."'>"." Code</th>";
  echo "<th ><a href='".$row['ds_url']."'>"."한국병명</button> </th>";
  echo "<th ><a href='".$row['ds_url']."'>"."Disease name(En.)</a></th>";

 echo "</tr>";
  echo "<tr>";
  echo "<td >" . $row['code'] . "</td>";
  echo "<td >" .$row['disease_co']."</td>";
  echo "<td >" .$row['disease_en']."</td>";

    echo "</tr>";
 echo "</table>";
 }

mysqli_close($con);

以上代码不起作用。我有什么不对劲,但我无法解决。 请给我一点建议。

0 个答案:

没有答案