Jump to content

mcgonzalezp

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mcgonzalezp's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. THANK YOU! that was a great help I've fixed most of what I need to fix so far, but still have a problem here. Look at my query at line 12. I need to insert those values in my Table NOTAS. The array is for: ID, user, materia (the other 2 values don't matter). Materia is the field I'm trying to get from the checkboxes array as you can see here... BUT, I can't get it to bring Materia value; I mean, the checkboxes array is right there, I see it when I test it outside the FOR loop, but when it is inside, the values dissapear, and Materia goes Null. Last help I need! Thank you ALL. 1 if (isset($_POST['Submit'])) 2 { 3 $cuantas=0; 4 $materia = $_POST["materia"]; 5 $cuantas = count($materia); 6 $cuenta = mysql_query("SELECT * FROM Notas"); 7 $cuenta2= $num_regs +1; 8 for ($i=0; $i<=$cuantas; $i++) 9 { 10 11 echo 'Registros FOR' .$cuenta2. '<br><br>'; 12 $querySQL= "INSERT INTO notas VALUES ($cuenta2,'".$_SESSION['IDusuario']."', $materia, 0,0)"; 13 $cuenta2 = $cuenta2 +1; } }
  2. Ohh!! I see... alright, I'll try to fix that and get back. I hope it works! TY!
  3. $querySQL= "INSERT INTO notas VALUES ($cuenta2,'".$_SESSION['IDusuario']."', $materia, 0,0)"; Well, I have a form with an array of checkmarks, calling the Database like this: <input name="materia[]" type="checkbox" id="pi" value="'.$rand['ID_materia'].'"> What I want to do, is to pick all the values of that array, and add them to the database. Create one new record with each selection the user makes of the checkmarks... So the values of the NOTAS table are: 1. Primary key: I 'm using CUENTA (count) to get to the last record) 2. The user is logged, so the ID is being read from the Session 3. The current value of Materia, as Primary key from the array. 4 and 5, two fields that can be null the first time I enter the record. So, the loop isn't working. That's why I am asking for support
  4. Well now I did this... Changed the PI name to MATERIA so I can read the code better... But still doesn't work. There's the for loop... Any ideas?! if (isset($_POST['submit'])) { $materia = $_POST["materia"]; $cuantas = count($materia); echo 'Materias Preinscritas: '.$cuantas.'<br><br>'; for ($i=0; $i<=$cuantas; $i++) { $subquery= "SELECT Count(*) FROM Notas"; $cuenta = mysql_query($subquery); $cuenta2= $cuenta +1; $querySQL= "INSERT INTO notas VALUES ($cuenta2,'".$_SESSION['IDusuario']."', $materia, 0,0)"; $resultado = mysql_query($querySQL); } }
  5. Thank you for your prompt reply! I tried something like that already but didn't work... or maybe I did something wrong again.
  6. Hello all! I am kind of a newbie in PHP issues, but I try to work with structural programming. I have a form, where I print some database information: try it here: http://190.78.37.17/k/index.php username: asuarez password: 123 So, the user logs in, goes to PREINSCRIPCIONES, and then you click on CONTINUAR (select either value in combo box, it doesn't matter) What I need, is the user to select All the subjects he/she wants to submit, and with one click, update them all. So far, with the code I am sending, I can update One of them, always the last one I select... I believe I need some kind of loop and array, but Can't seem to find where. Please, if anybody has an Idea, please please let me know <?php error_reporting(0); require_once('config.php'); if(!isset($_SESSION['usuario'])) $_SESSION['usuario'] = ''; if(!isset($_SESSION['enlinea'])) $_SESSION['enlinea'] = 'No'; $status=''; if(!isset($_GET['insertar'])) $_GET['insertar'] = ''; switch($_GET['insertar']) { case 'pre': error_reporting(0); { $querySQL= "UPDATE Notas set Preinscrita='".htmlentities($_POST['pi'])."' WHERE notas.usuario_n = '".$_SESSION['IDusuario']."' AND Notas.Materia_n = '".htmlentities($_POST['ID'])."'"; $resultado = mysql_query($querySQL); if(mysql_num_rows($resultado) == 1) { $status='OK'; } else { $status='Datos Incorrectos'; } }//la del case }//la del switch if (($_SESSION['enlinea'] != 'Si')) { echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL=index.php?accion=validar">'; } else { echo
×
×
  • 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.