Jump to content

mishuk

Members
  • Posts

    48
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mishuk's Achievements

Member

Member (2/5)

0

Reputation

  1. Is it possible to order the results of an sql statement by specifying which value you want at the top of the list and the rest can be in any order. For example if i had a table that had the values 1 - 10 in them and i wanted to select each value but wanted the value 5 at the top followed by the rest. e.g 5 1 2 3 4 6 7 and so on Is this possible in any way?
  2. I am working with graphs that get their results from a table in the database but first the user will select a year the reports are to be produced for. The user selects a year from the page. This is submitted and the next page which populates a variable $year with the value from ($_POST['year']). This page then produces the result of the query for the year specified into a table. I then have a seperate php file that stores the query again and produces a graph for the relevant query. However i can not pass the $_POST variable to the file that contains the graph. ----------------------------------------- report.php------------------------------ $year = ($_POST['year']); ?> <br> <TABLE BORDER="1" CELLSPACING="0" CELLPADDING="5" ALIGN="center" BORDERCOLOR="#C8C8C8"> <tr> <td colspan="2" bgcolor="#F1F1F1">1. On a scale of 1 to 10, how useful did the learners find the Thackray Days?</td> </tr> <tr> <td><? $query_string = "SELECT q1, count(q1) FROM tbl_y9 WHERE q1 IS NOT NULL AND year = $year GROUP BY q1 Order By q1 ASC"; $result_id = mysql_query($query_string); $column_count = mysql_num_fields($result_id); print("<TABLE BORDER=1 ALIGN=center BORDERCOLOR=\"#C8C8C8\" cellspacing=0 cellpadding=2>\n"); print("<TR>"); print("<TD BGCOLOR = #F1F1F1>Rating</TD>\n"); print("<TD BGCOLOR = #F1F1F1>Rating Count</TD>\n"); print("</TR>"); while ($row = mysql_fetch_row($result_id)) { print("<TR ALIGN=center VALIGN=TOP>"); for ($column_num = 0; $column_num < $column_count; $column_num++) print("<TD BGCOLOR = #FFFFFF>$row[$column_num]</TD>\n"); print ("</TR>\n"); } print ("</TABLE>\n"); ?> </td> <td><p align = "center"><img src="/careers/graph/y9q1.php"></p></td> </tr> <tr> ------------------------------------------------------------------------------------------- ------------------------------------------ y9q1.php --------------------------------- include ("../includes/db_connect.php"); include('../includes/postgraph.class.php'); $query = "SELECT q1, count(q1) FROM tbl_y9 WHERE q1 IS NOT NULL GROUP BY q1 Order By q1 ASC"; $result = mysql_query($query) or die(mysql_error()); code continues --------------------------------------------------------------------------------------------- How can i pass the $_post variable into y9q1.php as well as passing it to reports.php Hope this makes sence. Thanks
  3. hi i am working on populating a drop down menu with a select statement and have got so far. The drop down box is populated with value however the value are null. Can anyone help? $query="select distinct(house_type) from tbl_accommodation"; $stmt = ociparse($conn, $query); ociexecute($stmt); echo '<select name="house_type">'; echo '<option value = "-1">Select:</option>'; while($row=ocifetch($stmt)) { echo $row; echo '<option value=' . $row['house_type'] . '>' . $row['house_type'] . '</option>'; } echo '</select>';
  4. Still doesnt wor. Here is a bigger chunk of the script. At the beginning of the while $ethnicity is populated with the result from the student query eg $ethnicity = 1 and i want to then dynamically generate the below drop down menu with the ethnicity corresponding to the $ethnicity selected $res=mysql_query("select * from tbl_student where stud_id = $student"); while($row = mysql_fetch_array($res)) { $ethnicity = $row['ethnic_id']; ?> <FORM method="post" action="admin.php?do=editstu"> <TABLE BORDER="0" ALIGN="center"> <TR> <TD>Ethnicity:</TD> <TD> <? $res=mysql_query("select ethnic_id, ethnicity from tbl_ethnicity"); if(mysql_num_rows($res)==0) { echo "No Data"; } else { echo '<select name="ethnicity">'; echo '<option value = "-1">Select:</option>'; while($row=mysql_fetch_assoc($res)) { echo '<option value="' . $row['ethnicity_id'] . '">' . $row['ethnicity'] . '</option>'; } echo '</select>'; }; ?> </TD> </TR> <TR> <TD><input name="submit" type="submit" value="Update Student"></TD> <TD><input name="reset" type="reset" value="Reset"></TD> </TR> </TABLE> </FORM> Thanks
  5. unfortunately still no joy Parse error: syntax error, unexpected T_IF
  6. yeh sorry that was me being careless. Already tried that and get the error Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in ... on line 275 here is the full line echo '<option value="' . $row['ethnicity_id'] . '" if ($ethnicity == $row['ethnicity_id']) echo "selected">' . $row['ethnicity'] . '</option>';
  7. Cheers for the help. Carrying on from this. can i dynamically place a "selected" option in this drop down menu. something like echo '<option value="' . $row['ethnicity_id'] . '" if ($ethnicity=$row['ethnicity_id'] echo "selected">' . $row['ethnicity'] . '</option>'; What would be the correct syntax? $res=mysql_query("select ethnic_id, ethnicity from tbl_ethnicity"); if(mysql_num_rows($res)==0) { echo "No Data"; } else { echo '<select name="ethnicity">'; echo '<option value = "-1">Select:</option>'; while($row=mysql_fetch_assoc($res)) { echo '<option value="' . $row['ethnicity_id'] . '">' . $row['ethnicity'] . '</option>'; } echo '</select>'; };
  8. checked="checked" is there an oposite to "checked" e.g "unchecked"
  9. Hi. I am attempting to create an update form where the current fields in the table are populated into input boxes and then can be altered where necessary. I was wondering if it is possible to pre check radio buttons, check boxes and pre populate drop down menus based on the results currently in the table. eg. if the gender of a person is male then the radio button will be pre checked as male. How would this be done.?
  10. Hi. Using the script below i am trying to populate a bar chart with results from a query instead of static values (these being the values in the commented $data). I have managed to get to a stage where i get two bars, both of student count 9 one with a 0 for the title for the column and the other with SchNo. Can anyone please help? Thanks include ("../includes/db_connect.php"); include('../includes/postgraph.class.php'); $query = "SELECT count(s.school_id) SchNo FROM tbl_school a, tbl_student s WHERE a.school_id = s.school_id GROUP BY s.school_id"; $result = mysql_query($query) or die(mysql_error()); //$data = array(1 => 9, 11, 26, 31, 22, 19, 21, 29, 9, 11, 5, 10, 8, 9, 9); $data = mysql_fetch_array($result); $graph = new PostGraph(350,200); $graph->setGraphTitles('Number of students for each school', 'Schoo', 'Number of Students'); $graph->setYNumberFormat('integer'); $graph->setYTicks(10); $graph->setData($data); $graph->setXTextOrientation('horizontal'); $graph->drawImage(); $graph->printImage();
  11. I have a page that relies on two variables being passed into it for the year and the school in question. A user can then select a child from the list (list of children in school specified by variable) and enter their details. My problem is that when my check script throws back the page either due to field not selected or data inputted I get an error $school = ($_POST['school']); $year = ($_POST['year']); if($logged_in){ ?> <FORM action = "admin.php?do=addy9" method = "post"> <table ALIGN="center" border="0" cellspacing="2"> <tr> <td colspan="2" bgcolor="#FFFFFF" align="center"><h1>Add Year 9 Feedback Form</h1></td> </tr> <TR> <TD colspan="2" bgcolor="#FFFF00"><? if (isset($message)) echo "<b>$message<br><br></b>"; ?></TD> </TR> <tr> <td>Please select a student from the list:</td> <td> <? $res=mysql_query("select stud_id, surname, forename from tbl_student where school_id = $school AND year = $year"); if(mysql_num_rows($res)==0) { echo "No Data"; } else { echo '<select name="student">'; echo '<option value = "-1">Select:</option>'; while($row=mysql_fetch_assoc($res)) { echo '<option value="' . $row['stud_id'] . '">' . $row['surname'] .' '. $row ['forename'] . '</option>'; } echo '</select>'; }; ?> <input type="hidden" name="year" value = <? echo $year; ?> /> </td> </tr> </table> <br> // form continues // Check script, checks validity of form being submitted. case "addy9": if (!$_POST['student'] || $_POST['student'] == "-1") { unset ($_GET['do']); $message = "Please select a student"; include("addy9.php"); } else { //assign variables to $_POST $stud = ($_POST['student']); $year = ($_POST['year']); $q1 = ($_POST['q1']); $q2a = ($_POST['q2a']); $q2b = ($_POST['q2b']); $q3 = ($_POST['q3']); $q4 = ($_POST['q4']); $q5a = ($_POST['q5a']); $q5b = ($_POST['q5b']); // insert data into tbl_student $addy9feedback = "INSERT INTO tbl_y9 (stud_id, year, q1, q2a, q2b, q3, q4, q5a, q5b) VALUES ('$stud', '$year', '$q1', '$q2a', '$q2b', '$q3', '$q4', '$q5a', '$q5b')"; $result = mysql_query($addy9feedback) or die(mysql_error()); if (mysql_affected_rows() == 1) { $message = "Entry added."; include("addy9.php"); } else { error_log(mysql_error()); $message = "Error: please try again. If the error continues to occur containt the system administrator"; include("addy9.php"); } } break; So when the include is called the variables school and year are no longer populated. How can i solve this. thanks
  12. Hi I have used the code below and so far works as it should. However i would further like to place the results into a simple table and was wondering whats the best way of doing this? Tahanks output example Column 1 Column2 Column 3 ...... values values value ....... $curs = OCINewCursor($conn); $stmt = OCIParse($conn,"begin p_all_houses(_ten_type, _recordset); end;"); OCIBindByName($stmt,"_ten_type",&$tenant,32); OCIBindByName($stmt,"_recordset",&$curs,10,OCI_B_CURSOR); ociexecute($stmt); ociexecute($curs); while (OCIFetchInto($curs,&$p_recordset)) { echo "<pre>"; print_r($p_recordset ); echo "</pre>"; } Produces this Array ( [0] => 6 [1] => 2 [2] => 4 Sevensea Avenue [4] => Sheffield [5] => S4 5JS [6] => family [7] => detached [8] => 0 ) .................
  13. Can something be used in an if statement that works like a break; in a switch statement. I would like to exit the if statement and carry on with the rest of the script if a certain value is true e.g. if $var = 1 { exit if and carry on with script } else { [statement] } rest of script....
×
×
  • 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.