Jump to content

parodyband

New Members
  • Posts

    9
  • Joined

  • Last visited

parodyband's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This is the last thing i need done before the ENTIRE application is finished. Just the dumb little check boxes. That's it.
  2. <?php include 'connect.php'; $id = array($_POST['child']); $status = implode(', ', array_keys($id)); $query = mysql_query("SELECT * FROM Children WHERE id= 'How do I grab this id?' ") or die(MySql Error); $numrows = mysql_num_rows($query); if ($numrows!=0){ while ($row = mysql_fetch_assoc($query)){ $current = $row['status']; } } if ($current == 2){ mysql_query("UPDATE Children SET status=1 WHERE id IN $status"); } else if ($current == 1){ mysql_query("UPDATE Children SET status=2 WHERE id IN $status"); } ?> Is this used in the right context?
  3. I looked up implode, but how would I use it? It just allows you to put data in between data in the array?
  4. I am in no way a "noob" when it comes to other languages.
  5. Ok, I understand, but that wasn't what I was trying to ask... I know how to use arrays in other programming languages, but using it with mysql is a little confusing. So I have <?php include 'connect.php'; $id = $_POST['?']; //I don't know what you mean by php implode. $status = ?? foreach(id[]??){ $query = mysql_query("SELECT * FROM Children WHERE id='$id[?]''") or die("ERROR"); $numrows = mysql_num_rows($query); if ($numrows!=0){ while ($row = mysql_fetch_assoc($query)){ $current = $row['id']; } } if ($current == 2){ mysql_query("UPDATE Children SET status=1 WHERE id = '$status[$id]'"); } else if ($current == 1){ mysql_query("UPDATE Children SET status=2 WHERE id = '$status[$id]'"); } } ?> Am I close to achieving this? BTW Not all of my code showed up on the previous post
  6. Say I have my action set to 'changestatus.php' what would the script look like ish? Ive never used php implode and im not that good with Arrays. im using <?php include 'connect.php'; ?>
  7. Oh Sorry! Yeah how do I have check boxes in a while loop and have it change a mysql data based on what is checked?
  8. I am creating a Child Security Application called Shield Child Security. I ran into a roadblock, and I had to ask myself, "How will they take attendance?" So I want to take a mass status change. If you look at the picture you will see what I mean. <body> <div align="center"> <div style="width:460px; background-color:#000000; padding:11px;" align="left" class="shadow"> Children: <div style="background-color:#3399FF; padding:11px;" align="left" class="shadow"> <form action="" method="POST"> <table> <?php $query = mysql_query("SELECT * FROM Children WHERE classroom='$class'") or die("ERROR"); $numrows = mysql_num_rows($query); if ($numrows!=0){ while ($row = mysql_fetch_assoc($query)){ $cid = $row['id']; $fname = $row['firstname']; $lname= $row['lastname']; $status = $row['status']; $classroom = $row['classroom']; echo '<tr style="background-color:gray;"><td><input type="checkbox"></td><td align="center" width="150" name="'.$cid.'">[<a href="child.php?id='.$cid.'">'.$fname.' '.$lname.'</a>]</td>'; if ($classroom != 'none'){ if ($status == 1) { echo '<td align="center" width="200"><font color="red">Not Present</font>'; } else if ($status == 2){ echo '<td align="center" width="200"><font color="lightgreen">Present</font>';} } else { echo '<td align="center" vertical-align="middle"><br><form action="changeclass.php" method="POST"><select>Balls</select><input type="submit" value="+""></form></td>'; } echo '</td><td align="center"><a href="delete.php?id='.$cid.'&type=child">[ - ]</a></td></tr>'; } } else {echo "No Students";} ?> <tr> </tr> </table> <table> <td> <input type = "submit" value="Switch Status"> </td> </table </div> <br> <a href="classroom.php">Go Back</a> </div> </div> I'm sure its vulnerable to SQL Injection, but remember this is just a rough draft. A draft to get my ideas out in code. Peace! And Thank You!
×
×
  • 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.