
ec
Members-
Posts
43 -
Joined
-
Last visited
Never
Everything posted by ec
-
Any ideas on how to display the results of this query under the headings of Pupil Number, First Name, Lastname, Reason, and teacherid? $query = "SELECT detention.pupilno, detention.reason, detention.teacherid, pupil.firstname, pupil.lastname FROM detention, pupil WHERE detention.detentiondate = '$_SESSION[detentiondate]' AND pupil.pupilno = detention.pupilno "; $result = mysql_query($query); if ($result) { while ($array= mysql_fetch_assoc($result)) { echo "<br />"; print "$array[pupilno]: <i>$array[firstname] $array[lastname]</i><br />"; print "<b>Reason:</b> $array[reason]<br />"; print "<b>Allocated By:</b> $array[teacherid]"; print "<U> "; print "<b></u>[ ]</b><br />"; } } ?></p>
-
<?php echo '<form>'; $query1 = mysql_query("SELECT detentiondate FROM detentiondates WHERE detentiondate NOT IN (SELECT detentiondate FROM detention WHERE '".$_SESSION['pupilno']."' = pupilno)"); while ($row = mysql_fetch_assoc($query1)){ echo "$row[detentiondate]"; echo "<input type='radio' name='choice' value='{$row['detentiondate']}'><br>"; } I'm trying to add more to this query so that only dates which are 3 days or more away from today would be displayed as the result of this query. Anyone any ideas? I've tried adding in $t=getdate(); $currentdate=date('Y-m-d',$t[0]); $newcurrentdate = date("Y-m-d", mktime(0,0,0, date(m), date(d)+3,date(Y))); and then variations to the end of the query like AND IF $newcurrentdate < detentiondate but nothing's been working...
-
Thanks that bit of it is working now.
-
hi guys sorry for taking so long.... craygo: the line you gave me does work but there is still a problem; there is more then one value for the answer of the first search but at the minute it only elmintates 1 of the detentiondates.
-
Anyone got any idea what is wrong with this? I am trying to search for a list of detention dates which the pupil are in and compare them to the dates which are available generating a list of dates where the pupil is available. Any ideas? <?php $query1 = mysql_query("SELECT detentiondate FROM detention WHERE '".$_SESSION['pupilno']."' = pupilno "); $row1 = mysql_fetch_assoc($query1); $query2 = mysql_query("SELECT detentiondate FROM detentiondates WHERE detentiondate != $row1.detentiondate "); echo '<form>'; while ($row = mysql_fetch_assoc($query2)){ print "$row[detentiondate]"; echo "<input type='radio' name='choice' value='{$row['detentiondate']}'><br>"; ?>
-
thanks that was the type of structure i was looking for...got it looking like what i want now THANKS!
-
oh sorry... I mean having like a button next to in so that you can click it to submit it as the contents of a field...any ideas how you might go about it?? because everything just goes weird for me when combining html with php
-
is it possible with PHP to query for a set of results and then put these results in bullet form allowing the user to select one of the results for storage??
-
but that's no the problem i'm having....it shows me the correct information with my original code...it just doesn't show it like this Detention Date <detentiondate> <pupilno><firstname><lastname> Reason: <reason> Issued By:<teacherid> <pupilno><firstname><lastname> Reason: <reason> Issued By:<teacherid> <detentiondate> <pupilno><firstname><lastname> Reason: <reason> Issued By:<teacherid> etc.. which is the way i need it to show
-
I don't have a field called detention id...but anyways.. do u mean echo it as I have been printing it before or do i need to arrange the print in any weird way? thanks
-
-- phpMyAdmin SQL Dump -- version 2.10.3 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Mar 29, 2008 at 07:16 PM -- Server version: 5.0.45 -- PHP Version: 5.2.3 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `e1420022_echan334` -- -- -------------------------------------------------------- -- -- Table structure for table `academicyear` -- CREATE TABLE `academicyear` ( `startdate` date NOT NULL, `enddate` date NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `accesslevel` -- CREATE TABLE `accesslevel` ( `position` varchar(30) collate latin1_general_ci NOT NULL, `level` varchar(1) collate latin1_general_ci NOT NULL, PRIMARY KEY (`position`), UNIQUE KEY `position` (`position`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `detention` -- CREATE TABLE `detention` ( `pupilno` varchar(6) collate latin1_general_ci NOT NULL, `detentiondate` date NOT NULL, `reason` text collate latin1_general_ci NOT NULL, `teacherid` varchar(3) collate latin1_general_ci NOT NULL, PRIMARY KEY (`pupilno`,`detentiondate`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `detentiondates` -- CREATE TABLE `detentiondates` ( `detentiondate` date NOT NULL, PRIMARY KEY (`detentiondate`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `members` -- CREATE TABLE `members` ( `firstname` varchar(100) collate latin1_general_ci default NULL, `lastname` varchar(100) collate latin1_general_ci default NULL, `teacherid` varchar(100) collate latin1_general_ci NOT NULL, `passwd` varchar(32) collate latin1_general_ci NOT NULL default '', `level` int(1) NOT NULL, PRIMARY KEY (`teacherid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `pupil` -- CREATE TABLE `pupil` ( `pupilno` varchar(4) collate latin1_general_ci NOT NULL, `firstname` varchar(15) collate latin1_general_ci NOT NULL, `lastname` varchar(15) collate latin1_general_ci NOT NULL, `contactname` varchar(20) collate latin1_general_ci NOT NULL, `addresslineone` varchar(30) collate latin1_general_ci NOT NULL, `addresslinetwo` varchar(30) collate latin1_general_ci NOT NULL, `addresslinethree` varchar(30) collate latin1_general_ci NOT NULL, `city` varchar(30) collate latin1_general_ci NOT NULL, `county` varchar(30) collate latin1_general_ci NOT NULL, `postcode` varchar(10) collate latin1_general_ci NOT NULL, `country` varchar(30) collate latin1_general_ci NOT NULL, `phone` varchar(13) collate latin1_general_ci NOT NULL, PRIMARY KEY (`pupilno`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `teacher` -- CREATE TABLE `teacher` ( `teacherid` varchar(3) collate latin1_general_ci NOT NULL, `position` varchar(30) collate latin1_general_ci NOT NULL, PRIMARY KEY (`teacherid`), UNIQUE KEY `id` (`teacherid`), KEY `id_2` (`teacherid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
-
cooldude832 I get nothing if i did it ur way.....I'M SO CONFUSEDDD AHHHHHHHHH
-
mwasif, yes that is similiar to what i am looking for but it's not working even when i've changed it...have i done any thing wrong? $query = "SELECT detention.detentiondate, detention.pupilno, detention.reason, detention.teacherid, pupil.firstname, pupil.lastname FROM detention, pupil WHERE detention.detentiondate >= '$_SESSION[startdate]' AND detention.detentiondate <= '$_SESSION[enddate]' AND detention.pupilno = pupil.pupilno ORDER BY detention.detentiondate, pupil.lastname, pupil.firstname, pupil.pupilno "; $result = mysql_query($query); $current_date = ""; while($rs = mysql_fetch_array($result)) { if($current_date!=$rs["detentiondate"]) { $current_date=$rs["detentiondate"]; print "$array[detentiondate]<br />"; } print "$array[pupilno]: <i>$array[firstname] $array[lastname]</i><br />"; print "<b>Reason:</b> $array[reason]<br />"; print "<b>Allocated By:</b> $array[teacherid]<br />"; } ?>
-
Is there anyway of grouping the results by detention.detentiondate so that each date is only shown once? $query = "SELECT detention.detentiondate, detention.pupilno, detention.reason, detention.teacherid, pupil.firstname, pupil.lastname FROM detention, pupil WHERE detention.detentiondate >= '$_SESSION[startdate]' AND detention.detentiondate <= '$_SESSION[enddate]' AND detention.pupilno = pupil.pupilno ORDER BY detention.detentiondate, pupil.lastname, pupil.firstname, pupil.pupilno "; $result = mysql_query($query); if ($result) { while ($array= mysql_fetch_assoc($result)) { echo "<br />"; print "$array[detentiondate]<br />"; print "$array[pupilno]: <i>$array[firstname] $array[lastname]</i><br />"; print "<b>Reason:</b> $array[reason]<br />"; print "<b>Allocated By:</b> $array[teacherid]<br />"; } } ?>
-
Is there anyway of grouping the results by detention.detentiondate so that each date is only shown once? $query = "SELECT detention.detentiondate, detention.pupilno, detention.reason, detention.teacherid, pupil.firstname, pupil.lastname FROM detention, pupil WHERE detention.detentiondate >= '$_SESSION[startdate]' AND detention.detentiondate <= '$_SESSION[enddate]' AND detention.pupilno = pupil.pupilno ORDER BY detention.detentiondate, pupil.lastname, pupil.firstname, pupil.pupilno "; $result = mysql_query($query); if ($result) { while ($array= mysql_fetch_assoc($result)) { echo "<br />"; print "$array[detentiondate]<br />"; print "$array[pupilno]: <i>$array[firstname] $array[lastname]</i><br />"; print "<b>Reason:</b> $array[reason]<br />"; print "<b>Allocated By:</b> $array[teacherid]<br />"; } } ?>
-
but then is there a tag that you can use to great a new line?
-
When ever I print using the below code, I always get bullet point next to every line...is there anyway of getting rid of this? <?php $query = "SELECT detention.pupilno, detention.reason, detention.teacherid, pupil.firstname, pupil.lastname FROM detention, pupil WHERE detention.detentiondate = '$_SESSION[detentiondate]' AND pupil.pupilno = detention.pupilno "; $result = mysql_query($query); if ($result) { while ($array= mysql_fetch_assoc($result)) { echo "<li></li>"; print "<li>$array[pupilno]: <i>$array[firstname] $array[lastname]</i></li>"; print "<li><b>Reason:</b> $array[reason]</li>"; print "<li><b>Allocated By:</b> $array[teacherid] </li>";} } ?>
-
No, that's not it but I got it thanks if(strlen($newphone) <>13) { $errmsg_arr[] = 'Phone Number must be 13 digits long'; $errflag = true; } if($newphone == ''){ $errflag = false; }
-
How could I do if phone number is not missing, it must be 13 digits long otherwise errflag comes on? I've attempted several ways but none have worked This is what I have for the 13 digits part of the qry... if(strlen($phone) <> 13) { $errmsg_arr[] = 'Phone Number must be 13 digits long'; $errflag = true; }
-
Is it possible to have 2 update queries in the same file?? Both queries work fine with the other one // but won't work once i remove the // This is the code $qry = "SELECT level as level FROM accesslevel WHERE position= '$position' "; $result=mysql_query($qry); $result = mysql_fetch_array($result); $level = $result[0]; $qry = "UPDATE members SET level = '$level' WHERE teacherid = '$teacherid' "; $result = mysql_query($qry) $qry2 = "UPDATE teacher SET position = '$position' WHERE teacherid = '$teacherid' "; $result2 = mysql_query($qry2); //Check whether the queries was successful or not if($result, $result2) { header("location: updatesuccessful.php"); exit(); }else { die("Query failed"); } mysql_close();
-
I dunno what's wrong with this $query = "SELECT teacherid, position FROM teacher WHERE teacherid NOT IN "members" "; I'm trying to get the query to select teacherid and position from a table called teacher provided that the teacherid doesn't appear in the table members as well... any ideas??