먼저이 질문이 반복적으로 보이는 경우 사과 드리며 실사를하지 않았습니다. 나는 보통 전에 인터넷을 샅샅이 뒤 지지만, 나는 물어볼 필요가있는 것처럼 느낀다.한 페이지 URL을 검색 기능과 함께 사용
기본적으로 나는 내 지역 도시의 일부 명소를 나열하는 하나의 페이지로 구성된 동적 웹 사이트를 구축하고 있습니다. 그 부분은 내가 괜찮아 - 난 MySQL을 사용하여 데이터베이스를 만들었고, 나는 1 데이터베이스, 각기 다른 ID 이름을 가진 4 개의 테이블이 있습니다.
내 문제는 내 검색은 사용자가 입력 한 것, 즉 명소의 이름으로만 제한되며 실제로 동적 URL에 연결하는 데 어려움이 있습니다 (첫 번째 테이블 루프 쿼리 제외)
아래 코드는 왜 이런 일을하는지 설명합니다. 외부 링크가 될지라도 저에게 누군가가 대답을 할 수 있기를 바랍니다. 나는 가장 감사하고 영원히 빚을 질 것입니다. 그들이 그 결과가 위로 나는 자리에 ?category&fdID=".$results['foodID'];
세트를 가지고 있다는 사실로 인해 식품 N 음료 페이지로 연결됩니다 발견되면
<?php
error_reporting(0);
?>
<?php
mysqli_connect("localhost", "root", "", "everydayleeds") or die(mysqli_error());
mysqli_select_db($con, "everydayleeds") or die(mysqli_error()); /* everydayleeds is the name of database we've created */
$query = $_GET['query']; // 'query' is the variable name given to the $_GET action, which will take whatever is typed into the search box, indicating this via the URL paramater'
$min_length = 3; // You can set minimum length of the query if you want
if(strlen($query) >= $min_length){ // If query length is more or equal minimum length then
$query = htmlspecialchars($query); // This changes characters used in HTML to their equivalents, for example: < to >
$query = mysqli_real_escape_string($con, $query); // Makes sure nobody uses SQL injection
$raw_results = mysqli_query ($con, "SELECT foodndrink.Name AS fdName, nightlife.Name AS nightName, culture.Name AS cultName, placestostay.Name AS pName, foodndrink.fdID AS foodID, nightlife.nightID AS nID, cultID AS cID, placesID AS pID FROM foodndrink, nightlife, culture, placestostay
WHERE (foodndrink.Name LIKE '%".$query."%') OR (nightlife.Name LIKE '%".$query."%') OR (culture.Name LIKE '%".$query."%') OR (placestostay.Name LIKE '%".$query."%') ") OR die (mysqli_error($con));
if(mysqli_num_rows($raw_results) > 0){ // If one or more rows are returned do following
while($results = mysqli_fetch_assoc($raw_results)){ // $results = mysql_fetch_assoc($raw_results) puts data from database into array, while it's valid it does the loop
echo "Yes, we have a".$_GET['query']."<a href=attractions.php?category&fdID=".$results['foodID'];
break;
}
}
else{ // if there is no matching rows do following
echo "<p>Nope, Leeds probably doesn't have a </p>".$_GET['query'];
}
}
else{ // if query length is less than minimum
echo "Minimum length is ".$min_length;
}
?>
그래서, 링크가있는 사용자가 클릭 할 수 있습니다.
나는 루핑을 시도했는데, JOINs, 나는 서클에서 돌아 다니는 것처럼 보였다. 내 문제는 내가 4 개의 서로 다른 ID를 가진 4 개의 다른 테이블을 가지고 있다는 사실입니다.
조언이 있으면 도움을 받으실 수 있습니다.
감사합니다.
같은 예, 코드를 볼 수 없습니다 만들 수 있습니까? 코드 미리보기가 모든 코드를 포착하지는 못했지만 대신 HTML 미리보기를 사용했습니다. – Bilaal