PHPilliterate Posted February 10, 2008 Share Posted February 10, 2008 I created a DB that has a column visitorTeam and a column homeTeam. I am trying to create a search that will find all records that contain the search. I can easily have it pull the recordset for homeTeam, but I need help with how to make it search and display both $colname_WADAALFL = "-1"; if (isset($_GET['searchTeam'])) { $colname_WADAALFL = (get_magic_quotes_gpc()) ? $_GET['searchTeam'] : addslashes($_GET['searchTeam']); } mysql_select_db($database_schedule, $schedule); $query_WADAALFL = sprintf("SELECT * FROM ALFL WHERE homeTeam = '%s' ORDER BY ID ASC", $colname_WADAALFL); Link to comment https://forums.phpfreaks.com/topic/90415-where-help-needed/ Share on other sites More sharing options...
Barand Posted February 10, 2008 Share Posted February 10, 2008 <?php $query_WADAALFL = sprintf("SELECT * FROM ALFL WHERE ((homeTeam = '%s') OR (awayTeam = '%s')) ORDER BY ID ASC", $colname_WADAALFL, $colname_WADAALFL); Link to comment https://forums.phpfreaks.com/topic/90415-where-help-needed/#findComment-463520 Share on other sites More sharing options...
PHPilliterate Posted February 11, 2008 Author Share Posted February 11, 2008 :'( That didn't work. I restarted the whole thing again... Here is my code. By entering a term in my search field, nothing happens. <?php if (isset($_GET['search']) && $_GET['search'] == "") { $_GET['search'] = "-1"; } ?> <?php if (isset($_GET['S_rainout'])) { $_GET['S_rainout'] = "1"; } ?> <?php if (!session_id()) session_start(); if (isset($_SESSION["ALFL_Results_QueryString"]) && ($_SESSION["ALFL_Results_QueryString"] != "") && !isset($_SERVER["QUERY_STRING"]) ){ header("Location: ALFL_Schedule.php?".str_replace("&totalRows_","&old_totalRows_",$_SESSION["ALFL_Results_QueryString"])); } else{$_SESSION["ALFL_Results_QueryString"] = isset($_SERVER["QUERY_STRING"])?$_SERVER["QUERY_STRING"]:""; } ?> <?php $maxRows_WADAALFL = 20; $pageNum_WADAALFL = 0; if (isset($_GET['pageNum_WADAALFL'])) { $pageNum_WADAALFL = $_GET['pageNum_WADAALFL']; } $startRow_WADAALFL = $pageNum_WADAALFL * $maxRows_WADAALFL; $ParamhomeTeam_WADAALFL = "-1"; if (isset($_GET['search'])) { $ParamhomeTeam_WADAALFL = (get_magic_quotes_gpc()) ? $_GET['search'] : addslashes($_GET['search']); } $ParamvisitorTeam_WADAALFL = "-1"; if (isset($_GET['search'])) { $ParamvisitorTeam_WADAALFL = (get_magic_quotes_gpc()) ? $_GET['search'] : addslashes($_GET['search']); } $Paramrainout_WADAALFL = "0"; if (isset($_GET['S_rainout'])) { $Paramrainout_WADAALFL = (get_magic_quotes_gpc()) ? $_GET['S_rainout'] : addslashes($_GET['S_rainout']); } mysql_select_db($database_schedule, $schedule); $query_WADAALFL = sprintf("SELECT * FROM ALFL WHERE (visitorTeam LIKE '%%%s%%' OR '-1' = '%s') OR (homeTeam LIKE '%%%s%%' OR '-1' = '%s') OR (rainout = %s OR '0' = '%s') ORDER BY ID ASC", $ParamvisitorTeam_WADAALFL,$ParamvisitorTeam_WADAALFL,$ParamhomeTeam_WADAALFL,$ParamhomeTeam_WADAALFL,$Paramrainout_WADAALFL,$Paramrainout_WADAALFL); $query_limit_WADAALFL = sprintf("%s LIMIT %d, %d", $query_WADAALFL, $startRow_WADAALFL, $maxRows_WADAALFL); $WADAALFL = mysql_query($query_limit_WADAALFL, $schedule) or die(mysql_error()); $row_WADAALFL = mysql_fetch_assoc($WADAALFL); Link to comment https://forums.phpfreaks.com/topic/90415-where-help-needed/#findComment-463624 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.