หัวข้อ: นำข้อมูลจาก mySql-1 ไปค้นหาต่อที่ mySql-2
เริ่มหัวข้อโดย: minmono ที่ 14 มิถุนายน 2018, 19:33:32
สอบถามวิธีการนำข้อมูลที่กรองออกมาจากดาต้าเบสที่1 ไปค้นหาต่อในดาต้าเบสที่2 ครับดาต้าเบสที่1 เป็นเว็บฝากรูปครับ https://github.com/lfiore/upld/ แล้วได้ทำหน้าเว็บสำหรับแสดงรายการรูปภาพล่าสุดออกมาเป็น <?php
require('config.php'); require('common.php');
if (!isset($_SESSION['user'])) { exit_message('You are no authorised to access this page. Please log in.'); }
$user = $_SESSION['user'];
require('db.php');
$page = isset($_POST["page"])? (int) $_POST["page"] : 0; $images = mysqli_prepare($db, 'SELECT `id`, `ext`, `time` FROM `images` WHERE `removed` = "0" ORDER BY `time` desc limit '.$page.', 10 ' );
//mysqli_stmt_bind_param($images, 'i', $user); mysqli_stmt_execute($images); ++$db_queries; mysqli_stmt_store_result($images);
if (mysqli_stmt_num_rows($images) === 0) { exit_message('You haven\'t uploaded any images yet!'); }
mysqli_stmt_bind_result($images, $id, $ext, $time);
require('inc/header.php');
if (!defined('IN_SCRIPT')) { header('location: ../index.php'); exit; }
?>
<div class="box"> <p class="title" style="text-decoration: underline;">Admin Column mode to View All Image</p>
<?php echo'<table style="position: absolute;padding: 0 50px;"><thead> <tr style="background-color: #a4ed34;">'; echo '<th style="width: 200px" scope="col">Image ID</th>'; echo '<th style="width: 200px" scope="col">uploaded</th>'; echo '<th style="width: 80px" scope="col">View</th>'; echo '<th style="width: 200px" scope="col">Search</th>'; echo '</tr></thead>';
while (mysqli_stmt_fetch($images)) { echo '<tr>'; echo '<td>'. $id.'</td>'; echo '<td>'. $time .'</td>'; echo '<td><a target="_blank" rel="follow" href="' .VIEW_PATH . $id .'">GO</a></td>'; echo '<td> </td>'; echo '</tr>'; } echo'</table>'; ?>
<?php
mysqli_stmt_close($images); mysqli_close($db);
?> </div> <?php
(http://postto.me/1s/838.png) ต้องทำอย่างไรครับเพื่อให้นำ Image ID($id) จากรายการ > ไปค้นหาต่อในดาต้าเบสที่2 แล้วแสดงผลการค้นหาออกมาด้านหลังได้เลยไม่ต้องไปกดค้นหาที่ล่ะรายการอีกนะครับ
หัวข้อ: Re: นำข้อมูลจาก mySql-1 ไปค้นหาต่อที่ mySql-2
เริ่มหัวข้อโดย: minmono ที่ 16 มิถุนายน 2018, 21:34:27
แทรกคำสั่งลงไปอีกชุดสั่งเปลี่ยน DB ใหม่ก็ใช้ได้เลยเหรอนี่ :wanwan020:
$connect2 = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME); $images2 = mysqli_prepare($connect2, "SELECT * FROM messages WHERE body like '%" [b]. $id . [/b]"%' ");
mysqli_stmt_execute($images2); ++$db_queries; mysqli_stmt_store_result($images2);
if (mysqli_stmt_num_rows($images2) > 0) { echo'<label> Found </label>'; } else { echo'<a>Not Found </a>'; }
|