Jump to content

[SOLVED] Excluding a certain "field" within a PHP script


Airborne328

Recommended Posts

First, I have read the guidelines, and I certainly hope I am going to post/follow them correctly.

 

Summary:

 

I am online gamer that runs a site where players and clans can download a "combined" AC "ac=anticheat org", banlist that will exclude all duplicates.  The script works fine and returns them with a .dat file containing this merged list of players unique guids.  Their are 5 AC's, AASA, ACI, AoN, PsB and PBBans. 

 

Combined_banlist.php

 

<?php
error_reporting(0);
set_time_limit(0);

$link = mysql_connect('************', '********', '********');
if (!$link)
    die('Could not connect: ' . mysql_error());

$db_selected = mysql_select_db('Airborn_repo_site', $link);
if (!$db_selected)
    die ('Unable to select database: ' . mysql_error());
//$Query = "SELECT CONCAT('[', LPAD(year, 4, '0') , '.', LPAD(month, 2, '0'), '.', LPAD(day, 2, '0'), ' ', LPAD(hour, 2, '0'), ':', LPAD(min, 2, '0'), ':', LPAD(sec, 2, '0'), '] ', guid) AS banline FROM `bans` WHERE 1 GROUP BY guid";
$Query = "SELECT CONCAT('[aaorepodepot.us] ', guid) AS banline FROM `bans` WHERE 1 GROUP BY guid";

$result = mysql_query($Query);

if (!$result)
    die("Inable to execute query: " . mysql_error());

Header("Content-Type: application/x-download");
Header("Content-Disposition: attachment; filename=\"combinedACmbl.dat\"");
while ($row = mysql_fetch_assoc($result))
    echo $row['banline'] . "\r\n";

mysql_free_result($result);
mysql_close($link);
?>

 

I have had several requests, to have a separate link/download that would exclude a specific AC.  I have read and read and can't figure out the proper exclude command.

 

__________

 

MySQL info:

 

MySQL client version: 4.1.20

 

Table structure for table bans:

 

CREATE TABLE IF NOT EXISTS `bans` (
  `year` int(11) NOT NULL default '0',
  `month` int(11) NOT NULL default '0',
  `day` int(11) NOT NULL default '0',
  `hour` int(11) NOT NULL default '0',
  `min` int(11) NOT NULL default '0',
  `sec` int(11) NOT NULL default '0',
  `guid` varchar(32) NOT NULL default '',
  `name` varchar(255) NOT NULL default '',
  `ip` varchar(255) NOT NULL default '',
  `reason` varchar(255) NOT NULL default '',
  `ac` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`guid`,`ac`(3)),
  KEY `ac` (`ac`),
  KEY `ip` (`ip`),
  KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

_______________

 

ac field information:

 

SELECT COUNT( * ) AS `Rows` , `ac` 
FROM `bans` 
GROUP BY `ac` 
ORDER BY `ac` 
LIMIT 0 , 30 

 

 

Rows  ac 

41225 AASA

37726 ACI

33523 AON

2357 PBBans

8388 PSB

 

___________________

 

To close,  I have read manual after manual and searched this site for possible answers.  All tries have failed when I try to edit existing php to exclude an ac field.

 

What am I doing wrong/missing, or what can I do to make it right.?  ???

 

Thank you in advance for any assistance, and I certainly hope I followed the guidelines in posting here.

 

Airborne

 

 

Link to comment
Share on other sites

SELECT COUNT( * ) AS `Rows` , `ac` 
FROM `bans`
WHERE ac <> 'AASA' 
GROUP BY `ac` 
LIMIT 0 , 30

 

the above excludes 'AASA'.

 

To exclude multiple values you can

 

SELECT COUNT( * ) AS `Rows` , `ac` 
FROM `bans`
WHERE ac NOT IN ('AASA', 'ACI') 
GROUP BY `ac`  
LIMIT 0 , 30

 

Note: GROUP BY will also ORDER BY the same column by default.

Link to comment
Share on other sites

Okay so,

 

Should the combined_banlist.php query above be edited

 

 

From

 

$Query = "SELECT CONCAT('[aaorepodepot.us] ', guid) AS banline FROM `bans` WHERE 1 GROUP BY guid";

 

To

 

$Query = "SELECT CONCAT('[aaorepodepot.us] ', guid) AS banline FROM 
`bans` WHERE ac <> 'AASA' GROUP BY guid";

 

I hope I am understanding, cause my brain is hurting right about now.... :P

 

TY  8)

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.