Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. //TV FILTERS
  2. $sql = 'SELECT * FROM `table1`';
  3. $where = array();
  4. if ($searchlocation !== 'Any') $where[] = '`value` LIKE "%'.$searchlocation.'%"';
  5. if ($searchmake !== 'Any') $where[] = '`value` LIKE "%'.$searchmake.'%"';
  6. if ($searchtype !== 'Any') $where[] = '`value` LIKE "%'.$searchtype.'%"';
  7. if (count($where) > 0) {
  8. $sql .= ' WHERE '.implode(' OR ', $where);
  9. } else {
  10. // Error out; must specify at least one!
  11. }
  12.  
  13. $tvqresult = mysql_query($sql);
  14. $num_rowstvq = mysql_num_rows($tvqresult);
  15. while ($rowtvq = mysql_fetch_array($tvqresult)) {
  16. $contid = $rowtvq['contentid'];
  17.  
  18. //MAIN QUERY
  19. $mainsql = 'SELECT * FROM `table2` WHERE `content` LIKE "%' . $searchterm . '%" AND `id` = ' . $rowtvq['contentid'] . ' AND `template` = 12';
  20.  
  21. $resultmain = mysql_query($mainsql);
  22.  
  23. $num_rowsmain = mysql_num_rows($resultmain);
  24. if (!$resultmain) {
  25. continue;
  26. }
  27.  
  28. else {
  29. while ($row = mysql_fetch_array($resultmain )) {
  30. echo "[!Ditto? &parents=`134` &documents=" . $row['id'] . "&tpl=`usedtempchunk`!]";
  31. }//END MAIN LOOP
  32.  
  33. }//END MAIN ELSE
  34.  
  35. }//END TV WHILE LOOP
  36.  
  37. $sql = 'SELECT distinct contentid FROM `table1`'; // rest would be the same
  38.  
  39. $sql = 'SELECT distinct contentid, contentTitle, contentThing FROM `table1`';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement