1

所以基本上我正在尝试编写一个 php 脚本,该脚本可以上传到服务器并位于我网站上的某个位置以单击。然后当它被点击时,它会运行 mysql 查询并显示所需的信息......这就是我到目前为止所拥有的。

--Connect.php--

$dbhost = 'localhost';
$dbuser = '******';
$dbpass = '******';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die
        ('Error connecting to mysql');

$dbname = '*****';
mysql_select_db($dbname);

?>

--我需要运行php文件的mysql命令是

SELECT jsfdName.baseData AS Name, 
jsfdAddr.baseData as Address, 
jsfdZip.baseData AS Zip,      
jsfdCity.baseData AS City, 
sfdCounty.baseData AS County, 
jsfdState.baseData AS State
FROM jos_sobipro_field_data AS jsfdName
JOIN jos_sobipro_field_data AS jsfdAddr USING( sid )
JOIN jos_sobipro_field_data AS jsfdZip USING(sid)
JOIN jos_sobipro_field_data AS jsfdCity USING(sid)
JOIN jos_sobipro_field_data AS jfsdCounty USING(sid)
JOIN jos_sobipro_field_data AS jfsdState USING(sid)
WHERE jsfdName.fid = 36 AND jsfdAddr.fid = 37 AND jsfdZip.fid=38 AND jsfdCity.fid = 39 
AND jsfdCounty.fid = 40 AND jsfdState.fid = 41 AND sid > 329

那么如何编写 php 脚本来在我的网站中运行这个文件呢?

谢谢

4

2 回答 2

1

将查询存储在 php 变量中$query='That String'

然后使用它来执行它:

$res=mysql_query($qry);

然后查看每个结果:

while($row=mysql_fetch_assoc($res)) {
    print $row['Name']; }

:)

于 2012-05-05T18:14:32.633 回答
0

我猜你正在寻找这样的东西..

$dbhost = 'localhost';
$dbuser = '******';
$dbpass = '******';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die
    ('Error connecting to mysql');

$dbname = '*****';
mysql_select_db($dbname);

$sql = "SELECT jsfdName.baseData AS Name, 
jsfdAddr.baseData as Address, 
jsfdZip.baseData AS Zip,      
jsfdCity.baseData AS City, 
sfdCounty.baseData AS County, 
jsfdState.baseData AS State
FROM jos_sobipro_field_data AS jsfdName
JOIN jos_sobipro_field_data AS jsfdAddr USING( sid )
JOIN jos_sobipro_field_data AS jsfdZip USING(sid)
JOIN jos_sobipro_field_data AS jsfdCity USING(sid)
JOIN jos_sobipro_field_data AS jfsdCounty USING(sid)
JOIN jos_sobipro_field_data AS jfsdState USING(sid)
WHERE jsfdName.fid = 36 AND jsfdAddr.fid = 37 AND jsfdZip.fid=38 AND jsfdCity.fid = 39 
AND jsfdCounty.fid = 40 AND jsfdState.fid = 41 AND sid > 329
";

$result = mysql_query($sql);

if (!$result) {

echo "An error occurred in processing your    submission."; 
}   
$row=mysql_fetch_array($result);
于 2012-05-05T18:22:10.733 回答