Jump to content

BigD

Members
  • Posts

    75
  • Joined

  • Last visited

Everything posted by BigD

  1. Question to Dsonesuk, Save as pdf file, how does that help with page break issue? Say I have a pdf file with 3 sets of info in it. I still need a page break at the end of each set. Can you show me an example to handle that.Not every one has a xps viewer, so I probably will not try to save as xps file.
  2. I had an idea. My onepage function is called once for each student to generate progress report. So I added a parm with the output file name. I am looping through 3 students and my echo showed 3 output files report0, report1, report2 should be generated.I thought this will resolve the pagebreak issue since each report is a one page progress report.Guess what? it only created report2 with 3 student's report. Do not know why. Here is part of the code:<?php//header("Pragma: no-cache");//header("Expires: 0");/*<head><style>@page { size 8.5in 11in; margin: 2cm }div.page { page-break-after: always }</style></head>*/include("../mylibrary/dograde.php");include("../mylibrary/login.php"); login(); function onepage($fname, $lname, $eval, $bdate, $edate, $classid, $stdid,$ofile){header("Content-type: application/vnd.ms-word");header("Content-Disposition: attachment; filename=$ofile.htm");?><html><body><?phpecho "create file $ofile";
  3. Birbal,Thanks for your post.In the 2nd piece of code I posted, it has how the function is called:if ($rpt == 'Y'){onepage($firstname, $lastname,$eval, $bdate, $edate, $classid, $stdid);// echo "<h7 style=/"page-break-after/: always;/">end of report></h7>";}I am not just using .doc extension to make a word file. This line of code should do that:header("Content-type: application/vnd.ms-word");My problem is - A school administrator will run my code that will create a .htm file with many student's progress report in that file.He/she presses the print button, one page will contain 1 and half of next student's report. How to make a page break at the end of each student's report?
  4. I am still puzzled on creating .htm files. So many people have written PHP codes to create .doc files and we seldom heard people unable to see the file content. Only difference I see is most people are using straight PHP code, not calling a function to create .doc files.
  5. I was wrong and JSG is right. Binary data did get written to the file. After I changed this line:header("Content-Disposition: attachment; filename=document/report.doc");toheader("Content-Disposition: attachment; filename=report.htm");I could open it with IE and see my report. New problem is: it has 3 student's report back to back. That is why I wanted to write to a word document and insert page break at the end of each student page. Now it is a .htm document, how do I insert page break?
  6. And if I do this to the function code: <?php function onepage($fname, $lname, $eval, $bdate, $edate, $classid, $stdid){header("Content-type: application/vnd.ms-word");header("Content-Disposition: attachment; filename=document/report.doc");echo "<html>";echo "<body>";echo "Hello";include("../mylibrary/dograde.php");include("../mylibrary/login.php"); login(); echo "<h1> xxxxx School of Massage</h2></br>";echo "<h3>17043 El Camino Real, Suite 201 xxxxx</h1></br>";echo "<h2>PROGRESS REPORT</h3></br>"; 'Hello' did not get written to word file. it is a blank file. So I think problem lies between a function andvnd.ms-word interfaces. I do not know how to overcome the problem though!
  7. You are right JSG, the function is called from the following code,<!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><link rel="stylesheet" type="text/css" href="print.css" /></head><?php include("../mylibrary/onepage.php"); $classid = $_REQUEST['classid']; $atnstd = $_REQUEST['atnstd']; $fname = $_REQUEST['fname']; $lname = $_REQUEST['lname']; $eval = $_REQUEST['rptno']; $sdate = $_REQUEST['sdate']; $bdate1 = $sdate; $edate1 = strtotime(date("Y-m-d", strtotime($bdate1)) . " +3 month"); $edate1 = date('Y-m-d', $edate1); $bdate2 = $edate1; $edate2 = strtotime(date("Y-m-d", strtotime($bdate2)) . " +3 month"); $edate2 = date('Y-m-d', $edate2); $bdate3 = $edate2; $edate3 = strtotime(date("Y-m-d", strtotime($bdate3)) . " +3 month"); $edate3 = date('Y-m-d', $edate3); $bdate4 = $edate3; $edate4 = strtotime(date("Y-m-d", strtotime($bdate4)) . " +3 month"); $edate4 = date('Y-m-d', $edate4); $bdate5 = $edate4; $edate5 = strtotime(date("Y-m-d", strtotime($bdate5)) . " +3 month"); $edate5 = date('Y-m-d', $edate5); if ($eval == 1) {$bdate = $bdate1; $edate = $edate1;} if ($eval == 2) {$bdate = $bdate2; $edate = $edate2;} if ($eval == 3) {$bdate = $bdate3; $edate = $edate3;} if ($eval == 4) {$bdate = $bdate4; $edate = $edate4;} if ($eval == 5) {$bdate = $bdate5; $edate = $edate5;} $i = 0; while ($stdid = array_shift($atnstd)) { $rpt = $_REQUEST['rpt'.$i]; $firstname = array_shift($fname); $lastname = array_shift($lname); // echo "rpt is $firstname<br/>"; if ($rpt == 'Y') { onepage($firstname, $lastname,$eval, $bdate, $edate, $classid, $stdid); // echo "<h7 style=/"page-break-after/: always;/">end of report></h7>"; } $i++; }?> In the 1st piece code if I do this :<?phpheader("Content-type: application/vnd.ms-word");header("Content-Disposition: attachment; filename=document/report.doc");//header("Pragma: no-cache");//header("Expires: 0");/*<head><style>@page { size 8.5in 11in; margin: 2cm }div.page { page-break-after: always }</style></head>*/echo "<html>";echo "<body>";echo "Hello";include("../mylibrary/dograde.php");include("../mylibrary/login.php"); login(); function onepage($fname, $lname, $eval, $bdate, $edate, $classid, $stdid) {echo "<h1> xxxxx School of Massage</h2></br>";echo "<h3>17043 El Camino Real, Suite 201 xxxxx</h1></br>";echo "<h2>PROGRESS REPORT</h3></br>"; Hello got written to the word file(and only that). So I do not think naming the file to .doc causes problem.Any suggestions?
  8. I think the problem is I am using a function call that does not work well with word. anything outside the function gets created in word file. I will change the code not to use function calls. Are there anyone able to use functions and word?
  9. I tried to write html page to word file. the word file is blank. Any one who knows how to do that please help. Here is my code, sorry it is lengthy: <?phpheader("Content-type: application/vnd.ms-word");header("Content-Disposition: attachment; filename=document/report.doc");//header("Pragma: no-cache");//header("Expires: 0");/* <html><head><style>@page { size 8.5in 11in; margin: 2cm }div.page { page-break-after: always }</style></head><body>*/include("../mylibrary/dograde.php");include("../mylibrary/login.php"); login(); function onepage($fname, $lname, $eval, $bdate, $edate, $classid, $stdid) {echo "<h1> xxxxx School of Massage</h2></br>";echo "<h3>17043 El Camino Real, xxxxxxxx</h1></br>";echo "<h2>PROGRESS REPORT</h3></br>";echo "<h4> Evaluation # $eval Begins: $bdate Ends: $edate</h4></br>";echo "Student Name $fname $lname !";$query = "SELECT score FROM test where classid = $classid and stdid = $stdid and testname = 'M&M'";//echo "SQL $query</br>"; $result = mysql_query($query) or die(mysql_error());$row = mysql_fetch_array($result, MYSQL_ASSOC);$mscore = $row['score'];$query = "SELECT score FROM test where classid = $classid and stdid = $stdid and testname = 'Hist'";$result = mysql_query($query) or die(mysql_error());$row = mysql_fetch_array($result, MYSQL_ASSOC);$hscore = $row['score'];//echo "mscore, hscore are $mscore, $hscore</br>";$score =($mscore+$hscore)/2;//echo "score, $score</br>";$grade = dograde($score); $mttp = 'S';echo "<table width=\"100%\" cellpadding=\"1\" border=\"1\">\n"; echo "<tr><td><h2>Massage Therapy Technique(Written)</h2></td>\n"; echo "<td><h2>$grade</h2></td></tr>\n"; echo "<tr><td><h2>Massage Therapy Technique(pratical)</h2></td>\n"; echo "<td><h2>$mttp</h2></td></tr>\n"; $query = "SELECT stdid, AVG(score) FROM test where classid = $classid and stdid = $stdid and coursename = 'APP' GROUP BY coursename"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $avgscore = $row['AVG(score)']; $avggrade = dograde($avgscore); echo "avg score is $avgscore<br />"; echo "avg grade is $avggrade<br />"; echo "<tr><td><h2>Anatomy,Physiology & Pathology</h2></td>\n"; echo "<td><h2>$avggrade</h2></td></tr>\n"; $query = "SELECT stdid, AVG(score) FROM test where classid = $classid and stdid = $stdid and coursename = 'Kines' GROUP BY coursename"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $avgscore = $row['AVG(score)']; $avggrade = dograde($avgscore); echo "avg score is $avgscore<br />"; echo "avg grade is $avggrade<br />"; echo "<tr><td><h2>Kinesiology</h2></td>\n"; echo "<td><h2>$avggrade</h2></td></tr>\n"; $query = "SELECT stdid, AVG(score) FROM test where classid = $classid and stdid = $stdid and coursename = 'B & E' GROUP BY coursename"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $avgscore = $row['AVG(score)']; $avggrade = dograde($avgscore); echo "avg score is $avgscore<br />"; echo "avg grade is $avggrade<br />"; echo "<tr><td><h2>Business Practice and Professional Ethics</h2></td>\n"; echo "<td><h2>$avggrade</h2></td></tr>\n"; $query = "SELECT stdid, score FROM test where classid = $classid and stdid = $stdid and coursename = 'H & H'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $score = $row['score']; $grade = dograde($score)."/S/S"; echo "<tr><td><h2>Human Health & Hygiene / CPR / SFA</h2></td>\n"; echo "<td><h2>$grade</h2></td></tr>\n"; $query = "SELECT stdid, AVG(score) FROM test where classid = $classid and stdid = $stdid and coursename = 'Hydro' GROUP BY coursename"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $avgscore = $row['AVG(score)']; $avggrade = dograde($avgscore); echo "avg score is $avgscore<br />"; echo "avg grade is $avggrade<br />"; echo "<tr><td><h2>Hydrotherapy</h2></td>\n"; echo "<td><h2>$avggrade</h2></td></tr>\n"; if ( $eval < 5) $itn = 'NG'; echo "<tr><td><h2>Internship Program</h2></td>\n"; echo "<td><h2>$itn</h2></td></tr>\n"; echo "</table>\n";$mttw = 125; echo "<table width=\"100%\" cellpadding=\"1\" border=\"1\">\n"; echo "<tr><td><h2>Required Classroom Hours:</h2></td>\n"; echo "<td><h2>$mttw</h2></td></tr>\n"; echo "<tr><td><h2>Hours Attended to Date:</h2></td>\n"; echo "<td><h2>$mttw</h2></td></tr>\n"; echo "<tr><td><h2>Make-up Hours Needed:</h2></td>\n"; echo "<td><h2>$mttw - $mttw</h2></td></tr>\n"; echo "</table>\n"; } ?><div class="page"></div></body></html
  10. BigD

    How to escape &

    You are right and thanks, James.
  11. BigD

    How to escape &

    I have a sql $query = "SELECT score FROM test where classid = $classid, stdid = $stdid, testname = 'M&M'";It failed syntax check because the & in M&M. M&M is the actural value stored in my DB testname field.How do I escape & ?
  12. BigD

    stop and resume

    What I plan to create is both for web server and desktop. Info are stored for a training school in MySQL DB, Students can check their records through web server. School administrators can do backend records update through desktop application. I thought most web sites operate like that. It has 2 sides. store front is for customers, backend is for store clerks. Am I incorrect?
  13. BigD

    stop and resume

    I have a loop, each time through the loop I create a web page, pause for viewer to print using File > Print. When viewer presses enter I want to resume. How can this be done? A better way would be have a print button, when pressed it will print the web page. How can this be done?
  14. BigD

    stop and resume

    Is there a function that will stop PHP script and resume when viewer pressed enter key?
  15. BigD

    SQL error

    This is the result: gdate is 12-08-13insert grad SQL is INSERT INTO graduate(fname, lname, phone, email, picture, startdate, gdate, gender, stdid, classid, intid) values('F', 'L', '111-222-3333', 'lf@gmail.com', 'JFIF>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality C    $.' ",#(7),01444'9=82<.342C 2!!22222222222222222222222222222222222222222222222222
  16. BigD

    SQL error

    In the following code why gdate has the value of 12-08-13? could that cause sql error? or could the picture field(which is a thumb nail picture) cause the error?I have used the date("y-m-d") before and I was getting 2012-08-12. $gdate = date("y-m-d"); echo "gdate is $gdate"; $query = "INSERT INTO graduate(fname, lname, phone, email, picture, startdate, ". "gdate, gender, stdid, classid, intid) values('$fname', '$lname', '$phone', '$email', ". "'$picture', '$startdate', '$gdate', '$gender', '$stdid', '$classid', '$intid')"; echo "insert grad SQL is $query"; $result = mysql_query($query); if ($result) { echo "<h2>Student $fname $lname graduated</h2>\n"; } else { echo "<h2>SQL error</h2>\n". mysql_error(); }
  17. BigD

    where did cents go?

    Thanks Moderator. I deleted previous attachment. if that made attachments disappear in previous post, it should be separated from uploads and uploads should be automatically deleted. Just my 2 cents opinion. To the other friend responded, the calculation is this line $bal = $bal - $payment. I echoed it before and after. the display format changed. It should show in attachment.
  18. BigD

    where did cents go?

    Here is the screen shot of web page and php code.
  19. BigD

    where did cents go?

    Used 423.55K of your 500K global upload quota (Max. single file size: 76.45K)I would like to hear from forum moderator what does this mean? how can it be reset? My original question is: I echoed a variable as $xx.xx, subtracted some variable from it and echoed it again. now it dropped digits after decimal points and displaied as $xx. Why?
  20. BigD

    where did cents go?

    I want to post question with a .png attachment (184KB). I could not upload, it says I used up my upload quota. Yes I had uploaded 423KB before. How do I upload now? 500KB upload limit seems is too small.
  21. BigD

    how to retrieve db keys?

    I see my mistakes. $query = "SELECT $stdid, $classid from student where lastname= '$lastname' and firstname= '$firstname'";should be $query = "SELECT stdid, classid from student where lastname= '$lastname' and firstname= '$firstname'"; Thanks.
  22. I just inserted a row into my db, how do I retrieve the row key?Here is the code: $query = "INSERT INTO student (graduatedate,lastname,firstname, gender,classid,address, city, state, zip, phone, altphone, email,ssn, dob, picture, lboxname, lbdeposit) " . " VALUES ('na','$lastname', '$firstname', '$gender','$classid','$address', '$city', '$state', '$zip', '$phone', '$altphone','$email','$ssn', '$dob', '$thumbnail','$lboxname', '$lbdeposit')"; $result = mysql_query($query);echo "<h2> Here is the result on student db= $stdid, $lastname ,$firstname,$gender,$classid,$address,$city,$state, $zip,$phone,$altphone,$email,$ssn,$dob,$lboxname,$lbdeposit</h2>\n"; if ($result) { echo "<h2>Student added</h2>\n"; $query = "SELECT $stdid, $classid from student where lastname= '$lastname' and firstname= '$firstname'"; } else { echo "<h2>Problem adding Student</h2>\n". mysql_error(); exit; } Here is the inquire result: Here is the result on student db= , aa ,aa,,2,,,, ,,,,,,, Student added$stdid is the key, it is not returned.
  23. I corrected the wrong </td> tags, the Browse button is still in the wrong place. Sorry it is long, here is the code: <?phpif (!isset($_SESSION['store_admin'])){ echo "<h2>Sorry, you have not logged into the system</h2>\n"; echo "<a href=\"admin.php\">Please login</a>\n";} else{ $userid = $_SESSION['store_admin']; echo "<form enctype=\"multipart/form-data\" action=\"admin.php\" method=\"post\">\n"; echo "<h2>Enter Student Information</h2><br>\n"; echo "<table width=\"100%\" cellpadding=\"1\" border=\"1\">\n"; echo "<tr><td>Class</td>\n"; echo "<td><select name=\"cat\">\n"; $query="SELECT classid,classname from class where classstatus = 'open'"; $result=mysql_query($query); while($row=mysql_fetch_array($result,MYSQL_ASSOC)) { $classid = $row['classid']; $classname = $row['classname']; echo "<option value=\"$classid\">$classname</option>\n"; } echo "</select></td></tr>\n"; echo "<tr><td>Last name</td><td><input type=\"text\" size=\"40\" name=\"lastname\"></td></tr>\n"; echo "<tr><td>First name</td><td><input type=\"text\" size=\"20\" name=\"firstname\"></td></tr>\n"; echo "<tr><td>Gender(M,F)</td><td><input type=\"text\" size=\"2\" name=\"gender\">"; echo " S S N(xxx-xx-xxxx)<input type=\"text\" size=\"11\" name=\"ssn\"></td></tr>\n"; echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1024000\">\n"; echo "<tr><td>Picture</td><input type=\"file\" name=\"picture\"></td></tr>\n"; echo "<tr><td>Date of Birth (yyyy-mm-dd)</td><td><input type=\"text\" size=\"10\" name=\"dob\"></td></tr>\n"; echo "<tr><td>Address</td><td><input type=\"text\" size=\"25\" name=\"address\">"; echo " City<input type=\"text\" size=\"18\" name=\"city\">"; echo " State<input type=\"text\" size=\"2\" name=\"state\">"; echo " Zip<input type=\"text\" size=\"5\" name=\"zip\"></td></tr>\n"; echo "<tr><td>Phone xxx-xxx-xxxx</td><td><input type=\"text\" size=\"15\" name=\"phone\">"; echo " Alternate Phone<input type=\"text\" size=\"15\" name=\"altphone\"></td></tr>\n"; echo "<tr><td>Email address</td><td><input type=\"text\" size=\"45\" name=\"email\"></td></tr>\n"; echo "<tr><td>Tuition</td><td>Fee's<input type=\"text\" size=\"8\" name=\"fee\">"; echo " Waiver<input type=\"text\" size=\"8\" name=\"waiver\">"; echo " Payment<input type=\"text\" size=\"8\" name=\"payment\"></td></tr>\n"; echo "<tr><td>Lock Box #</td><td><input type=\"text\" size=\"4\" name=\"lboxname\">"; echo " Lock Box Deposit<input type=\"text\" size=\"5\" name=\"lbdeposit\"></td></tr>\n"; echo "<tr><td>Note</td><td>Currently Tuition Fee is $4960. Lock Box Deposit is $15</td></tr>\n"; echo "</table>\n"; echo "<input type=\"submit\" value=\"Submit\">\n"; echo "<input type=\"hidden\" name=\"content\" value=\"addstudent\">\n"; echo "</form>\n";}?>
  24. I mis read dsonesuk's post, he was refering to screen 2 coding.Yes it should be coded as he suggested, but the mistake did not cause any problem. PHP interpreter is pretty smart to correct my error and produced a nice web page..
  25. That is not it. in screen1 coding after last line I have echo " State<input type=\"text\" size=\"2\" name=\"state\"> ZIP<input type=\"text\" size=\"5\" name=\"zip\"></td></tr> "; I want to put address, city, state, zip all in one table detail element.
×
×
  • Create New...