Jump to content

Checkbox Question


tDC

Recommended Posts

Hey All

Im new here :) So hey lol

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

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

Change this line:
[code]<?php
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";
?>[/code]

to
[code]<?php
echo '<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
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.