PHP MySQL数据库多重过滤(PHP MySQL Database multi filtration)
所以我有一个包含大量属性的表,并将它们显示在网页上。 由于我们的产品范围很广,我开发了一种过滤系统。 但是,在使用时,您只能选择一个标签,但我们希望以某种方式设计它,以便您可以选择一个标签,然后选择另一个标签。 我目前的代码如下。
<h3>Advanced Search:</h3> <table> <tr> <td colspan="2" style="vertical-align: top; width:50%; !important;"> <h3>Location</h3> <div> <a href="webpropertyloc.php?loc=Alsancak" data-ajax="false" class="ui-btn">Alsancak</a> <a href="webpropertyloc.php?loc=Karsiyaka" data-ajax="false" class="ui-btn">Karsiyaka</a> <a href="webpropertyloc.php?loc=Lapta" data-ajax="false" class="ui-btn">Lapta</a> <a href="webpropertyloc.php?loc=Kayalar" data-ajax="false" class="ui-btn">Kayalar</a> <a href="webpropertyloc.php?loc=Sadrazamkoy" data-ajax="false" class="ui-btn">Sadrazamkoy</a> <a href="webpropertyloc.php?loc=Camlibel" data-ajax="false" class="ui-btn">Cambeli</a> <a href="webpropertyloc.php?loc=Baspinar" data-ajax="false" class="ui-btn">Baspinar</a> <!--<a href="property.php?loc=" data-ajax="false" class="ui-btn"></a> <a href="property.php?loc=" data-ajax="false" class="ui-btn"></a> <a href="property.php?loc=" data-ajax="false" class="ui-btn"></a>--> </div> </td> <td style="vertical-align: top; width:25%;"> <h3>Number of Bedrooms</h3> <div> <a href="webpropertybed.php?bed=1" data-ajax="false" class="ui-btn">1</a> <a href="webpropertybed.php?bed=2" data-ajax="false" class="ui-btn">2</a> <a href="webpropertybed.php?bed=3" data-ajax="false" class="ui-btn">3</a> <a href="webpropertybed.php?bed=4" data-ajax="false" class="ui-btn">4</a> </div> </td>
然后继续使用另外几个选项,然后页面上的代码如下:
<h1>Properties</h1> <?php $loc = $_GET["loc"]; $con = mysql_connect("localhost","Username","Password"); mysql_selectdb("db",$con); $sql = "SELECT * FROM Properties WHERE Location='$loc' ORDER BY `Properties`.`Price` ASC"; $mydata = mysql_query($sql,$con); echo "<h4>Location:" . $loc . "</h4><br>"; while($record = mysql_fetch_array($mydata)){ echo "<div id=\"property\">" . "<img src=\"images/" . $record['MainPic'] . "\" id=\"propimg\" align=\"left\">" . "<div id=\"text\" style=\"text-align: center; margin-right:20px;\"><h2>" . $record['Title'] . "</h2>" . $record['Ref'] . "<br/>" . "£" . $record['Price'] . "<br/>" . $record['Location'] . "<br/>" . "<a href=\"property_view.php?id=" . $record['ID'] . "\" data-ajax=\"false\" class=\"ui-btn\" id=\"button\">Details</a></div>" . "<img src=\"images/bottom-line.png\" id=\"bottomline\"></div>" . "</div>" ; } mysql_close($con); ?>
任何帮助都会受到极大的欢迎。 提前致谢!
So I have a table with a whole load of properties and have displayed them on a webpage. As we have a wide range I developed a filtration system. However when used you can only select one tag, but we want to devise it in a way so that you can select one tag and then another. My current code is as follows.
<h3>Advanced Search:</h3> <table> <tr> <td colspan="2" style="vertical-align: top; width:50%; !important;"> <h3>Location</h3> <div> <a href="webpropertyloc.php?loc=Alsancak" data-ajax="false" class="ui-btn">Alsancak</a> <a href="webpropertyloc.php?loc=Karsiyaka" data-ajax="false" class="ui-btn">Karsiyaka</a> <a href="webpropertyloc.php?loc=Lapta" data-ajax="false" class="ui-btn">Lapta</a> <a href="webpropertyloc.php?loc=Kayalar" data-ajax="false" class="ui-btn">Kayalar</a> <a href="webpropertyloc.php?loc=Sadrazamkoy" data-ajax="false" class="ui-btn">Sadrazamkoy</a> <a href="webpropertyloc.php?loc=Camlibel" data-ajax="false" class="ui-btn">Cambeli</a> <a href="webpropertyloc.php?loc=Baspinar" data-ajax="false" class="ui-btn">Baspinar</a> <!--<a href="property.php?loc=" data-ajax="false" class="ui-btn"></a> <a href="property.php?loc=" data-ajax="false" class="ui-btn"></a> <a href="property.php?loc=" data-ajax="false" class="ui-btn"></a>--> </div> </td> <td style="vertical-align: top; width:25%;"> <h3>Number of Bedrooms</h3> <div> <a href="webpropertybed.php?bed=1" data-ajax="false" class="ui-btn">1</a> <a href="webpropertybed.php?bed=2" data-ajax="false" class="ui-btn">2</a> <a href="webpropertybed.php?bed=3" data-ajax="false" class="ui-btn">3</a> <a href="webpropertybed.php?bed=4" data-ajax="false" class="ui-btn">4</a> </div> </td>
And it goes on with another few options the code then on the page is as follows:
<h1>Properties</h1> <?php $loc = $_GET["loc"]; $con = mysql_connect("localhost","Username","Password"); mysql_selectdb("db",$con); $sql = "SELECT * FROM Properties WHERE Location='$loc' ORDER BY `Properties`.`Price` ASC"; $mydata = mysql_query($sql,$con); echo "<h4>Location:" . $loc . "</h4><br>"; while($record = mysql_fetch_array($mydata)){ echo "<div id=\"property\">" . "<img src=\"images/" . $record['MainPic'] . "\" id=\"propimg\" align=\"left\">" . "<div id=\"text\" style=\"text-align: center; margin-right:20px;\"><h2>" . $record['Title'] . "</h2>" . $record['Ref'] . "<br/>" . "£" . $record['Price'] . "<br/>" . $record['Location'] . "<br/>" . "<a href=\"property_view.php?id=" . $record['ID'] . "\" data-ajax=\"false\" class=\"ui-btn\" id=\"button\">Details</a></div>" . "<img src=\"images/bottom-line.png\" id=\"bottomline\"></div>" . "</div>" ; } mysql_close($con); ?>
Any help would be greatly received. Thanks in advance!
原文:https://stackoverflow.com/questions/28726751
最满意答案
您应该使用自定义函数来交换列表中的两个节点,而不是复制节点的每个结构成员。
void swap(struct client *a, struct client *b) { a->prev->next = b; b->prev = a->prev; b->next->prev = a; a->next = b->next; a->prev = b; b->next = a; }
You should use a custom function to swap two nodes in your list instead of copy each struct member of the node.
void swap(struct client *a, struct client *b) { a->prev->next = b; b->prev = a->prev; b->next->prev = a; a->next = b->next; a->prev = b; b->next = a; }
相关问答
更多-
你的插入函数看起来应该是这样的 void Insert(struct StudentRecords Record) { struct Node* newNode = GetNewNode(Record); struct Node *tmp = head; /* Check if we need to insert at head */ if (head==NULL) { head = newNode; return; } /* Check if new node ...
-
您应该使用自定义函数来交换列表中的两个节点,而不是复制节点的每个结构成员。 void swap(struct client *a, struct client *b) { a->prev->next = b; b->prev = a->prev; b->next->prev = a; a->next = b->next; a->prev = b; b->next = a; } You should use a custom function to swa ...
-
用c ++对链表进行排序(Sorting a linked list in c++)[2023-10-13]
滑动链表的更简单方法是这样的: for (node *current = head; current != nullptr; current = current->next) { // This will run through all of the nodes until we reach the end. } 并滑动到倒数第二个项目(确保node->next存在)如下所示: for (node *current = head; current->next != nullptr; current ... -
在c中对双向链表进行排序(Sorting doubly linked list in c)[2022-02-15]
您未正确实现合并排序,该排序基于递归地将列表分为两部分,对它们进行排序并合并结果。 但是在你的代码中,你并没有真正将列表分成两半。 注意在行中: while((head_two != NULL) && (head_two->next != NULL)) { head = head->next; head_two = head->next->next; } head_two = head->next; head->next = NULL; 当head_two到达列表末尾时退出while循环: ... -
部分问题是 while ((aux->prox!=NULL)||(aux->prox->time<=time)) 我猜你的意思 while ((aux->prox!=NULL)&&(aux->prox->time<=time)) 我没有寻找其他问题。 再见, 弗朗西斯 Part of the problem is while ((aux->prox!=NULL)||(aux->prox->time<=time)) I guess you meant while ((aux->prox!=NULL)&&(au ...
-
排序例程,通过比较来决定之前或之后的内容。 如果在函数中进行比较,则元素的顺序由返回确定(例如,小于零(通常为-1 ),零,大于零(通常为1的返回))。 如果要对主要参数进行排序并遇到等效项,请按辅助字符串进行比较,并将这些结果用于展示位置。 在大多数情况下,比较函数将采用指向要比较的每个节点的void指针。 通过这种方式,您可以访问sort函数中的主要和次要字符串。 如果第一次比较的结果等于零,则在sort函数中包含二次比较,并根据该二次比较的结果返回( -1, 0, 1 )。 A sort routin ...
-
这是合并排序链表的传统和最快方法。 它是一种自下而上的样式合并排序,它使用指向节点的指针数组来保存中间列表,其中array [i]为null或指向列表,其中2表示power i节点。 原始列表中的节点合并到数组中,然后合并阵列中的列表以形成单个排序列表。 HP / Microsoft C ++ STL std :: list :: sort使用相同的算法。 /* prototype */ NODE * MergeLists(NODE *pSrc1, NODE *pSrc2); /* sort list u ...
-
单个圆形链表排序(Sorting singly circular linked list)[2021-09-13]
在分析提供的源代码时,建议的排序算法非常接近预期的“选择排序算法” 。 存在两个嵌套循环,但是执行独立功能。 步骤1 - 通过包括从第一个循环到第二个循环的条件来执行真正的嵌套循环。 要对所有列表进行排序,选择将从索引的下一个节点开始。 for(index = head; index -> next != head; index = index -> next) { // start the selection from the index->next for(selection = ind ... -
C:链表的递归排序(C: Recursive sorting of linked list)[2022-01-07]
像这样解决 Node *sort_ll(Node* head){ if(head == NULL || head->next == NULL) return head;//There is no need for processing int max = head->data; Node *prev = head; Node *to_move = NULL; Node *tmp = head->next; //find maximum va ... -
排序链表问题(Sorting a linked list issue)[2022-03-12]
问题出在你的find_mid函数上。 如果使用仅包含两个节点的链接列表对其进行测试,您会看到它返回最后一个节点而不是第一个节点。 例: list = ListNode.new(4, ListNode.new(3)) res = find_mid(list) puts res.val # It would print 3 因此,列表将不再缩小,代码将永远或实际上使用大小为2的链表重复递归,直到堆栈太深错误 。 然后解决方案是按如下方式更改功能: def find_mid(head) return n ...