この質問が多くの場所で尋ねられたことは知っていますが、私が達成しようとしていることは少し異なります。
シナリオ:
変数「id」を使用してMySQLデータベースからホテルデータを取得する/hotel/index.phpページがあります。
私が達成したいのは、たとえば /hotel/index.php?id=1 が /hotel/hotelname/ として表示されることです
私のindex.phpは次のようになります。
<?php
$dbhost = something;
$dbuser = somethingmore;
$dbpass = alotmore;
$hid = $_GET["id"];
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$sql = 'SELECT * FROM hotel where id = .$hid';
mysql_select_db('h_db');
$retval = mysql_query("SELECT * FROM hotel WHERE id='". mysql_real_escape_string( $hid ) ."'", >$conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
if($row['inventory_source']="T") // Check inventory source
{
$hotelid = $row['hotelid_t'];
}
else
{
$hotelid = $row['hotelid_b'];
}
$hotelname = $row['hotel_name'];
$thumbnail = $row['thumbnail'];
$hoteladdress = $row['hotel_address_full'];
$cityname = $row['city'];
$cityid = $row['cityid'];
$country = $row['country_name'];
$propertydesc = $row['property_description'];
$amenities = $row['xmlamenities'];
$checkin = $row['checkin'];
$checkout = $row['checkout'];
$petsallowed = $row['pets_allowed'];
$guestrating = $row['overall_rating'];
$star = $row['star_rating'];
$roomcount = $row['room_count'];
}
これは mod_rewrite を使用して実現できることを知っています。しかし、私はそれを行う方法がわかりません。そこにいるプロからの助けは高く評価されます。