-
Posts
2,527 -
Joined
-
Last visited
Posts posted by DeanWhitehouse
-
-
this should send you in the right direction
<?php $Search = mysql_query( "SELECT DISTINCT Courses.Course_Name, student_courses.Course_ID, student_courses.Student_ID, students.Enrollment, students.First_Name, students.Last_Name FROM Courses INNER JOIN student_courses ON Courses.Course_ID = student_courses.Course_ID INNER JOIN students ON student_courses.Student_ID = students.Student_ID WHERE Courses.Course_ID='$Course'") or die(mysql_error()); echo "<table border='0'> <tr align='center'> <td width='20%'><font color='#FFFFFF' face='Calibri'> <b>Enrollment No </td><td width='20%'><font color='#FFFFFF' face='Calibri'> <b>First Name </td><td width='20%'><font color='#FFFFFF' face='Calibri'><b>Last Name</td></tr>" while($row = mysql_fetch_assoc($Search)) $sql = mysql_query(SELECT DISTINCT/*put where the attendance data is coming from here*/); or die(mysql_error()); if ($sql == 1)/*this is the data from the database, 1 = present*/ { echo "<tr align='center'> <td><font color ='White' face = 'calibri'> $row['Enrollment']; </td><td><font color ='White' face = 'calibri'> $row['First_Name']; </td><td><font color ='White' face = 'calibri'> $row['Last_Name']; </td></tr><tr><td><font color ='White' face = 'calibri'>Present </td></tr></table></font>"; } elseif ($sql == 2))/*this is the data from the database, 2= not present*/ { echo "<tr align='center'> <td><font color ='White' face = 'calibri'> $row['Enrollment']; </td><td><font color ='White' face = 'calibri'> $row['First_Name']; </td><td><font color ='White' face = 'calibri'> $row['Last_Name']; </td></tr><tr><td><font color ='White' face = 'calibri'>Absent </td></tr></table></font>"; } ?>
-
wheres it getting the data from??
-
erm, can you post the code you already have and i can edit to show you
-
use an if and else statement depending on the query
-
change = to ==
this might work
-
to make the code look nicer and just a helpfull tip, you can have the whole form in one echo instead of seperate lines
-
ok, thanks for all the help.
-
ok, thanks,
this is now my working code
<?php require_once 'includes/config_table.inc.php'; require_once 'includes/db_connect.php'; mysql_query("SELECT * from `$user` WHERE user_name='$user_name'"); if ($_SESSION['is_valid'] == true){ if ($_SESSION['user_level'] == 2){ echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; } if ($_SESSION['user_level'] == 1){ echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; } } else { include_once ('login.php'); } ?>
how can i display the user name of the user, i am using sessions and cookies
-
when i remove the curly bracket i get this error
Parse error: syntax error, unexpected $end in /home/www/deanwhitehouse.awardspace.co.uk/logged_in.php on line 26
and you can write includes and requires without the brackets
-
ok, people ignore the sql statement,
-
the table name is saved as a variable, so no to "SELECT * FROM users and i want to display the users username, but i can't think of a way to.
Anyway back to the main problem, of the login page not displaying
-
<?php if ($_SESSION['is_valid'] == true){ if ($_SESSION['user_level'] == 2){ mysql_query("SELECT * from `$user` WHERE user_name"); echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; } if ($_SESSION['user_level'] == 1){ mysql_query("SELECT * from `$user` WHERE user_name"); echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; } else { include_once'login.php'; } } ?>
this code is ment to display a login form if the user is not logged in, but it doesn't, and i dunno why
-
isn't a maths function, e.g greater than and less than
-
<?php if(isset($_POST['construction'])){ $construction = $_POST['construction']; $handle = fopen('config.php', 'w+'); //open the file for writing $content = "<?php define('CONSTRUCTION', '{$construction}'); ?>"; //the content to be written fwrite($handle, $content); //write it fclose($handle); } ?> <form action="<?php $_SERVER['PHP_SELF']; ?>" method='POST'> <select name="construction"> <option value="yes">yes</option> <option value="no">no</option> </select> <input type="hidden" name="construction" value="true"><input type="submit" value="Submit"> </form>
-
<form action="<?php $_SERVER['PHP_SELF']; ?>" method='POST'> <input type="hidden" name="construction" value="true"><input type="submit" value="Submit">
if it doesn't work add these, input type before the other input type
-
is it the same error? or different line
-
<?php echo'<div id="contact"> <h2>You have an error please check your message and try again!</h2> <form id="contact_form" name="contact_form" method="post" action="$_SERVER['PHP_SELF']"> <label>Name:<br /> <input name="name" type="text" class="form" id="name" /> </label> <br /><br /> <label>Email:<br /> <input name="email" type="text" class="form" id="email" /> </label> <br /><br /> Message:<br /> <label> <textarea name="message" cols="45" rows="5" class="form" id="message"></textarea> </label> <br /><br /> <label> <input name="submit" type="submit" class="form_button" id="submit" value="Submit" /> </label> </form> </div> '; } elseif (isset($email)||isset($name)||isset($message)||!empty($message)||!empty($email)||!empty($name)) { echo ' <div id="contact"> <form enctype="multipart/form-data" name="contact_form" method="post" action="$_SERVER['PHP_SELF']"> <br /><br /><Br /><br /><b> Thank You,<br /><br /> Vicious Vamp will review your message soon!<br /><br /></b> </form> </div> '; mail('viciousvamp@gmail.com','Mail for ViciousVamp',$message,$headers); } else { echo ' <div id="contact"> <form id="contact_form" name="contact_form" method="post" action="$_SERVER['PHP_SELF']"> <label>Name:<br /> <input name="name" type="text" class="form" id="name" /> </label> <br /><br /> <label>Email:<br /> <input name="email" type="text" class="form" id="email" /> </label> <br /><br /> Message:<br /> <label> <textarea name="message" cols="45" rows="5" class="form" id="message"></textarea> </label> <br /><br /> <label> <input name="submit" type="submit" class="form_button" id="submit" value="Submit" /> </label> </form> </div>'; } include ("inc/footer.inc.php"); ?>
-
yer, delete all the <<<<html, (are the spose to be comments or <html>)??
comments in PHP are // on one line or /* */ on more than one
-
ok, what do u want it to do?
database?
etc.
-
<?php else { //missing echo '<<<HTML <div id="contact"> <form id="contact_form" name="contact_form" method="post" action="'$action'"> <label>Name:<br /> <input name="name" type="text" class="form" id="name" /> </label> <br /><br /> <label>Email:<br /> <input name="email" type="text" class="form" id="email" /> </label> <br /><br /> Message:<br /> <label> <textarea name="message" cols="45" rows="5" class="form" id="message"></textarea> </label> <br /><br /> <label> <input name="submit" type="submit" class="form_button" id="submit" value="Submit" /> </label> </form> </div> HTML'; } //missing
the last else.
-
dude are you really that stuck??
If so i will write the code, for free, but just a basic one.
-
y do i need to use the flush and clean??
-
ok,
-
so do people think i should use ob_start();
or try and change the code and find a way to make it work
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result reso
in PHP Coding Help
Posted
this is my code, does anyone no why it isn't working