Jump to content

"WHERE" help needed


PHPilliterate

Recommended Posts

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
Share on other sites

:'( 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.