Jump to content

[SOLVED] Help with array


Zergman

Recommended Posts

Having this as my select box

<select name="validmenu[]" class="inputbox" id="validmenu" size="4" multiple>

 

gives me this using print_r($_GET['validmenu']);

Array ( [0] => Behaviour [1] => Improper Abstract ) 

Those are the two options I selected out of my box

 

sorry bout colors, that was from the origional script :)

 

Link to comment
Share on other sites

Same error as before ... not sure whats going on

 

Warning: implode() [function.implode]: Bad arguments

 

But it does give me sorta the proper output when I echo it :)

Behaviour,Improper Abstract

 

Correct me if im wrong here.  When using IN() in my sql statement, shouldn't the output be more like this?

'Behaviour', 'Improper Abstract'

Link to comment
Share on other sites

Wow, it does (I just tested).  That's really dumb.  They should change that error message to something more descriptive. o_O  Also, why did you go from $_GET['color'] in the original post to $_GET['validmenu']?

 

EDIT: I have an idea of where the message is coming from actually.  Please post your full code for the page.  You might be running it in a loop or something and overwriting whatever you're imploding somehow.  At least that's the best guess I can offer without any other code.

Link to comment
Share on other sites

But it does give me sorta the proper output when I echo it :)

Behaviour,Improper Abstract

 

Sort of?  That looks correct to me!

 

 

 

That output doesn't seem to work in my query.  When I manually enter it into my sql, it works like this.

valid IN ('Behaviour', 'Improper Abstract')

Link to comment
Share on other sites

