Jump to content

Mufleeh

Members
  • Posts

    36
  • Joined

  • Last visited

Everything posted by Mufleeh

  1. Hi All, I have an issue with the session variable. shoppingcart.php is the first file executed and contains the following code, $postal_charges = get_meter_square() * $postageRate; $_SESSION['postalcharges'] = $postal_charges; and once the 'Proceed' button is pressed its re-directed to purchase.php as following, window.location='purchase.php'; In purchase.php the value of $_SESSION['postalcharges'] doesn't read. But if I go back and click on 'Proceed' again it reads. Moreover this happens only on Firefox latest one. Can anyone help me on this?
  2. Hi all, Firstly, I belie I am asking this question at the correct section of this forum. If not please advice me with regard. My problem is.... I am in the process of developing a Course Evaluation System for my final year project. System is to be built using PHP + MySQL. Briefly, I must be able to design a form, scan it using an image scanner and upload them to the server using my system for data analysis and reports generation. I mean this system must have the following functions, 1. Form design 2. Scan forms (using a scanner) 3. Extract data from scanned documents (using some OMR mechanisms) Leaving report generation things aside, I am wondering how can I use PHP to accomplish these tasks. I am allowed to use open source applications when ever possible like queXML and queFX that are developed for designing and OMR respectively. As I ran through them I realize the complexity of those applications and hardship of integrating them to mine. I believe an expert of PHP can advice on this matter...can you please? Thanks in advance, Mufleeh
  3. Hi, I am receiving below error message. PDOStatement::errorInfo(): Array ( [0] => 00000 [1] => 7 [2] => ERROR: syntax error at or near "." LINE 1: SELECT * .view_teachers_information, * .view_teachers_first_... ^ ) Regards, Mufleeh
  4. Hi, Firstly I'm really sorry for not submitting my question properly. Please refer below and check whether its possible to help me out. - I assume that "nic" is a unique ID for each teacher. - Yes it is - Is there only ONE record per teacher (or nic) in the "view_teachers_info" table or can there be multiple? - Only one record per teacher - Is there only ONE record per teacher (or nic) in the "view_teachers_first_school" table or can there be multiple? - Only one record per teacher - Is it possible for a record to exist in one of those tables associated with a "nic" but no record(s) in the other table for the same "nic"? If so, is there one table that will have at least one associated record for each "nic" or is there one table that should be considered the "primary"? That means if there is a record in the primary, but no associated record in the secondary, it should be included in the results. But, if an associated record exists in the secondary, but not the primary, it will not display in the results. All the records (teachers/nic) in view_teachers_info also in view_teachers_first_school. We can consider view_teachers_info as the primary table.
  5. Hi, Every views are linked with a field 'nic' and different fields from different views have to be retrieved. I tried doing that linking the keys in different views. But it seems like there is an issue. $query = $this->dbh->prepare("SELECT * FROM view_teachers_info, view_teachers_first_school, view_teachers_current_school WHERE view_teachers_info.nic IN (SELECT nic FROM view_teachers_current_school WHERE school_id = '$this->schoolId') AND view_teachers_current_school.nic = view_teachers_first_school.nic AND view_teachers_first_school.nic = view_teachers_information.nic ");
  6. Hi all, Thanks for the responses, I need different fields from those two views. In example I need the schoolname and grade from view_teachers_info and startdate from view_teachers_first_school. This seems to be not possible in the way you've suggested. Please advice. Regards, Mufleeh
  7. Hi, I have been using below 2 queries separately and they are working fine. Queries are from views, now I want them to be joined and display the data in one single table. I couldn't make it in the way I tried, can anyone please let me know a better way? $query = $this->dbh->prepare("SELECT * FROM view_teachers_info WHERE nic IN (SELECT nic FROM view_teachers_current_school WHERE school_id = '$this->schoolId')"); $query = $this->dbh->prepare("SELECT * FROM view_teachers_first_school WHERE nic IN (SELECT nic FROM view_teachers_current_school WHERE school_id = '$this->schoolId')"); What I tried was simply, $query = $this->dbh->prepare("SELECT * FROM view_teachers_info,view_teachers_first_school WHERE nic IN (SELECT nic FROM view_teachers_current_school WHERE school_id = '$this->schoolId')"); Regards, Mufleeh
  8. Hi, I am sorry its bit confusing to me. When I made it as below inside my php script, echo "var s1 = jQuery.parseJSON(".json_encode($stackDiv).");"; echo "var ticks = jQuery.parseJSON(".json_encode($stackCount).");"; Browser displays the data inside the arrays as below. var s1=jQuery.parseJSON([22,32,45,56]) var ticks=jQuery.parseJSON([12,35,32,11]) But how can I pass this into javascript out side the php (in the same page) and get the graph displayed?
  9. Hi, Thanks for your response. Do you mean that if I write the above code inside PHP then I can use those variables inside js as an Array? It doesn't work as I expected. I have given you how my code looks like, can you figure out what could we do? <!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"> <link rel="stylesheet" type="text/css" href="css/jquery.jqplot.css" /> <link rel="stylesheet" type="text/css" href="css/examples.css" /> <script language="javascript" type="text/javascript" src="js/jquery.js"></script> <script language="javascript" type="text/javascript" src="js/jquery.jqplot.js"></script> <script language="javascript" type="text/javascript" src="js/jqplot.barRenderer.js"></script> <script language="javascript" type="text/javascript" src="js/jqplot.categoryAxisRenderer.js"></script> </head> <body> <?php // PHP starts function myFunction(){ // function starts here //function codes here "var s1 = jQuery.parseJSON(".json_encode($stackDiv).");"; "var ticks = jQuery.parseJSON(".json_encode($stackCount).");"; ?> // PHP closed // java script outside PHP <script class="code" type="text/javascript">$(document).ready(function(){ plot1 = $.jqplot('chart1', [s1], { seriesDefaults:{ renderer:$.jqplot.BarRenderer, pointLabels: { show: true } }, axes: { xaxis: { renderer: $.jqplot.CategoryAxisRenderer, ticks: ticks } }, highlighter: { show: false } }); $('#chart1').bind('jqplotDataClick', function (ev, seriesIndex, pointIndex, data) { $('#info1').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data); } ); });</script> <div id="chart1" style="margin-top:20px; margin-left:20px; width:300px; height:300px;"></div> <?php // PHP reopened } // myFunction function close other functions and codes ?> // PHP closed </body> </html>
  10. Hi, Thanks for your support. My arrays are one dimensional and stored in 2 variables like $arrayOne and $arrayTwo. As you see in the above java script(example) there are two variables s1 and ticks have been defined and made them equal to 2 arrays that comes in to the graph x and y. If we keep the js out of php we can't make it as below right? var s1= $arrayOne var ticks = $arrayTwo So how can I do this? Regards, Mufleeh
  11. well, I need to plot a graph using data retrieved from the data base. I have the data within 2 different arrays. This above js is the code to create the graph and I have to pass the data (which are in the arrays) to js. Is there any other way to do it?
  12. Hi All, I need to plot a graph retrieving data from my data base. I have done all the codings to get the data and store them to 2 different arrays.I though of using jquery to create the graphs. Below is the script has to be added to generated the grahp. I was wondering how to get this within the function in my php script. Can anyone help me fixing this? <script class="code" type="text/javascript">$(document).ready(function(){ var s1 = [2, 6, 7, 10]; var ticks = ['a', 'b', 'c', 'd']; plot1 = $.jqplot('chart1', [s1], { seriesDefaults:{ renderer:$.jqplot.BarRenderer, pointLabels: { show: true } }, axes: { xaxis: { renderer: $.jqplot.CategoryAxisRenderer, ticks: ticks } }, highlighter: { show: false } }); $('#chart1').bind('jqplotDataClick', function (ev, seriesIndex, pointIndex, data) { $('#info1').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data); } ); });</script> <div id="chart1" style="margin-top:20px; margin-left:20px; width:300px; height:300px;"></div> Regards, Mufleeh
  13. Hi, I am sorry, I can not exactly understand what do you mean. I receive the above thing when I used ->errorInfo() in my coding. This is how I used it. print_r($this->dbh->errorInfo()); Regards, Mufleeh
  14. Hi, I need to plot a graph for Math teaches vs division for a given zone. I will be using js to draw the graph so I need to make up the table first. The table I need is some thing like this. Division1 Division2 Division3 Division4 Division5 No.Of teachers in division1 No.Of teachers in division2 No.Of teachers in division3 No.Of teachers in division4 No.Of teachers in division5 Below is how I select the zone,' <p><b>Select the Zone to Generate the Graph for Mathematics Teacher Distribution:</b></p> <form method="post" id="graphMathsTeacherbyDivision" action="<?php echo $_SERVER['SCRIPT_NAME']?>"> <select name="selectZone"> <?php foreach($this->allZones as $zone) { echo "<option"; echo " value='$zone[zone_id]' "; echo ">"; echo $zone['zone_id'].": ".$zone['zone_name']; echo "</option>"; }?> </select> <input type="submit" name='zone_id' value="Generate Graph"/> </form></br></br> Below is how I have written the query, $selectZone = $_POST['selectZone']; $query = $this->dbh->prepare("SELECT division_id FROM view_zone_division_district_province WHERE zone_id='$selectZone'"); $query->execute(); $divisions = $query->fetchall(); foreach($divisions as $div) { $queryMe = $this->dbh->prepare("SELECT nic FROM view_teachers_current_school_appointment WHERE appointment_category_name = 'Mathematics' AND census_id IN (SELECT census_id FROM view_schools WHERE division_id = '$div[division_id]')"); $queryMe->execute(); $count = $queryMe->fetchall(); } What I need to is to get the number of teachers from second query. I tried it writing count($count) but it doesn't give me the count. Please let me know how to do this? If you can please let me know below also, I need to create the table (as above) which gives the division and the respective number of teachers in that division. Please advice. Regards, Mufleeh
  15. Hi, It displays below error, Array ( [0] => 00000 [1] => [2] => ) 0Array ( [0] => 00000 [1] => [2] => ) 0Array ( [0] => 00000 [1] => [2] => ) 0Array ( [0] => 00000 [1] => [2] => ) 0
  16. Hi, I need the count of the retrieved results from my data base. Below coding isn't working can anyone fix this to me? $queryMe = $this->dbh->prepare("SELECT name_initials FROM view_teachers_information WHERE nic IN (SELECT nic FROM view_teachers_current_school_appointment WHERE appointment_category_name = 'Mathematics' AND census_id IN (SELECT census_id FROM view_schools WHERE division_id = '$div[division_id]'))"); $queryMe->execute(); $countMe = $queryMe->fetchall(); $result = count($countMe); echo $result; Regards, Mufleeh
  17. Hi, I noted it and I'll do in in future. Below is the error message I am receiving now! PDOStatement::errorInfo(): Array ( [0] => 00000 [1] => 7 [2] => ERROR: operator does not exist: character varying = integer LINE 1: ...ELECT census_id FROM view_schools WHERE division_id = 010114 ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. ) PDOStatement::errorInfo(): Array ( [0] => 00000 [1] => 7 [2] => ERROR: operator does not exist: character varying = integer LINE 1: ...ELECT census_id FROM view_schools WHERE division_id = 010115 ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. ) PDOStatement::errorInfo(): Array ( [0] => 00000 [1] => 7 [2] => ERROR: operator does not exist: character varying = integer LINE 1: ...ELECT census_id FROM view_schools WHERE division_id = 010116 ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. ) PDOStatement::errorInfo(): Array ( [0] => 00000 [1] => 7 [2] => ERROR: operator does not exist: character varying = integer LINE 1: ...ELECT census_id FROM view_schools WHERE division_id = 010117 ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. )
  18. Hi, Thanks for your response, yes its inside a class I'll use $this where its possible. Below is the entire function I am working with. Also I'll change the count(nic) to count(*). If you see any errors in my function please let me know, also please note that the code works well up to foreach($divisions as $div) function graphMathsTeacherbyDivision() { //echo '<p><b>Select the Zone to Generate the Graph for Mathematics Teacher Distribution:</b></p>'; //Query for all Zones $query = $this->dbh->prepare("SELECT * FROM zones"); $query->execute(); $this->allZones = $query->fetchall(); $query = NULL; ?> <!--form inside HTML--> <p><b>Select the Zone to Generate the Graph for Mathematics Teacher Distribution:</b></p> <form method="post" id="graphMathsTeacherbyDivision" action="<?php echo $_SERVER['SCRIPT_NAME']?>"> <select name="selectZone"> <?php foreach($this->allZones as $zone) { echo "<option"; echo " value='$zone[zone_id]' "; echo ">"; echo $zone['zone_id'].": ".$zone['zone_name']; echo "</option>"; }?> </select> <input type="submit" name='zone_id' value="Generate Graph"/> </form> $selectZone = $_POST['selectZone']; // get the data from the user $query = $this->dbh->prepare("SELECT division_id FROM view_zone_division_district_province WHERE zone_id='$selectZone'"); $query->execute(); $divisions = $query->fetchall(); //Below this it seems to be an issue [color=red]foreach($divisions as $div)[/color] { $query = $this->dbh->prepare("SELECT COUNT(nic) FROM teachers_info WHERE (subject_name = 'Mathematics' AND school_id IN(SELECT school_id FROM schools WHERE division_id = $div))"); $query->execute(); $count = $query->fetchall(); ] echo "<tr>"; $i = $i + 1; echo "<td>$i.</td> <td>" .$count."</td>"; echo "</tr>"; }
  19. Hi cyberRobot, Thanks for your response! I made the it but there are problems in the queries if you could help me it would be really appriciated, http://www.phpfreaks.com/forums/index.php?topic=338495.0 Regards, Mufleeh
  20. Hi all, I want the count of math teachers for a given zone. A single zone can have several divisions and and a single division can have many schools and a school can have many math teachers. Below is my query and it doesn't work as I expected. Can you please try to fins if I have made any errors? $selectZone = $_POST['selectZone']; // get the data from the user $query = $this->dbh->prepare("SELECT division_id FROM view_zone_division_district_province WHERE zone_id='$selectZone'"); $query->execute(); $divisions = $query->fetchall(); foreach($divisions as $div) { $query = $this->dbh->prepare("SELECT COUNT(nic) FROM teachers_info WHERE (subject_name = 'Mathematics' AND school_id IN(SELECT school_id FROM schools WHERE division_id = $div))"); $query->execute(); $count = $query->fetchall(); ] echo "<tr>"; $i = $i + 1; echo "<td>$i.</td> <td>" .$count."</td>"; echo "</tr>"; } Regards, Mufleeh
  21. Hi all, I have used a dropdown menu inside the <form> tag. There are list of zones and one will be selected. I would like to whether I can use PHP inside the <form></form> as I have used below and how to get the id of the selected one from the drop down men. Below is my code and it doesn't work as I expect, please advice. <form method="post" id="graphDraw" action="<?php echo $_SERVER['SCRIPT_NAME']?>"> <?php echo "<select name=\"".'zone_id'."_zone_".$zoneNo."\" style=\"width: 175px\">"; foreach($this->allZones as $zone) { echo "<option"; echo " value='$zone[zone_id]' "; echo ">"; echo $zone['zone_id'].": ".$zone['zone_name']; echo "</option>"; } echo"</select>"; ?> <input type="submit" value="Generate Graph"/> </form> Once the button is clicked I need to get the id (zone_id) of the selected zone in the drop down menu and send it to a query. Regards, Mufleeh
  22. Hi, Thanks its a great resource for me. Can you please correct the PHP that I have written using PDO as its not working? Regards, Mufleeh
  23. Hi, As you see, my scripts are written using PDO objects. So can I make your script as below and also please tell me how to define the axis of the graph with required fields? $result = $dbh->query($query); $rows = $result->fetchAll(PDO::FETCH_ASSOC); $data=array(); while($rows=fetch($result)) { $data[]=$rows; }
  24. Hi, I am trying with it...will keep you updated Regards, Mufleeh
  25. Hi, I have written below query which lists the information of Mathematics teachers for a given division. $query = $this->dbh->prepare("SELECT * FROM teachers_information WHERE nic IN (SELECT nic FROM teachers_current_school WHERE subject_name = 'Mathematics' AND school_id IN(SELECT school_id FROM schools WHERE division_id =(SELECT division_id FROM divisions WHERE division_name='$_POST[division_name]')))"); I displayed the results as below... foreach ($teachers AS $row) { echo "<tr>"; $i = $i + 1; echo "<td>$i.</td> <td>" .$row[division_id]."</td> <td>" .$row[nic]."</td> <td>" .$row[name_full]."</td> <td>". $row[date_of_birth]."</td> <td>". $row[sex]."</td> <td>". $row[address]."</td>"; } Now I need to plot a graph against the schools and the number of Math teachers. Here the schools can be indicated by school_id and also I believe the number of Math teachers can be taken from the row count. Below is a sample I got from the PHPlot manual which gives a basig graph and I am wondering how to replace the array with my queried results. Can anyone please help me to fix this? <?php //Include the code require_once 'phplot.php'; //Define the object $plot = new PHPlot(); //Define some data $example_data = array( array('a',3), array('b',5), array('c',7), array('d',, array('e',2), array('f',6), array('g',7) ); $plot->SetFontGD(x_label,5); $plot->SetFontGD(y_label,5); $plot->SetDataValues($example_data); //Turn off X axis ticks and labels because they get in the way: $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); //Draw it $plot->DrawGraph(); ?>
×
×
  • 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.