tDC Posted December 11, 2006 Share Posted December 11, 2006 Hey AllIm new here :) So hey lolJust a quickie - Im quite a PHP n00b, and i have a problem i need fixing..On a section in my website i have a huge list of files/links displayed on a php page, all of which have a checkbox next to them,I get about 2000 a day and i have to manually select every, single, checkbox.. Which as you can guess i gave up after about 1000.I need evey box checked and then i click ok and its done, but there's no select all option.Any idea's about how when i visit the page all the box's are checked as default?TIA ;D Link to comment https://forums.phpfreaks.com/topic/30244-checkbox-question/ Share on other sites More sharing options...
kenrbnsn Posted December 11, 2006 Share Posted December 11, 2006 Can you post the code that's generating the form?Ken Link to comment https://forums.phpfreaks.com/topic/30244-checkbox-question/#findComment-139067 Share on other sites More sharing options...
simcoweb Posted December 11, 2006 Share Posted December 11, 2006 http://www.phpfreaks.com/quickcode/Checking-all-checkboxes-in-a-form/311.php Link to comment https://forums.phpfreaks.com/topic/30244-checkbox-question/#findComment-139069 Share on other sites More sharing options...
tDC Posted December 11, 2006 Author Share Posted December 11, 2006 Thanks for your quick replies :)[code] function que($go) { global $list; $check_first = 1; if ($go == "Insert") { $this->max_dl--; $tabellen = $this->mysql_tb_dl; $hvahvor = $this->run($list); $dato = $this->dato(); $g_antall = mysql_query("SELECT COUNT(id) AS TOTAL FROM $tabellen"); $antall = mysql_result($g_antall,0); $antallet = $antall+count($title); if ($antallet > $this->max_dl && $this->max_dl > 0) { $max_limit = $antall-$this->max_dl; $max_get = mysql_query("SELECT * FROM $tabellen ORDER BY id DESC"); while ($max_row = mysql_fetch_row($max_get)) { $max_id[] = $max_row[0]; } for ($i=0; $i<count($max_id); $i++) { if ($i == 0) $max_query = "WHERE id = '".$max_id[$i]."'"; else $max_query .= " || id = '".$max_id[$i]."'"; } mysql_query("DELETE FROM $tabellen $max_query"); } $get = mysql_query("SELECT * FROM $this->mysql_tb_que WHERE $hvahvor"); mysql_query("DELETE FROM $this->mysql_tb_que WHERE $hvahvor"); echo "<b>".count($list)." downloads inserted to database!</b>"; while ($row = mysql_fetch_array($get)) { mysql_query("INSERT INTO $this->mysql_tb_dl (type, title, url, sname, surl, date, email) VALUES ('$row[type]','$row[title]','$row[url]','$row[sname]','$row[surl]','$dato','$row[email]')"); } echo "<br><br><a href=\"javascript:history.go(-1)\">back</a>"; } elseif ($go == "Delete") { $hvahvor = $this->run($list); mysql_query("DELETE FROM $this->mysql_tb_que WHERE $hvahvor"); echo "<b>".count($list)." downloads in que deleted!</b><br><br><a href=\"javascript:history.go(-1)\">back</a>"; } else { $get = mysql_query("SELECT * FROM $this->mysql_tb_que"); echo "<form name=\"f1\" action=\"admin.php?go=added\" method=\"POST\">".mysql_num_rows($get)." downloads submitted for review<br><br>\n\n"; if (mysql_num_rows($get)) { while ($row = mysql_fetch_array($get)) { if (!$row[email]) $row[email] = "no email"; echo "<input type=\"checkbox\" name=\"list[]\" value=\"".$row[id]."\" class=\"box\"><a href=\"".$row[url]."\" target=\"_blank\">".$row[title]."</a> ($row[type], <a href=\"$row[surl]\" target=\"_blank\">$row[sname]</a> - $row[email])<br>\n"; } echo "<br><input type=\"Submit\" name=\"sub\" value=\"Insert\" class=\"form\"> <input type=\"Submit\" name=\"sub\" value=\"Delete\" class=\"form\"></form>"; } } }[/code] Link to comment https://forums.phpfreaks.com/topic/30244-checkbox-question/#findComment-139072 Share on other sites More sharing options...
kenrbnsn Posted December 11, 2006 Share Posted December 11, 2006 Change this line:[code]<?phpecho "<input type=\"checkbox\" name=\"list[]\" value=\"".$row[id]."\" class=\"box\"><a href=\"".$row[url]."\" target=\"_blank\">".$row[title]."</a> ($row[type], <a href=\"$row[surl]\" target=\"_blank\">$row[sname]</a> - $row[email])<br>\n";?>[/code]to[code]<?phpecho '<input type="checkbox" name="list[]" value="'.$row[id].'" class="box" checked><a href="'.$row['url'].'" target="_blank">'.$row[title].'</a> ($row[type], <a href="' . $row['surl'] . ' target="_blank">' . $row['sname'] . '</a> - ' . $row['email'])' . "<br>\n";?>[/code]I added the attribute "checked" to the line. I also change the surronding quotes to single quotes so I could get rid of the backslashe escape character.Ken Link to comment https://forums.phpfreaks.com/topic/30244-checkbox-question/#findComment-139086 Share on other sites More sharing options...
tDC Posted December 11, 2006 Author Share Posted December 11, 2006 HeyI then get this:[quote]Parse error: syntax error, unexpected ')', expecting ',' or ';' in /my/web/site/yoursite.com/public_html/site/edit.class.php on line 269[/quote] Link to comment https://forums.phpfreaks.com/topic/30244-checkbox-question/#findComment-139092 Share on other sites More sharing options...
kenrbnsn Posted December 11, 2006 Share Posted December 11, 2006 I missed one " . ' " before the ")" after "$row['email']Ken Link to comment https://forums.phpfreaks.com/topic/30244-checkbox-question/#findComment-139098 Share on other sites More sharing options...
tDC Posted December 11, 2006 Author Share Posted December 11, 2006 :):):):):)Absolutely brilliantThanks alot for all your help :)Ashley. Link to comment https://forums.phpfreaks.com/topic/30244-checkbox-question/#findComment-139105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.