Jump to content

lwaters5

New Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by lwaters5

  1. Ok, I think I am getting real close now. Here is my code: <?php date_default_timezone_set('America/New_York'); ?> <?php require_once('../../Connections/connect.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = "0,2,3,4,5,6,7"; $MM_donotCheckaccess = "false"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && false) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "error2.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_connect, $connect); $idList = implode(',', $_POST['UID']); $sql = 'SELECT *, scholarships.NAME as scholarshipname FROM scholarships, gc_codes, users INNER JOIN stu_app2008 ON users.UID = stu_app2008.UID INNER JOIN activities ON users.UID = activities.UID INNER JOIN coll_exp ON users.UID = coll_exp.UID INNER JOIN employ ON users.UID = employ.UID INNER JOIN fin_app ON users.UID = fin_app.UID INNER JOIN finaid ON users.UID = finaid.UID INNER JOIN stu_special ON users.UID = stu_special.UID WHERE gc_codes.GCID = users.GC and scholarships.ID = stu_special.ID and UID in (' . $idList . ')'; $res = mysql_query($sql); $varlist = array(); while ($row = mysql_fetch_assoc($res)) { $varlist[$row['UID']] = $row; } ?> This is the error message that I get: Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\Scholarship\admin\printable_version2_test3.php on line 87
  2. Thanks so much for your quick response and help. As you can see I am a newbie to PHP . So I replaced the code with your code and I am still getting some errors. Here is the new code: <?php date_default_timezone_set('America/New_York'); ?> <?php require_once('../../Connections/connect.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_connect, $connect); $idList = implode(',', $_POST['UID']); $sql = 'SELECT * FROM users WHERE UID in (' . $idList . ')'; $res = mysql_query($sql); $varlist = array(); while ($row = mysql_fetch_assoc($res)) { $varlist[$row['UID']] = $row; } date_default_timezone_set('America/New_York'); ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title><br /> <style> .break { page-break-before: always; } </style> </head> <body><?php foreach ($varlist as $UID => $row) do { ?> <p class="break"><strong><?php echo $varlist['FNAME']; ?> <?php echo $varlist['LNAME']; ?></strong></p> <fieldset id="el11"><legend><strong>Section 1: Applicant Information</strong></legend> <table width="100%" border="0" cellspacing="1" cellpadding="6"> <tr bgcolor="#c2bdaf"> <td width="26%" valign="top"><strong>Name: </strong><?php echo $varlist['FNAME']; ?> <?php echo $varlist['LNAME']; ?></strong></font></strong></td> <td valign="top"><strong>Gender: </strong><?php echo $varlist['GENDER']; ?></strong></font></strong></td> <td valign="top"><strong>SID: </strong><?php echo $varlist['SID']; ?></strong></font></strong></td> </tr> <tr> <td colspan="2" valign="top" bgcolor="#FFFFFF"><strong>Address: </strong><?php echo $varlist['ADDRESS']; ?></strong></font></strong></td> <td valign="top" bgcolor="#FFFFFF"><strong>Homeroom: </strong><?php echo $varlist['HR']; ?></strong></font></strong></td> </tr> <tr bgcolor="#c2bdaf"> <td valign="top"><strong>Telephone: </strong><?php echo $varlist['TEL']; ?></strong></font></strong></td> <td valign="top"><strong>LC: </strong><?php echo $varlist['LC']; ?></strong></font></strong></td> <td valign="top"><strong>GC: </strong><?php echo $varlist['GC']; ?></strong></font></strong></td> </tr> <tr> <td valign="top" bgcolor="#FFFFFF"><strong>Email: </strong><?php echo $varlist['UNAME']; ?></strong></font></strong></td> <td colspan="2" valign="top" bgcolor="#FFFFFF"><strong>Elementary School:</strong> <?php echo $varlist['ELEM']; ?></td> </tr> </table> </fieldset> <?php } while ($varlist = mysql_fetch_array($your_scholarships)); ?> </body> </html> <?php mysql_free_result($your_scholarships); ?> I think my error is in the line: <?php } while ($varlist = mysql_fetch_array($your_scholarships)); ?> at the bottom of the code and where I tell it to show the data using this type of code: <?php echo $varlist['HR']; ?> Thanks again.
  3. Sorry about that, here is my code for the results page. I have it repeating each table now but, it is not repeating the data within the table. mysql_select_db($database_connect, $connect); foreach ($_POST['UID'] as $value) { $SQLquery = $query_your_scholarships = "SELECT * FROM users WHERE UID = $value"; $your_scholarships = mysql_query($query_your_scholarships, $connect) or die(mysql_error()); $varlist = mysql_fetch_array ($your_scholarships); echo $varlist['UID'] . ": " . $varlist['FNAME'] . " " . $varlist['LNAME'] . "<br />"; } date_default_timezone_set('America/New_York'); ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title><br /> <style> .break { page-break-before: always; } </style> </head> <body><?php foreach ($_POST['UID'] as $value) do { ?> <p class="break"><strong><?php echo $varlist['FNAME']; ?> <?php echo $varlist['LNAME']; ?></strong></p> <fieldset id="el11"><legend><strong>Section 1: Applicant Information</strong></legend> <table width="100%" border="0" cellspacing="1" cellpadding="6"> <tr bgcolor="#c2bdaf"> <td width="26%" valign="top"><strong>Name: </strong><?php echo $varlist['FNAME']; ?> <?php echo $varlist['LNAME']; ?></strong></font></strong></td> <td valign="top"><strong>Gender: </strong><?php echo $varlist['GENDER']; ?></strong></font></strong></td> <td valign="top"><strong>SID: </strong><?php echo $varlist['SID']; ?></strong></font></strong></td> </tr> <tr> <td colspan="2" valign="top" bgcolor="#FFFFFF"><strong>Address: </strong><?php echo $varlist['ADDRESS']; ?></strong></font></strong></td> <td valign="top" bgcolor="#FFFFFF"><strong>Homeroom: </strong><?php echo $varlist['HR']; ?></strong></font></strong></td> </tr> <tr bgcolor="#c2bdaf"> <td valign="top"><strong>Telephone: </strong><?php echo $varlist['TEL']; ?></strong></font></strong></td> <td valign="top"><strong>LC: </strong><?php echo $varlist['LC']; ?></strong></font></strong></td> <td valign="top"><strong>GC: </strong><?php echo $varlist['GC']; ?></strong></font></strong></td> </tr> <tr> <td valign="top" bgcolor="#FFFFFF"><strong>Email: </strong><?php echo $varlist['UNAME']; ?></strong></font></strong></td> <td colspan="2" valign="top" bgcolor="#FFFFFF"><strong>Elementary School:</strong> <?php echo $varlist['ELEM']; ?></td> </tr> </table> </fieldset> <?php } while ($varlist = mysql_fetch_array($your_scholarships)); ?> </body> </html> <?php mysql_free_result($your_scholarships); ?>
  4. Using this code: <form id="form1" name="form1" method="post" action="test4.php"> <?php do { ?> <p> <input name="UID[]" type="checkbox" id="UID" value="<?php echo $row_applicants['UID']; ?>" /> <label for="UID"></label> <?php echo $row_applicants['FNAME']; ?> <?php echo $row_applicants['LNAME']; ?> </p> <?php } while ($row_applicants = mysql_fetch_assoc($applicants)); ?> <p> <input type="submit" name="button" id="button" value="Submit" /> </p> </form> I pass the checkbox field to another page that displays the profiles for each UID. I am getting the content boxes to repeat but, the information in the boxes are not repeating. Any advice? Here is the results page: mysql_select_db($database_connect, $connect); foreach ($_POST['UID'] as $value) { $SQLquery = $query_your_scholarships = "SELECT * FROM users WHERE UID = $value"; $your_scholarships = mysql_query($query_your_scholarships, $connect) or die(mysql_error()); $varlist = mysql_fetch_array ($your_scholarships); echo $varlist['UID'] . ": " . $varlist['FNAME'] . " " . $varlist['LNAME'] . "<br />"; } date_default_timezone_set('America/New_York'); ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title><br /> <style> .break { page-break-before: always; } </style> </head> <body><?php foreach ($_POST['UID'] as $value) do { ?> <p class="break"><strong><?php echo $varlist['FNAME']; ?> <?php echo $varlist['LNAME']; ?></strong></p> <fieldset id="el11"><legend><strong>Section 1: Applicant Information</strong></legend> <table width="100%" border="0" cellspacing="1" cellpadding="6"> <tr bgcolor="#c2bdaf"> <td width="26%" valign="top"><strong>Name: </strong><?php echo $varlist['FNAME']; ?> <?php echo $varlist['LNAME']; ?></strong></font></strong></td> <td valign="top"><strong>Gender: </strong><?php echo $varlist['GENDER']; ?></strong></font></strong></td> <td valign="top"><strong>SID: </strong><?php echo $varlist['SID']; ?></strong></font></strong></td> </tr> <tr> <td colspan="2" valign="top" bgcolor="#FFFFFF"><strong>Address: </strong><?php echo $varlist['ADDRESS']; ?></strong></font></strong></td> <td valign="top" bgcolor="#FFFFFF"><strong>Homeroom: </strong><?php echo $varlist['HR']; ?></strong></font></strong></td> </tr> <tr bgcolor="#c2bdaf"> <td valign="top"><strong>Telephone: </strong><?php echo $varlist['TEL']; ?></strong></font></strong></td> <td valign="top"><strong>LC: </strong><?php echo $varlist['LC']; ?></strong></font></strong></td> <td valign="top"><strong>GC: </strong><?php echo $varlist['GC']; ?></strong></font></strong></td> </tr> <tr> <td valign="top" bgcolor="#FFFFFF"><strong>Email: </strong><?php echo $varlist['UNAME']; ?></strong></font></strong></td> <td colspan="2" valign="top" bgcolor="#FFFFFF"><strong>Elementary School:</strong> <?php echo $varlist['ELEM']; ?></td> </tr> </table> </fieldset> <?php } while ($varlist = mysql_fetch_array($your_scholarships)); ?> </body> </html> <?php mysql_free_result($your_scholarships); ?>
  5. HI, I am a newbie using Dreamweaver to create a form that has a checbox next to students's names. Once you select the student's you wish to see, you hit submit and it sends you to anther page where it displays the profiles for each of these students so they can be printed. My form looks like this: <form id="form1" name="form1" method="post" action="test4.php"> <?php do { ?> <p> <input name="UID[]" type="checkbox" id="UID" value="<?php echo $row_applicants['UID']; ?>" /> <label for="UID"></label> <?php echo $row_applicants['FNAME']; ?> <?php echo $row_applicants['LNAME']; ?> </p> <?php } while ($row_applicants = mysql_fetch_assoc($applicants)); ?> <p> <input type="submit" name="button" id="button" value="Submit" /> </p> </form> My test results page looks like this: mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $UID = $_POST['UID']; $query = "SELECT * FROM users WHERE UID = ('$UID')"; $results = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($results)==1){ // If there is only one row that was returned $results = mysql_fetch_array($results); echo $results['UID']; // If the column name is incorrect, just change it to match }elseif(mysql_num_rows($results)>1){ // If there is more than one row that was returned while($result=mysql_fetch_array($results)){ // Loop through each row that was returned and display it echo $result['UID']." "; } }else{ //If there were no rows returned, this is just to account for every option and is entirely optional echo "No matched!"; } I want the end result page to look like the attached file with multiple profiles. Thanks in advance
  6. I am a newbie and I am trying to do a site scraping project to obtain all the following fields: Test Year, Test Name, Grade Level, Question #, Question Type, Reporting Category, Standard #, Standard description, Example Question (with image) for this web page that has a page for each question. http://www.doe.mass.edu/mcas/search/question.aspx?mcasyear=2010&QuestionSetID=1&grade=8&subjectcode=MTH&questionnumber=36 I am a newbie at PHP and would love if you could point me in the right direction. The page uses tables and I need to extract the data from the body of the page as well as some of the info from the url and then have it inserted into a MySQL database. Thank you so much for your help.
×
×
  • 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.