我想打印一个名为“res_properties”的表格的内容,以大致了解我的投资组合,但不知道语法(PHP 了解我,但我不了解 PHP...):
我有一个名为“res_properties”的表和一个名为“location_id”的列,还有一个名为“res_location”的表和两个名为“id”和“slug”的列,其中“slug”列包含该位置的人类可读内容
样本“id”是“3”,等于“California”(“slug”的内容)“id”是“4”,等于“Virginia”(“slug”的内容)等等。
打印时我需要查找表'res_location'并且当'location_id'等于'id'然后用'slug'的内容替换'id'(或将'slug'的内容移动到一个新字段中,例如'location_name '(25 个字符)并打印该字段。
到目前为止,我的代码是这样的,我感谢任何帮助。非常感谢:
<html>
<head>
<title>Portfolio</title>
</head>
<link rel="stylesheet" type="text/css" href="../scripts/css/formate.css" />
<body>
<?php
// Connects to Database
mysql_connect("localhost","user","passw") or die(mysql_error());
mysql_select_db("db_name") or die(mysql_error());
$data = mysql_query("SELECT * FROM res_properties");
$location = mysql_query("SELECT * FROM res_locations")
or die(mysql_error());
Print "<table border cellpadding=3>";
Print "<br><h3>Portfolio</h3><p><br>";
Print "<table border cellpadding=3>";
Print "<tr align='left'><th width=130>Villa Name</th><th width=40>Beds</th><th width=40>Baths</th><th width=60>Sleeps</th><th width=40>Location</th><th width=40>Loc-ID</th><th width=300 >Site URL</th></tr>";
while($info2 = mysql_fetch_array( $location ))
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<td>".$info['ref_id'] . "</td> ";
Print "<td>".$info['bedrooms'] . " </td>";
Print "<td>".$info['bathrooms'] . " </td>";
Print "<td>".$info['max_occupants'] . " </td>";
Print "<td>".$info2['slug'] . " </td>";
Print "<td>".$info2['id'] . " </td>";
// here I want to print a clickable URL but some syntax error:
// Print "<td>" http://www.domain_name.com/'.$info['slug'] .'.html;
// when using the echo command it works fine like this, but doesn't output a clickable URL:
// echo 'http://www.domain_name.com/'.$info['slug'] .'.html' . "<br />";
}
Print "</table>";
?>
</body>
</html>