Airborne328 Posted October 7, 2008 Share Posted October 7, 2008 ??? Ill start with that smilie and hope I am posting in the correct area... I run and online gaming site that holds within its database 5 AC master banlists. I have a current link/download within the members panel to download combined ALL 5 and have it remove ALL duplicates, np there. I recently got a few requests to be able to download a combined master banlist, excluding 1 of the AC's namely AASA. With the help of Barand, in a "solved" thread here.....That was done successfully , as you can see when viewing the members panel after logging in with "temporary" user and pass information. http://www.phpfreaks.com/forums/index.php/topic,219654.0.html ____________________ I thought it would be more worthy and more friendly usable if I just created a page listing the 5 AC's with checkboxes. That way they could check the ones they wanted added and leave unchecked the ones they did not. Then click on the download button and have it retreive from the DB those checked banlists, of course leaving out any duplicates as before. _________ Thats is where I am out now. I have the temp page up as you can see I had no issues with the simple part...... http://aaorepodepot.us/combinedAC.php user=testaccount pass=testaccount Just click on COMBINED AC BANLIST within the NAV block and login, then click again _________ I am stuck and now cant seem how to figure how ??? to have the checked boxes apply/pulldown from DB the specific banlists upon clicking "download of course leaving out the duplicates" I am only a beginner and read alot I have already posted my DB info, version, table structure etc. but will repost here again for easier reading. MySQL info: MySQL client version: 4.1.20 Table structure for table bans: [select]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]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 With the other php's I did for downloading a combained mbl of all AC's it easier. Now having the check boxes, I am confused how to write it fo reach checked or unchecked. I believe some of wording I need is for example...I just am stuck on how to apply or use it in coding the page for completion/testing. WHERE ac IN ('AC_NAME1', 'AC_NAME2') WHERE ac IN ('AC_NAME1', 'AC_NAME2', 'AC_NAME3') below is a copy/code of the combinedAC.php <?php require("includes/global.php"); mysqlconnect(); $c = RetriveCookie(); if(!CheckLogin($c[0], $c[1])) { header("Location: members.php"); die(); } $page_title = 'AAO Combined AC MBL'; $content = '<div align="center"><strong>AAO Anti-Cheat Organization Master Banlists "Under Construction.!"</strong><br /><br /> <font color="red">Master Banlist downloaded will contain NO duplicates.!</font></div> <br> <br> <style type="text/css"> <!-- .style1 {color: #0099FF} .style2 {color: #FF0000} .style3 {color: #FFFFFF} .style4 {color: #FFFF00} .style5 {color: #00FF00} --> </style> <table width="90" border="0" cellpadding=" "> <tr> <td><input type="checkbox" name="AASA"> <span class="style1">AASA</span></td> </tr> <tr> <td><input type="checkbox" name="ACI"> <span class="style2">ACI</span></td> </tr> <tr> <td><input type="checkbox" name="AON"> <span class="style3">AON</span></td> </tr> <tr> <td><input type="checkbox" name="PsB"> <span class="style4">PsB</span></td> </tr> <tr> <td><input type="checkbox" name="PBBans"> <span class="style5">PBBans</span></td> </tr> </table> <br /> <br /> <table width="100" border="0" cellpadding=" "> <tr> <td width="43"><input type="submit" name="submit" value="Download"></td> </tr> </table> <table width="125" border="0" cellpadding=" " bordercolor="#7A7B51"> <tr> <td></td> </tr> </table>'; include('template.php'); ?> Thanks in advance for any assistance on this. Now I am wishing maybe you guys had a paid to do section.... Quote Link to comment https://forums.phpfreaks.com/topic/127433-solved-downloading-database-information-based-on-checked-or-unchecked-boxes/ Share on other sites More sharing options...
Barand Posted October 7, 2008 Share Posted October 7, 2008 sample code processing checkboxes to build query <?php if (isset($_POST['ac'])) { $aclist = join ("','" , $_POST['ac']); $sql = "SELECT ac, COUNT(*) as total FROM bans WHERE ac IN ('$aclist')"; GROUP BY ac echo '<pre>', $sql, '</pre>'; // view the query } ?> <form method='post'> Choose ac/s <br/> AASA <input type="checkbox" name="ac[]" value="AASA"> <br/> ACI <input type="checkbox" name="ac[]" value="ACI"> <br/> AON <input type="checkbox" name="ac[]" value="AON"> <br/> PBBans <input type="checkbox" name="ac[]" value="PBBans"> <br/> PSB <input type="checkbox" name="ac[]" value="PSB"> <br/> <input type="submit" name="btnSubmit" value="Submit"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/127433-solved-downloading-database-information-based-on-checked-or-unchecked-boxes/#findComment-659397 Share on other sites More sharing options...
Airborne328 Posted October 8, 2008 Author Share Posted October 8, 2008 Thanks. Question #1, what is the connector between the php coding and the form fields and download button. If say AASA and PSB are only checked, what in that coding sees that.? ??? Unless I am missing the obvious.... Question #2 Would be simple to add the following to the end of that php coding to bring forward a combined file for downloading, example. 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); So it would look like this...? <?php if (isset($_POST['ac'])) { $aclist = join ("','" , $_POST['ac']); $sql = "SELECT ac, COUNT(*) as total FROM bans WHERE ac IN ('$aclist')"; GROUP BY ac echo '<pre>', $sql, '</pre>'; // view the query } 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); ?> Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/127433-solved-downloading-database-information-based-on-checked-or-unchecked-boxes/#findComment-659504 Share on other sites More sharing options...
Barand Posted October 8, 2008 Share Posted October 8, 2008 Question #1, what is the connector between the php coding and the form fields and download button. If say AASA and PSB are only checked, what in that coding sees that.? ??? Unless I am missing the obvious.... $_POST['ac'] contains an array of checked values Quote Link to comment https://forums.phpfreaks.com/topic/127433-solved-downloading-database-information-based-on-checked-or-unchecked-boxes/#findComment-659679 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.