Jump to content

facarroll

Members
  • Posts

    106
  • Joined

  • Last visited

Everything posted by facarroll

  1. I have two tables 'quiz' and 'topics'. The relevant columns in 'quiz' are 'passState' (which returns 1 or 0 representing true/false) and 'managerId' which is a record number referring to a particular administrator. The relevant columns in 'topics' are 'managerId' and six other columns named 'equip1' .... 'equip6' respectively, which refer to the allocation of particular quizzes to particular student groups. Each quiz can be allocated to none or any or all of the groups 'egroup1' to 'egroup6' by the allocation of true/false value to each. The code below displays all of the required data on the page, but not in the layout I want. Despite the use of SELECT DISTINCT the data is returned in duplicate. As well as that, the image file 'tick2.png' (in the last table data row) is not returned in any meaningful way. Firstly, it should only be returned when 'passState' has a value of 1. Secondly, it is being returned to all of the rows in the array, but only to one of the duplicate rows but randomly it seems. I don't understand what's wrong. I appreciate that this is a long winded explanation, but I'd really appreciate some help. <?php //$query1 = mysql_query("SELECT DISTINCT comment, url_big, url_small, title, pdf, comment FROM topics WHERE managerId = $managerId AND $egroup = 1 ORDER BY title"); $query1 = mysql_query("SELECT DISTINCT comment, url_big, url_small, title, pdf, passState FROM topics INNER JOIN quiz ON topics.managerId = quiz.managerId WHERE ( topics.$egroup = 1 AND quiz.userId = '$userId' ) ORDER BY topics.title "); ?> <table width="850" style="font-size:16px"> <tr> <?php while ($row1 = mysql_fetch_array($query1)) { ?> <td width="45"></td> <td width="132" style="vertical-align:middle;"><?php echo "<a href='../../wood/wood_tool_images/{$row1['url_big']}' target='_blank'><img src = '../../wood/wood_tool_images/{$row1['url_small']}' /><br />\n"; ?></td> <td width="25"></td> <td width="172" style="vertical-align:middle;"><?php echo "{$row1['title']} <br />\n"; ?></td> <td width="25"></td> <td width="132" style="vertical-align:middle;"><?php echo "<a href='../equipment/{$row1['title']} Safety Quiz/{$row1['title']} Safety Quiz.php'>Take This Quiz</a><br />\n"; ?></td> <td width="25"></td> <td width="112" style="vertical-align:middle; text-align:right;"><?php echo "<a href='../../wood/wood_tool_images/pdf/{$row1['pdf']}' target='_blank'><img src='../../wood/wood_tool_images/pdf/icon.jpg' /><br />\n"; ?></td> <td width="15"></td> <td width="132" style="vertical-align:middle; text-align:left;" ><?php echo "{$row1['comment']} <br />\n"; ?></td> <td width="45"><?php if ("{$row1['passState']}" == 1) {echo "<img src=' ../../wood/wood_tool_images/tick2.png' /><br />\n";}?></td> </tr> <?php } ?> </table>
  2. Update: I bypassed the login script and found that the interactive pages contained no data from the database. This suggests a database problem, but what to do about it.
  3. I have a webpage that is PHP and MySql driven. I do all of my development on a WAMP server in my notebook, get it pretty and upload to the online website. All good for months, then today the online site will not process the login system I've set up on one of the pages. I went back to the WAMP server page and it's all good. Uploaded the relevant files from the notebook, but still no good online. I've checked the data in both databases, and identical. Also checked the connect file. One thing, a different logon for a different page is ok, though that data is held in a different table from the offending login system. Any suggestions? I'm suspicious of the online database, but not sure why. You can check the bad login at http://www.safetytestingonline.com/demonstration/admin_login/member_account.php and similarly a good one at http://www.safetytestingonline.com/demonstration/admin_login/stud_do_quiz.php. Any comments gratefully read. I should add that you can click on the login panels and you will be prompted with the respective login details, as these logins are there to access a demonstration page. Also, if anyone can explain the error message on one of the login panels, that help is welcome also.
  4. Hi everyone, I don't know whether this is a PHP or MySql problem, but I think it is the former. The following code queries the database correctly, (and before you ask, there are no duplicate database entries), but the output duplicates every row. e.g., hammer (jpg image) hammer hammer (jpg image) hammer saw (jpg image) saw saw (jpg image) saw screwdriver (jpg image) screwdriver screwdriver (jpg image) screwdriver and so on. I cannot see why the code causes the row to repeat. <?php session_start(); if (isset($_SESSION['id'])) { // Put stored session variables into local php variable $id = $_SESSION['id']; $userId = $_SESSION['userId']; $userGroup = $_SESSION['userGroup']; $managerId = $_SESSION['managerId']; } include_once("demo_conn.php"); $sql = mysql_query("SELECT * FROM users WHERE id='$id'"); while($row = mysql_fetch_array($sql)) { // Get member data into a session variable $egroup = $row["egroup"]; session_register('egroup'); $_SESSION['egroup'] = $egroup; } $query = mysql_query("SELECT topics.url_big, topics.url_small, topics.title, topics.$egroup, quiz.passState, quiz.userDate FROM topics INNER JOIN quiz ON (topics.managerId = quiz.managerId) WHERE topics.$egroup = 1 ORDER BY title ASC"); while ($row1 = mysql_fetch_array($query)) { echo "<a href='../../wood/wood_tool_images/{$row1['url_big']}' target='_blank'><img src='../../wood/wood_tool_images/{$row1['url_small']}' /><br />\n"; echo "{$row1['title']} <br />\n"; } ?>
  5. I reviewed and modified the code. I now get an array, but mostly in duplicate. You can see the duplication in the attached screenshot. This is another problem I guess, but at least the query is working, somewhat. The dynamic variables are session variables that allow the selection of certain columns in the tables. I've posted the code going further, as I think this new problem may emanate from there. <?php $query1 = mysql_query("SELECT topics.url_big, topics.url_small, topics.title, topics.".$egroup.", quiz.passState, quiz.userDate FROM topics INNER JOIN quiz ON (topics.managerId = quiz.managerId) WHERE topics.".$egroup." = 1 ORDER BY title ASC"); ?> <table width="850" style="font-size:16px"> <?php while ($row1 = mysql_fetch_array($query1)) { ?> <tr> <td width="45"></td> <td width="132" style="vertical-align:middle"><?php echo "<a href='../../wood/wood_tool_images/{$row1['url_big']}' target='_blank'><img src='../../wood/wood_tool_images/{$row1['url_small']}' alt='' /><br />\n"; ?></td> <td width="25"></td> <td width="172" style="vertical-align:middle"><?php echo "{$row1['title']} <br />\n"; ?></td> <td width="25"></td> <td width="132" style="vertical-align:middle"><?php echo "<a href='../equipment/{$row1['title']} Safety Quiz/{$row1['title']} Safety Quiz.php'>Take This Quiz</a><br />\n"; ?></td> <td width="25"></td> <td width="112" style="vertical-align:middle"><?php echo "<img src='../../wood/wood_tool_images/{$row2['testcompleted.jpg']}' /><br />\n"; ?></td> <td width="25"></td> <td width="122" style="vertical-align:middle"><?php echo "{$row1['userDate']} <br />\n"; ?></td> <td width="45"></td> </tr> <?php } ?> </table> [attachment deleted by admin]
  6. Can anyone see what is wrong here? This is my first serious attempt at this. <?php $query1 = mysql_query(" SELECT topics.url_big, topics.url_small, topics.title, topics.".$egroup.", quiz.passState FROM topics INNER JOIN quiz ON (topics.managerId = quiz.".$managerId.") WHERE topics.".$egroup." = 1 ORDER BY title ASC"); ?>
  7. Fixed it myself. <?php $query1 = mysql_query("SELECT * FROM topics WHERE managerId=".$managerId." AND ".$egroup."= 1 ORDER BY title ASC"); ?>
  8. I have a Select statement that relies on two session variables to complete the statement. One variable, $egroup, supplies a column name. I cannot make the SELECT work. It works fine if I substitute the real name of one of the columns such as "egroup1", or "egroup6", but that's what the variable $egroup is for. Can anyone tell me where I'm wrong? I guess the answer is in the syntax, but I'm not very good at this and I've been on it for too long. Any help gratefully taken. <?php $query1 = mysql_query("SELECT * FROM topics WHERE managerId='".$managerId."' AND "$egroup"= 1 ORDER BY title ASC"); ?>
  9. Here is my form.It works fine.Because it is a radio button form, only one variable of the six available is chosen. This variable is echoed in the relevant hidden field. Then when the variable from the hidden field is posted, it is supposed to be converted to one of six specified strings and then posted to the database into column "egroup". The problem I have is that it always goes to the last variable and posts the string "egroup6". I want to break out of the str_replace routine and post the replacement name which matches the sequence of the hidden field selection. How can I rewrite the str_replace routine so that it breaks when it finds the selected variable? The code for the form; <table width="700" align="center" cellpadding="5"> <form action="adduser2.php" method="post" enctype="multipart/form-data"> <input name="egroup1" type="hidden" value="<?php echo "$group1"; ?>"> <input name="egroup2" type="hidden" value="<?php echo "$group2"; ?>"> <input name="egroup3" type="hidden" value="<?php echo "$group3"; ?>"> <input name="egroup4" type="hidden" value="<?php echo "$group4"; ?>"> <input name="egroup5" type="hidden" value="<?php echo "$group5"; ?>"> <input name="egroup6" type="hidden" value="<?php echo "$group6"; ?>"> <tr> <td colspan="3"><font color="#OO99CC"><?php echo "$errorMsg"; ?> </font></td> </tr> <tr> <td width="200"><div align="right"> <p><br /> Enter Student Name: </div></td> <td width="125"><p><br /> <input name="userId" type="text" value="<?php echo "$studName"; ?>" /> </td> <td width="350"> <input name="userPwd" type="hidden" value="<?php echo "$activatecode"; ?>" /> <font size="-1" color="#006600">(The password </font><font size="+2" color="#0000FF"><?php echo "$activatecode"; ?></font><font size="-1" color="#006600"> has been allocated to this next student. Print out your full list of student passwords <a href="../reports/reports_page.php">here</a>.)</font></td> </tr> <tr> <td></td> </tr> <tr> <td width="200"><div align="right">Allocate this student to <br /> one of these quiz groups:</div></td> <td width="125" colspan="1"><input type="radio" name="userGroup" value="'<?php echo "$group1"; ?>'" /> <?php echo "$group1"; ?><br /> <input type="radio" name="userGroup" value="'<?php echo "$group2"; ?>'" /> <?php echo "$group2"; ?><br /> <input type="radio" name="userGroup" value="'<?php echo "$group3"; ?>'" /> <?php echo "$group3"; ?><br /> <input type="radio" name="userGroup" value="'<?php echo "$group4"; ?>'" /> <?php echo "$group4"; ?><br /> <input type="radio" name="userGroup" value="'<?php echo "$group5"; ?>'" /> <?php echo "$group5"; ?><br /> <input type="radio" name="userGroup" value="'<?php echo "$group6"; ?>'" /> <?php echo "$group6"; ?><br /></td> <td width="350" align="right" ><p><?php echo $bottlinks; ?></td> </tr> <tr> <td><input name="userCollege" type="hidden" value="<?php echo "$school"; ?>" /> <input name="managerId" type="hidden" value="<?php echo "$userid"; ?>" /> <div align="right"></div></td> <td><input type="submit" name="Submit" value="Submit Form" /></td> </tr> </form> </table> When I post the data I use this code; // Filter the posted variables $studName = preg_replace("/[^A-Z a-z0-9]/", "", $_POST['userId']); $activatecode = preg_replace("/^A-Z a-z0-9]/", "", $_POST['userPwd']); $school = preg_replace("/[^A-Z a-z0-9]/", "", $_POST['userCollege']); $userGroup = preg_replace("/[^A-Z a-z0-9]/", "", $_POST['userGroup']); // variables posted from hidden fields $egroup1 = $_POST['egroup1']; $egroup = str_replace($egroup1, "egroup1", $egroup1); $egroup2 = $_POST['egroup2']; $egroup = str_replace($egroup2, "egroup2", $egroup2); $egroup3 = $_POST['egroup3']; $egroup = str_replace($egroup3, "egroup3", $egroup3); $egroup4 = $_POST['egroup4']; $egroup = str_replace($egroup4, "egroup4", $egroup4); $egroup5 = $_POST['egroup5']; $egroup = str_replace($egroup5, "egroup5", $egroup5); $egroup6 = $_POST['egroup6']; $egroup = str_replace($egroup6, "egroup6", $egroup6); $managerid = preg_replace("/[^A-Z a-z0-9]/", "", $_POST['managerId']); // filter everything but spaces, numbers, and letters Here is the insert statement; $sql = mysql_query("INSERT INTO users (userId, userPwd, userCollege, userGroup, egroup, managerId, doe) VALUES('$studName','$activatecode','$school', '$userGroup', '$egroup', '$managerid', now())") or die (mysql_error());
  10. Working on it. I'll get back to you. You can see the site at www.safetytestingonline.com.
  11. I'll try to explain further. When the user enters text into the form, it is meaningful only to that user. It is always a name, but could be "Bill", or "grade3", or "new students". There are six fields the user can use. I want to have a preset name that goes into the record, being group1 to group6. Then I can search the database for the preset field names and derive the user names accordingly.
  12. I will store a user supplied name for the field "group1". Obviously, the text input will be whatever the user decides, but elsewhere I need to be able to search the database for this record based on the data supplied by the user. I can do this if I have an accompanying field with one of the six preset names. I cannot search on the user supplied data because it could be anything, meaningful only to the user. Ask me further if this does not make sense.
  13. I don't know whether this is a PHP or an HTML question. I want to be able to post a preset value to accompany an input text value, and have both values entered in the database record. You can see in the code below that the form asks for names for up to six student groups, such as "Year7", "Year8", "Year9" and so on. What I want my form to do is to post the accompanying preset input name (in this case "group1", "group2", "group3", and so on) to a second column in the same record, so that I can search the records on this preset field. How can I do this? <table width="750" align="center" cellpadding="4"> <form action="admin_login.php" method="post" enctype="multipart/form-data"> <tr> <td><div align="right"><font size="-1">Student Group 1: </font><font color="#CC0000"> </font></div></td> <td><input name="group1" type="text" value="<?php echo "$group1"; ?>" /></td> </tr> <tr> <td><div align="right"><font size="-1">Student Group 2: </font><font color="#CC0000"> </font></div></td> <td><input name="group2" type="text" value="<?php echo "$group2"; ?>" /></td> </tr> <tr> <td><div align="right"><font size="-1">Student Group 3: </font><font color="#CC0000"> </font></div></td> <td><input name="group3" type="text" value="<?php echo "$group3"; ?>" /></td> </tr> <tr> <td><div align="right"><font size="-1">Student Group 4: </font><font color="#CC0000"> </font></div></td> <td><input name="group4" type="text" value="<?php echo "$group4"; ?>" /></td> </tr> <tr> <td><div align="right"><font size="-1">Student Group 5: </font><font color="#CC0000"> </font></div></td> <td><input name="group5" type="text" value="<?php echo "$group5"; ?>" /></td> </tr> <tr> <td><div align="right"><font size="-1">Student Group 6: </font><font color="#CC0000"> </font></div></td> <td><input name="group6" type="text" value="<?php echo "$group6"; ?>" /></td> </tr> <tr> <td><div align="right"></div></td> <td><input type="submit" name="Submit" value="Submit Form" /></td> </tr> </form>
  14. I understand the concept, but need some more direct help. I'd greatly appreciate some further help.
  15. I've got my code working OK in that the correct results are drawn from the database. What I have here in the code is an array consisting of an image, accompanied by its title and thirdly a link to activate a quiz associated with the image. Everything works fine, except because the page is dynamic, I always have an unknown number of sets of data (image, title and link) which I want to display so that each set of data takes up a new row. The code I have here, while displaying the correct data, places all of the results into the same row. Any suggestions are most welcome. <?php // Query the database $query1 = mysql_query("SELECT title FROM topics WHERE managerId='".$managerId."' AND egroup1='"."1"."' ORDER BY title ASC"); $query2 = mysql_query("SELECT url_small FROM topics WHERE managerId='".$managerId."' AND egroup1='"."1"."' ORDER BY title ASC"); $query3 = mysql_query("SELECT title FROM topics WHERE managerId='".$managerId."' AND egroup1='"."1"."' ORDER BY title ASC"); while($row1 = mysql_fetch_array($query3)) { $linkname .= $row1['title']."<br />\n"; } ?> <table> <tr> <td> <?php while ($row2 = mysql_fetch_array($query2)) { $thumbnail.= $row2['url_small']; echo "<img src='wood_tool_images/{$row2['url_small']}' alt='' /><br />\n"; } ?> </td> <td height="200"> <?php echo $linkname ?> </td> <td> <?php while ($row1 = mysql_fetch_array($query1)) { $quizname.= $row1['title']; echo "<a href='../{$row1['title']} Safety Quiz/{$row1['title']} Safety Quiz.php'>Take This Quiz</a><br />\n"; } ?> </td> </tr> </table>
  16. I made some changes to my field names as suggested by sasa and despite my petulant grumblings in my recent (minutes ago) post, I have to say that he was quite correct. Thanks.
  17. I posted the question because I didn't know what I was doing. I still don't, but why did you answer my question with another question? I need help rather than some sort of oblique criticism.
  18. At first the Insert query sequence appears to be wrong, but I am sure it is OK. I have used an unfortunate choice of field name in "equip", but that is not the problem.
  19. I put a snippet up yesterday, and thought it had been solved. It had a typo error, but there is still something wrong. The whole page follows, because it might be easier to see what I am doing. The form successfully inserts a new record OK, but it will not update a record that already exists as is intended. Instead, it always creates another new record. Where can I be wrong? <?php session_start(); // See if logged in member by checking session data if (isset($_SESSION['recid'])) { // Put stored session variables into local php variable $userid = $_SESSION['recid']; $username = $_SESSION['name']; $school = $_SESSION['college']; $payer_email = $_SESSION['payer_email']; $group1 = $_SESSION['group1']; $group2 = $_SESSION['group2']; $group3 = $_SESSION['group3']; $group4 = $_SESSION['group4']; $group5 = $_SESSION['group5']; $group6 = $_SESSION['group6']; } else { ?> <!-- make login box --> <html> <tr> <td> <p> <p> <p></td> </tr> <table style= border align="center" border="1" width="400" height="200"> <td align="center" valign="center">You need to<a href="login_allocate_quiz.php">log in</a>as an administrator to<br /> allocate quizzes to student groups.</td> </table> </html> <?php exit(); } // Set error message as blank upon arrival to page $errorMsg = ""; // Check to see if the form has been submitted if (isset($_POST['equip'])){ //Connect to the database through include include_once "demo_conn.php"; //set variables $equip = $_POST['equip']; $egroup1 = $_POST['egroup1']; $egroup2 = $_POST['egroup2']; $egroup3 = $_POST['egroup3']; $egroup4 = $_POST['egroup4']; $egroup5 = $_POST['egroup5']; $egroup6 = $_POST['egroup6']; //create variables to manipulate filenames in database $lowquip = strtolower($equip); $wordquip = str_replace (" ", "", $lowquip); $bigpic = $wordquip.'big'; $smallpic = $wordquip.'small'; $bigpic = $bigpic.'.jpg'; $smallpic = $smallpic.'.jpg'; $errorMsg = '<font size="-1"><u>ERROR:</u> You have not entered the following required information.'; $nogroup = ((!$egroup1) && (!$egroup2) && (!$egroup3) && (!$egroup4) && (!$egroup5) && (!$egroup6)); $noequip = (!$equip); if ($nogroup) {$errorMsg .= "--- Student Group. (No data was forwarded to the database.)</font>";} else if($noequip) {$errorMsg .= "--- Quiz Name. (No data was forwarded to the database.)</font>";} else {$query = mysql_query("SELECT equip FROM topics WHERE equip = '$equip' AND managerId = '$userid'"); if (mysql_num_rows($query) > 0) mysql_query("UPDATE topics SET egroup1 = '$egroup1', egroup2 = '$egroup2', egroup3 = '$egroup3', egroup4 = '$egroup4', egroup5 = '$egroup5', egroup6 = '$egroup6' WHERE equip = '$equip' AND managerId = '$userid'"); else mysql_query("INSERT INTO topics (managerId, equip, title, url_big, url_small, egroup1, egroup2, egroup3, egroup4, egroup5, egroup6) VALUES ('$userid','$wordquip', '$equip', '$bigpic', '$smallpic', '$egroup1', '$egroup2', '$egroup3', '$egroup4', '$egroup5', '$egroup6')") or die (mysql_error("error 1321")); $URL='make_quiz_list_test4.php'; header ('Location: '.$URL); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <meta http-equiv="X-UA-Compatible" content="IE=4"> <!-- IE5 mode --> <meta http-equiv="X-UA-Compatible" content="IE=7.5"> <!-- IE7 mode --> <meta http-equiv="X-UA-Compatible" content="IE=100"> <!-- IE8 mode --> <meta http-equiv="X-UA-Compatible" content="IE=a"> <!-- IE5 mode --> <title>Manager selected quiz list</title> <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> <!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]--> <!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]--> <script type="text/javascript" src="script.js"></script> </head> <body> <div id="art-page-background-simple-gradient"> <div id="art-page-background-gradient"></div> </div> <div id="art-main"> <div class="art-sheet"> <div class="art-sheet-tl"></div> <div class="art-sheet-tr"></div> <div class="art-sheet-bl"></div> <div class="art-sheet-br"></div> <div class="art-sheet-tc"></div> <div class="art-sheet-bc"></div> <div class="art-sheet-cl"></div> <div class="art-sheet-cr"></div> <div class="art-sheet-cc"></div> <div class="art-sheet-body"> <div class="art-header"> <div class="art-header-png"></div> <div class="art-header-jpeg"></div> <div class="art-logo"> <h1 id="name-text" class="art-logo-name"><a href="#">Safety Testing Online</a></h1> <div id="slogan-text" class="art-logo-text">Safety - The Most Valuable Insurance</div> </div> </div> <div class="art-nav"> <div class="l"></div> <div class="r"></div> <div class="art-nav-center"> <ul class="art-menu"> <li> <a href="../../index.php" class="active"><span class="l"></span><span class="r"></span><span class="t">Home</span></a> </li> <li> <a href="../demo_main.php"><span class="l"></span><span class="r"></span><span class="t">Demonstrations Page</span></a> <ul> </ul> </li> <li> <a href="logout.php"><span class="l"></span><span class="r"></span><span class="t">Admin Logout</span></a> </li> </ul> </div> </div> <div class="art-content-layout"> <div class="art-content-layout-row"> <div class="art-layout-cell art-content"> <div class="art-post"> <div class="art-post-tl"></div> <div class="art-post-tr"></div> <div class="art-post-bl"></div> <div class="art-post-br"></div> <div class="art-post-tc"></div> <div class="art-post-bc"></div> <div class="art-post-cl"></div> <div class="art-post-cr"></div> <div class="art-post-cc"></div> <div class="art-post-body"></div> <div class="art-post-bl"></div> <div class="art-post-br"></div> <div class="art-post-tc"></div> <div class="art-post-bc"></div> <div class="art-post-cl"></div> <div class="art-post-cr"></div> <div class="art-post-cc"></div> <div class="art-post-body"> <div class="art-post-inner art-article"> <table style="table-layout:fixed; width:850px;"> <tr> <td style="text-align:left; width:30px;"> </td> <td style="text-align:left; width:350px;"><font size="+1">Allocation of Woodwork Quizzes to Groups.</font></td> <td style="text-align:left; text-align:center; vertical-align:bottom; width:450px;"><font color="#0000FF">Administrator: <?php echo $username; ?> - <?php echo $school; ?>.</font></td> <td style="text-align:left; width:20px;"></td> </tr> </table> <table style="table-layout:fixed; width:850px;"> <tr> <td style="text-align:left; width:30px;"></td> <td style="text-align:left; vertical-align:bottom; width:800px;"><font color="#FF0000"><?php echo "$errorMsg"; ?></font></td> <td style="text-align:left; width:20px;"></td> </tr> </table> <table style="table-layout:fixed; border:thin; text-align:left; width:850px;"> <tr> <td style="text-align:right; width:35px;"></td> <td style="text-align:left; width:190px;"></td> <td style="text-align:right; width:20px;"></td> <td style="text-align:left; width:210px;"><font color="#FF0000"></font></td> <td style="text-align:right; width:20px;"></td> <td style="text-align:left; width:110px;"></td> <td style="text-align:right; width:20px;"></td> <td style="text-align:right; width:180px;"></td> <td style="text-align:right; width:35px;"></td> </tr> <hr/> <tr> <td rowspan="12"></td> <td rowspan="12"> <br/> <form method="post" enctype="multipart/form-data" action="make_quiz_list_test4.php"> <!--<form method="post" action="< ?php echo $PHP_SELF;?>">--> <select size="25" name="equip" /> <option selected value="">No Quiz Selected</option> <option value="Biscuit Jointer">Biscuit Jointer</option> <option value="Dowelling Machine">Dowelling Machine</option> <option value="Drill Cordless">Drill - Cordless</option> <option value="Drill with Cord">Drill - Power Corded</option> <option value="Pedestal Drill">Drill - Pedestal</option> <option value="Edge Tool Sharpener">Edge Tool Sharpener</option> <option value="General Workshop Safety">General Workshop Safety</option> <option value="Pedestal Grinder">Grinder - Pedestal</option> <option value="Hand Tools">Hand Tools</option> <option value="Jointer">Jointer (fixed)</option> <option value="Jointer Surfacer Combo">Jointer/Surfacer (combo)</option> <option value="Shaper">Shaper (fixed)</option> <option value="Lathe for Wood">Lathe - Wood</option> <option value="Linisher">Linisher</option> <option value="Mortiser with Hollow Chisel">Mortiser - Hollow Chisel</option> <option value="Nailgun for Brads">Nailer - Air (brads)</option> <option value="Planer Portable">Planer - (portable)</option> <option value="Router Portable">Router - Plunge</option> <option value="Router with Sliding Table">Router Table - Slide</option> <option value="Sander Belt">Sander - Belt (fixed)</option> <option value="Sander Disc Belt Combo">Sander - Belt/Disc Combo)</option> <option value="Sander Portable Belt">Sander - Belt (portable)</option> <option value="Sander Disc">Sander - Disc (fixed)</option> <option value="Sander Orbital">Sander - Orbital</option> <option value="Sander Random Orbit">Sander - Random Orbital</option> <option value="Sander Bobbin">Sander - Vertical Spindle</option> <option value="Saw Bandsaw">Saw - Bandsaw</option> <option value="Saw Bench">Saw - Circular (bench)</option> <option value="Saw Portable Circular">Saw - Circular (portable)</option> <option value="Saw Drop or Chop">Saw - Drop (alt Chop)</option> <option value="Saw Drop and Slide">Saw - Drop & Slide</option> <option value="Jigsaw Portable">Saw - Jigsaw (portable)</option> <option value="Saw Panel">Saw - Panel (fixed)</option> <option value="Saw Radial Arm">Saw - Radial Arm</option> <option value="Saw Sabre">Saw - Sabre(portable)</option> <option value="Saw Scroll">Saw - Scroll</option> <option value="Screw Driver Portable">Screwdriver - Portable</option> <option value="Thicknesser">Thickness Planer</option> </td> <td> </td> <td> </td> <td> </td> <td rowspan="7"><br /> <br /> <br /> <input type="checkbox" name="egroup1" value="1" /> <?php echo $group1; ?> <p> <input type="checkbox" name="egroup2" value="1" /> <?php echo $group2; ?> <p> <input type="checkbox" name="egroup3" value="1" /> <?php echo $group3; ?> <p> <input type="checkbox" name="egroup4" value="1" /> <?php echo $group4; ?> <p> <input type="checkbox" name="egroup5" value="1" /> <?php echo $group5; ?> <p> <input type="checkbox" name="egroup6" value="1" /> <?php echo $group6; ?> <p> <input type="submit" value="submit" name="Send Data"> </form> </td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td style="border:solid; color:#006600; 1px; padding:10px; text-align:left;"><font size="-1">Select a Quiz Topic from the drop down list on the left. Then go to the check boxes on the right to select all of the groups that are expected to undertake this test. <p>You can select only one quiz each time, but you can select from one to six groups to undertake that quiz. <p>Repeat this process until you have allocated all of the tests that you require each group to complete. <p>If you make a mistake you can delete a quiz allocation <a href="../../under_con.php">here</a> at any time. </font></td> <td></td> <td></td> <td style="color:#006600;"><font size="-1">Go back to the <br /> <a href="member_account.php">main edit page</a>.<br/> <br /> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> </font></td> </tr> <tr> <td></td> <td> <br/> <br/> <br/> <br/></td> <td></td> <td></td> <td></td> </tr> </table> <!-- /article-content --> </div> <div class="cleared"></div> </div> <div class="cleared"></div> </div> </div> </div> </div> </div> <div class="cleared"></div> <div class="art-footer"> <div class="art-footer-inner"> <div class="art-footer-text"> <p><a href="#">Contact Us</a> | <a href="#">Terms of Use</a> | <a href="#">Trademarks</a> | <a href="#">Privacy Statement</a><br /> <?php $time = time () ; //This line gets the current time off the server $year= date("Y",$time); //This line formats it to display just the year echo "Copyright © 2010 - " . $year; //this line prints out the copyright date range, you need to edit 2010 to be your opening year ?> All Rights Reserved.</p> </div> </div> <div class="art-footer-background"></div> </div> <div class="cleared"></div> </div> </div> <div class="cleared"></div> <p class="art-page-footer">Designed by Frank.</p> </div> </body> </html>
  20. I have a snippet which only partly works. The code is intended to update a record, but if it does not exist, then create it. This snippet always creates a new record, and will not update an existing one. What's wrong? $query = mysql_query("SELECT equip FROM topics WHERE equip = '$equip' AND managerId = '$userid'"); if (mysql_num_rows($query) > 0) { mysql_query("UPDATE topics SET egroup1 = '$egroup1', egroup2 = '$egroup2', egroup3 = '$egroup3', egroup4 = '$egroup4', egroup5 = '$egroup5', egroup6 = '$egroup6', WHERE equip = '$equip' AND managerId = '$userid'"); } else { mysql_query("INSERT INTO topics (managerId, equip, title, url_big, url_small, egroup1, egroup2, egroup3, egroup4, egroup5, egroup6) VALUES ('$userid','$wordquip', '$equip', '$bigpic', '$smallpic', '$egroup1', '$egroup2', '$egroup3', '$egroup4', '$egroup5', '$egroup6')"); }
  21. For some reason my screenshot didn't post. Maybe I should've sent it as a .doc file instead of .docx. Attached here. [attachment deleted by admin]
  22. I'm new at PHP and have a problem. I have a MySql database with lists of students grouped into classrooms. A typical group is shown in the attached screenshot screenshot.docx. I want to be able to select one or more of the names by using the associated checkbox, and upgrade a student or students into a different group as defined in the radio button list also in the screenshot. I have the rudiments of the file attached, but I have absolutely no idea how I can post the array so that the records are updated. Each student has an individual record with a field name userGroup which holds a string nominated by their classroom teacher, such as "year7", "year 8" and so on while they are in one of the several classrooms, but when they leave school this is recorded in a field named noGroup with a value of 0 or 1. I can post further details as required, but it would be great if someone could help me. [attachment deleted by admin]
  23. Got it with this. $nogroup = ((!$egroup1) && (!$egroup2) && (!$egroup3) && (!$egroup4) && (!$egroup5) && (!$egroup6)); $noequip = (!$equip); if ($nogroup){ $errorMsg .= "--- Student Group. (No data was forwarded to the database.)</font>"; } else if($noequip){ $errorMsg .= "--- Quiz Name. (No data was forwarded to the database.)</font>"; } else { Thanks for your help.
  24. Sorry Mr Adam, don't understand. I'll post my script here and see if you can figure out what I'm doing wrong. I've posted the working script with the part I cannot get to work is commented out. (lines 54-68) If I uncomment the lines the script stops. Any help? [attachment deleted by admin]
×
×
  • 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.