gah, I hate doing this.  Don't like it when people know how truely stupid I am with all of this  :'(  lol

 

<?php require_once('../Connections/cnt2tracker.php'); ?>
<?php
//MX Widgets3 include
require_once('../includes/wdg/WDG.php');

// Load the tNG classes
require_once('../includes/tng/tNG.inc.php');

// Make unified connection variable
$conn_cnt2tracker = new KT_connection($cnt2tracker, $database_cnt2tracker);

//Start Restrict Access To Page
$restrict = new tNG_RestrictAccess($conn_cnt2tracker, "../");
//Grand Levels: Level
$restrict->addLevel("admin");
$restrict->Execute();
//End Restrict Access To Page

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$date = date ('Y-m-d');
$weekback = date ("Y-m-d", time() - 604800);
$yesterday = date ("Y-m-d", time() - 86400);
$prevmonth = date ('m', prev_month());
$month = date ('m');
$year = date ('Y');
$monthname = date ('F');
$backmonthname = date ('F', prev_month());
$orderedby = $_GET['sortby'];
$lvl2display = $_GET['lvl2'];
$startdate = $_GET['startdatefield'];
$enddate = $_GET['enddatefield'];
$t2agent = $_GET['nsagentfield'];
$flagent = $_GET['frontlineagentfield'];
$conclusion = $_GET['conclusionmenu'];
$conclusioncomments = $_GET['conclusioncomments'];
$prov = $_GET['radio'];
$CBBC = $_GET['BC'];
$valid = $_GET['validmenu'];
$level1 = $_GET['country'];
$level2 = $_GET['state'];
$level3 = $_GET['city'];
$notes = $_GET['notesfield'];

$comma_separated = implode(",", $_GET['validmenu']);
echo $comma_separated;




$colname_rsnamedisplay = "-1";
if (isset($_SESSION['kt_login_user'])) {
  $colname_rsnamedisplay = $_SESSION['kt_login_user'];
}
mysql_select_db($database_cnt2tracker, $cnt2tracker);
$query_rsnamedisplay = sprintf("SELECT * FROM users WHERE uname = %s", GetSQLValueString($colname_rsnamedisplay, "text"));
$rsnamedisplay = mysql_query($query_rsnamedisplay, $cnt2tracker) or die(mysql_error());
$row_rsnamedisplay = mysql_fetch_assoc($rsnamedisplay);
$totalRows_rsnamedisplay = mysql_num_rows($rsnamedisplay);

$colname_rstheme = "-1";
if (isset($_SESSION['kt_login_user'])) {
  $colname_rstheme = $_SESSION['kt_login_user'];
}
mysql_select_db($database_cnt2tracker, $cnt2tracker);
$query_rstheme = sprintf("SELECT * FROM users WHERE uname = %s", GetSQLValueString($colname_rstheme, "text"));
$rstheme = mysql_query($query_rstheme, $cnt2tracker) or die(mysql_error());
$row_rstheme = mysql_fetch_assoc($rstheme);
$totalRows_rstheme = mysql_num_rows($rstheme);

mysql_select_db($database_cnt2tracker, $cnt2tracker);
$query_rsadminsearch = "SELECT * FROM `data` WHERE tdate between '$startdate%' and '$enddate%' AND t2agent LIKE '$t2agent%' AND flagentTID LIKE '$flagent%' AND resolution LIKE '$conclusion%' AND rescomments LIKE '$conclusioncomments%' AND prov LIKE '$prov%' AND valid IN ('$comma_separated') AND level1 LIKE '$level1%' AND level2 LIKE '$level2%' AND level3 LIKE '$level3%' AND notes LIKE '$notes%' ORDER BY tdate";
$rsadminsearch = mysql_query($query_rsadminsearch, $cnt2tracker) or die(mysql_error());
$row_rsadminsearch = mysql_fetch_assoc($rsadminsearch);
$totalRows_rsadminsearch = mysql_num_rows($rsadminsearch);

mysql_select_db($database_cnt2tracker, $cnt2tracker);
$query_rsvalidfield = "SELECT * FROM valid_entries ORDER BY entry ASC";
$rsvalidfield = mysql_query($query_rsvalidfield, $cnt2tracker) or die(mysql_error());
$row_rsvalidfield = mysql_fetch_assoc($rsvalidfield);
$totalRows_rsvalidfield = mysql_num_rows($rsvalidfield);
?>

 

Link to comment
Share on other sites

Here's the rest of the page.  Sorry if it looks a tad messed up, had to remove some stuff that I could get fired over if it was posted outside our network.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wdg="http://ns.adobe.com/addt">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tracker Management</title>

<link href="../css/<?php echo $row_rstheme['theme'] ?>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../includes/common/js/sigslot_core.js"></script>
<script src="../includes/common/js/base.js" type="text/javascript"></script>
<script src="../includes/common/js/utility.js" type="text/javascript"></script>
<script type="text/javascript" src="../includes/wdg/classes/MXWidgets.js"></script>
<script type="text/javascript" src="../includes/wdg/classes/MXWidgets.js.php"></script>
<script type="text/javascript" src="../includes/wdg/classes/Calendar.js"></script>
<script type="text/javascript" src="../includes/wdg/classes/SmartDate.js"></script>
<script type="text/javascript" src="../includes/wdg/calendar/calendar_stripped.js"></script>
<script type="text/javascript" src="../includes/wdg/calendar/calendar-setup_stripped.js"></script>
<script src="../includes/resources/calendar.js"></script>
<link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="sorttable.js" type="text/javascript"></script>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td  width="350" height="70" class="logo1"></td>
    <td  width="350" height="70" class="logo2"></td>
  </tr>
  <tr>
    <td colspan="2"><hr class="style1" /></td>
  </tr>
  <tr>
    <td><div align="left"><a href="main.php">Main</a> | <span class="style1">></span>Search<span class="style1"><</span> | Tracking | <a href="../callDetail.php">Incident Entry</a> | <a href="javascript:;" onclick="MM_openBrWindow('monitor.php','Monitor','status=yes,scrollbars=yes,resizable=yes,width=500,height=70')">Monitor</a> | <a href="admin_users.php">Users</a></div></td>
    <td><div align="right">Welcome Admin <?php echo $row_rsnamedisplay['fname']; ?> <?php echo $row_rsnamedisplay['lname']; ?> | <a href="../pref.php?recordID=<?php echo $row_rsnamedisplay['id']; ?>">Preferences</a></div></td>
  </tr>
</table>
<form id="form1" name="form1" method="get" action="search.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
  <tr>
    <td><div align="right">Start Date :</div></td>
    <td>
      <input name="startdatefield" class="inputbox" id="startdatefield" value="<?php echo $weekback; ?>" wdg:mondayfirst="true" wdg:subtype="Calendar" wdg:mask="<?php echo $KT_screen_date_format; ?>" wdg:type="widget" wdg:singleclick="true" wdg:restricttomask="no" />
      <?php echo $startdate ?>
      <?php if ($totalRows_rsadminsearch > 0) { // Show if recordset not empty ?>
        (Start)
  <?php } // Show if recordset not empty ?></td>
    <td><div align="right">NS Agent :</div></td>
    <td><input name="nsagentfield" type="text" class="inputbox" id="nsagentfield" /> <?php echo $nsagent; ?></td>
    <td><div align="left">AB
      <input type="radio" name="radio" id="AB" value="AB" />
BC
<input type="radio" name="radio" id="BC" value="BC" />
ALL 
<input type="radio" name="radio" id="%" value="%" />
    </div></td>
    </tr>
  <tr>
    <td><div align="right">End Date :</div></td>
    <td><input name="enddatefield" class="inputbox" id="enddatefield" value="<?php echo $date; ?>" wdg:mondayfirst="true" wdg:subtype="Calendar" wdg:mask="<?php echo $KT_screen_date_format; ?>" wdg:type="widget" wdg:singleclick="true" wdg:restricttomask="no" />
      <?php echo $enddate ?>
      <?php if ($totalRows_rsadminsearch > 0) { // Show if recordset not empty ?>
        (End)
  <?php } // Show if recordset not empty ?></td>
    <td><div align="right">Frontline Agent :</div></td>
    <td><input name="frontlineagentfield" type="text" class="inputbox" id="frontlineagentfield" /> <?php echo $flagent; ?></td>
    <td><div align="left">Validity :
        <select name="validmenu[]" class="inputbox" id="validmenu" size="4" multiple>
          <option value="%" selected="selected">All</option>
          <option value="*Valid*">*Valid*</option>
          <option value="Behaviour">Behaviour</option>
          <option value="Improper Abstract">Improper Abstract</option>
          <option value="Improper Route">Improper Route</option>
          <option value="Invalid STN">Invalid STN</option>
          <option value="Kudos">Kudos</option>
          <option value="Other">Other</option>
          <option value="Policy/Procedure">Policy/Procedure</option>
          <option value="Poor Ticket Creation">Poor Ticket Creation</option>
          <option value="Troubleshooting">Troubleshooting</option>
        </select>
    </div></td>
    </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
  <tr>
    <td colspan="2" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><div align="right">Conclusion :</div></td>
        <td><div align="left">
          <select name="conclusionmenu" class="inputbox" id="conclusionmenu">
            <option value="%" selected="selected">All</option>
            <option value="Resolved" >Resolved</option>
            <option value="Dispatched">Dispatched</option>
            <option value="Other">Other</option>
          </select>
        </div></td>
      </tr>
      <tr>
        <td valign="middle"><div align="right">Comments :</div></td>
        <td><div align="left">
          <textarea name="conclusioncomments" class="textarea" id="conclusioncomments" cols="30" rows="3"></textarea>
        </div></td>
      </tr>
      <tr>
        <td valign="top"> </td>
        <td> </td>
      </tr>
      <tr>
        <td><div align="right">Notes :</div></td>
        <td><div align="left">
          <textarea name="notesfield" class="textarea" id="notesfield" cols="30" rows="3"></textarea>
        </div></td>
      </tr>
      <tr>
        <td> </td>
        <td> </td>
      </tr>
    </table></td>
    <td colspan="3"><div align="left">    
      <select name="state" size="10" class="textarea" id="state" onchange="setCities();">
        <option value="" selected="selected"> </option>
      </select>
      
      <select name="city" size="10" class="textarea"  id="city" onchange=" ">
        <option value="" selected="selected"> </option>
      </select>
    </div></td>
    </tr>
  <tr>
    <td valign="top"><div align="right"></div></td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
  <tr>
    <td colspan="5"><div align="center">
      <input type="submit" name="searchbutton" class="button1" id="searchbutton" value="Search" /><input name="resetbutton" type="button" class="button1" id="resetbutton" onclick="MM_goToURL('parent','search.php');return document.MM_returnValue" value="Reset" />
      <?php if ($totalRows_rsadminsearch > 0) { // Show if recordset not empty ?>
        <?php echo $totalRows_rsadminsearch ?> Found 
        <input name="excelexport" type="submit" class="button1" id="excelexport" onclick="MM_goToURL('parent','searchexport.php?startdate=<?php echo $startdate ?>&enddate=<?php echo $enddate ?>&t2agent=<?php echo $t2agent ?>&flagent=<?php echo $flagent ?>&conclusion=<?php echo $conclusion ?>&conclusioncomments=<?php echo $conclusioncomments ?>&prov=<?php echo $prov ?>&valid=<?php echo $valid ?>&level1=<?php echo $level1 ?>&level2=<?php echo $level2 ?>&level3=<?php echo $level3 ?>&notes=<?php echo $notes ?>');return document.MM_returnValue" value="Export to Excel" />
          <?php } // Show if recordset not empty ?>
          
    </div></td>
    </tr>
</table>
</form>

<?php if ($totalRows_rsadminsearch > 0) { // Show if recordset not empty ?>
  <table class="sortable" width="100%" border="0" cellspacing="0" cellpadding="0">
  <thead>
    <tr align="left">
      <th>Date</th>
      <th>T2 Agent</th>
      <th>FL Agent</th>
      <th>Level 1</th>
      <th>Level 2</th>
      <th>Level 3</th>
      <th>Province</th>
      <th>Validity</th>
      <th>Conclusion</th>
      </tr>
    </thead>
    <tbody>
    <?php do { ?>
      <?php
$count++;
if(($count % 2) == 1){
$class = "row0";
} else {
$class = "row1";
}
?>
      <tr class="<?php echo $class; ?>">
        <td width="80" onclick="MM_openBrWindow('main_quick_display.php?recordID=<?php echo $row_rsadminsearch['id']; ?>','QuickDisplay','scrollbars=yes,resizable=yes,width=500,height=400')"><a href="javascript:;"><?php echo $row_rsadminsearch['tdate']; ?></a></td>
        <td width="75"><?php echo $row_rsadminsearch['t2agent']; ?></td>
        <td width="75"><?php echo $row_rsadminsearch['flagentTID']; ?></td>
        <td width="135"><?php echo $row_rsadminsearch['level1']; ?></td>
        <td width="150"><?php echo $row_rsadminsearch['level2']; ?></td>
        <td width="165"><?php echo $row_rsadminsearch['level3']; ?></td>
        <td width="65"><?php echo $row_rsadminsearch['prov']; ?></td>
        <td width="115"><?php echo $row_rsadminsearch['valid']; ?></td>
        <td width="100"><?php echo $row_rsadminsearch['resolution']; ?></td>
        </tr>
      <?php } while ($row_rsadminsearch = mysql_fetch_assoc($rsadminsearch)); ?>
      </tbody>
      <tfoot>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      </tr>
    </tfoot>
  </table>
  <?php } // Show if recordset not empty ?>
  <?php if ($totalRows_rsadminsearch == 0) { // Show if recordset empty ?>
    Please make you selection for search
  <?php } // Show if recordset empty ?>
<?php

function prev_month ( $now = FALSE ) {

if ( !is_numeric($now) )
	$now = time();

# Limit to a single date call to grab our info ( assuming parsing a string is faster than date function )
$data = date( 'n Y j t', $now );
list( $currMonth, $year, $currDay, $currDaysPerMonth ) = explode( ' ', $data );

# Find out the previous month
$prevMonth = $currMonth == 1 ? 12 : $currMonth - 1;

# Find out previous year
$year = $prevMonth == 12 ? $year - 1 : $year;

# Grab the number of days in previous month
$prevDaysPerMonth = date( 't', mktime(0,0,0, $prevMonth, 1, $year) );

# See if today is greater than or the same as the total days in previous month
if ( $currDay >= $prevDaysPerMonth )
	return mktime( 0,0,0, $prevMonth, $prevDaysPerMonth, $year );

# Should be fine from here
return mktime( 0,0,0, $prevMonth, $currDay, $year );

}

# Use it!
#echo date( 'Y-m-d', prev_month() );

?>

<p>
<?php echo $query_rsadminsearch; ?>
</p>

</body>
</html>
<?php
mysql_free_result($rsnamedisplay);

mysql_free_result($rstheme);

mysql_free_result($rsadminsearch);

mysql_free_result($rsvalidfield);

?>

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.