Sunday, July 08, 2018

Seoul Bus Information - TOPIS (html, php)


-- html
<!DOCTYPE html>
<html>
<head>
<title>bus find</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body style="font-size:12;font-family:verdana">
<b>Search "station - topis.db"</b><br>

<form action="search_stname.php" method="post">
정류소ID<input type="text" name="stid"><input type="submit">
</form>

</body>
</html>

-- php

<?php

$stid = $_POST["stid"];
$stname = $_POST["stname"];
$line = $_POST["line"];
//$stname_es = sqlite_escape_string($stname);


// -- 다국어 -- 정류소아이디(stid) - station table
if ( !empty($stid) ) {
   //$dbhandle = sqlite_open('topis.db', 667, $error);
   //$dbhandle = new SQLite3('topis.db', 667, $error);
   $myPDO = new PDO('sqlite:topis.db');
  
   // if (!$dbhandle) die ($error);
   // $stm0 = "select sn, stid, stname, xypos from station where stid = '01003'";
   $stm0 = "select sn, stid, stnmkr, stnmen, stnmcn, stnmjp, note from mlineinfo where stid like '%".$stid."%';";
   $result = $myPDO->query($stm0);
   echo "<br><hr>정류소ID(stid)검색: ".$stm0."<br>";

   //$ok = sqlite_exec($dbhandle, $stm, $error);
   //if (!$ok) die("Error: $error"); 
   //echo "Form submitted successfully";
   echo "<table><tr><td>연번</td><td>정류소ID</td><td>정류소명</td><td>en</td><td>cn</td><td>jp</td></tr>";
   foreach($result as $row) {
      echo "<td>" . $row['sn'] . "</td>";
      echo "<td>" . $row['stid'] . "</td>";
      echo "<td>" . $row['stnmkr'] . "</td>";
      echo "<td>" . $row['stnmen'] . "</td>";
      echo "<td>" . $row['stnmjp'] . "</td>";
      echo "</tr>";
   }
   echo "</table>";
}

?>

No comments:

Pranten

 Pranten