0

我希望从下拉菜单中为我的用户提供一个选项,以选择他们想要运行的查询,然后在单击菜单时触发查询运行。我在想类似的东西......

姓名-----地址----销售人员----完整报告--

因此,例如,如果用户从菜单中单击完整报告选项,它将触发此查询。

'SELECT DISTINCT jsfdName.baseData AS Name, jsfdAddr.baseData as Address, 
jsfdZip.baseData   AS Zip, jsfdCity.baseData AS City, jsfdState.baseData AS State,   
jsfdEmail.baseData AS Email,jsfdPhone.baseData AS Phone, jsfdPerson.baseData AS Person, 
jsfdContacted.baseData AS Contacted
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 jsfdState USING(sid)
JOIN jos_sobipro_field_data AS jsfdEmail USING(sid)
JOIN jos_sobipro_field_data AS jsfdPhone USING(sid)
JOIN jos_sobipro_field_data AS jsfdPerson USING(sid)
JOIN jos_sobipro_field_data AS jsfdContacted USING(sid)
WHERE jsfdName.fid = 36 AND jsfdAddr.fid = 37 AND jsfdZip.fid=38 AND jsfdCity.fid = 39     
AND jsfdState.fid = 41 AND jsfdEmail.fid = 65 AND jsfdPhone.fid = 46 AND jsfdPerson.fid  
= 66 AND jsfdContacted.fid = 63 AND sid > 900';

有任何想法吗?我也试图在一个文件中完成这一切,因为我希望它受到密码保护,以便只有用户才能访问它。谢谢你们的帮助。

4

1 回答 1

2

我假设您了解 php、html 和 sql 的基础知识。我只会告诉你如何选择哪个查询。

对于 html,我将其用于下拉列表:

<select name="report">
    <option value="1">Full Report</option>
    <option value="2">Some Other Report</option>
</select>

您可以根据需要使用不同的值重复此操作。

现在对于 php(选择查询):

<?php
switch($_POST['report']) {
    case "1":
        $query = "SOME QUERY TEXT WOULD GO HERE";
        break;
    case "2":
        $query = "TEXT FOR A DIFFERENT QUERY HERE";
        break;
    default:
        //DO SOMETHING HERE IF THE VALUE IS NOT RECOGNIZED
        break;
}
//NOW RUN THE QUERY WITH $query as the string
?>

您可以根据需要添加任意数量case的 s 以满足您的需要。

于 2012-05-21T16:51:35.587 回答