Welcome to Dream.In.Code
Become a PHP Expert!

Join 136,932 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,837 people online right now. Registration is fast and FREE... Join Now!




trying to get my head around this

 
Reply to this topicStart new topic

trying to get my head around this

didgy58
25 Mar, 2008 - 12:39 AM
Post #1

D.I.C Head
**

Joined: 23 Oct, 2007
Posts: 170



Thanked: 1 times
My Contributions
hi guys i have created a student registration. the login page is available here

http://quo-vadis.me.uk/testsite/lee4/slogin.php

now when the user enters there user name and password and they are correct the select box is filled up with the modules that they can register for on that specific day, it checks the database for modules that are available on todays date if there are none it tells them that they shouldnt be in

CODE

<?php
$q=$_GET['q'];
$f=$_GET['e'];
if (($q=="")&&($f=="")||($q=="")&&($f!="")||($q!="")&&($f=="")){ //checking for username and password entry
echo "Please Enter A User Name Or Password </li>";
exit();
}

require_once('includes/mysqlconnection.php'); // getting the sql connection script

$sql2="select enrolnumb from student where (enrolnumb='" .$q. "' and pass=SHA('" .$f. "'))"; //checking for username in db

$nresult=mysql_query($sql2);
if (mysql_num_rows($nresult)==1)
{
    $z='Friday';//date("l");//getting todays date in words

    $sql="select studentcourse.mod1id,studentcourse.mod2id,studentcourse.mod3id,studentcourse.mod4id,module.title,module.modid, module.lesson1,module.lesson2 from studentcourse,module where (studentcourse.enrolnumb='" . $q . "' and (studentcourse.mod1id=module.modid and module.lesson1='" . $z . "')or (studentcourse.mod2id=module.modid and module.lesson1='" . $z . "') or (studentcourse.mod3id=module.modid and module.lesson1='" . $z . "') or (studentcourse.mod4id=module.modid and module.lesson1='" . $z . "'))  or (studentcourse.enrolnumb='" . $q . "' and (studentcourse.mod1id=module.modid and module.lesson2='" . $z . "') or (studentcourse.mod2id=module.modid and module.lesson2='" . $z . "') or (studentcourse.mod3id=module.modid and module.lesson2='" . $z . "') or (studentcourse.mod4id=module.modid and module.lesson2='" . $z . "')) ";
    
$result=mysql_query($sql);
    if(mysql_num_rows($result)>0)//if the result shows that he has lectures today it now lists them in a drop down
{
echo "<select name='module' id='module' onChange='copyselect(this)'><option>Please Choose A Module</option>";
while($row=mysql_fetch_array($result))
        {
if ($row['lesson1']==$row['lesson2']){ // if module has 2 lessons on same day show first here and second within the loop
$lesson='lesson 1';
echo "<option value= " .$row['modid']. ">" .$row['title']. " , $lesson</option>";
}
if ($row['lesson1']==$z){
$lesson='lesson 1';
}
if ($row['lesson2']==$z) {
$lesson='lesson 2';
}
            echo "<option value=" . $row['modid'] . ">" .$row['title'].  ", $lesson</option>";
        }
            echo "</select></li><li><input type='submit' value='Register' /></li>";

    }
else {
echo "You Have No Lectures Today What Are You Doing In????";//if the student has no lectures on the day letting him know

}
}
else
{
echo "<select ><option>Please Choose A Module</option></select> <br /> Incorrect User Name or Password Please Try Again</li>";//if user name and password are not valid tells the user

}
?>


this page is called via ajax and builds the select box by being called on the onblur function of the password box, no problem here, when they select the module they would like to register they then click the submit and are registered onto the module and data is saved on the database, now what i would like is when they have registered the module it is removed form the select, now these selectes are built dynamically so im guessing i would need to do a query on the student login database first and try and match against the 1st sql. so im wondering is it possible to do something similar to this.

CODE


while ($row=mysql_fetch_array($result)){
while ($row2=mysql_fetch_array($result2)){
if ($row['somehting']==$row2['something']{
exit this stage of the while loop on both and pull the next record
}
}
}


ok so what im trying to do i have 2 queries on that pulls modules that the student is enrolled on, and that are running that day to fill the select so thats the $row one, now the second would be a sql that searches the student login table for submissions made on that day and taking the moduleid and the lesson number(1 or 2) and student number, now if the $row['enrolnumb'] matches $row2['enrolnumb'] and $row['modid'] matches $row2['modid'] and date matches $row2['date'], i would like it to not add that option to the select box and skip that element in the array how would i go about doing that is it basically

CODE

get the the matched statment and then just
exit();


or does that just exit the whole thing and not carry on i would still like to continue through the loop to build the select box, im just wondering if this is totally possible?


User is offlineProfile CardPM
+Quote Post

didgy58
RE: Trying To Get My Head Around This
25 Mar, 2008 - 01:13 AM
Post #2

D.I.C Head
**

Joined: 23 Oct, 2007
Posts: 170



Thanked: 1 times
My Contributions
ok ive just looked up some stuff on this and there is a continue statment. do u think this might do it if i place it in the matched area ??



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 10:38PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month