Link to home
Start Free TrialLog in
Avatar of acslater
acslater

asked on

Convert from PHP to JSP

Hi there,
Just wonder could anyone convert the following PHP code to JSP code.  Our aim is to get personal details from the DB and also results from another table to produce a similar letter to this using JSP:

---------
<?php
session_start(); //Starts the session for session variables header("Cache-control: private");
//generates letter for users who have requested feedback
//changes request field to blank to ensure no second copies only available to admin
?>
<html>

<head>
  <title>Report</title>
</head>

<body>

<?php

$db = mysql_connect("localhost", "root");
mysql_select_db("psytest",$db);

//check for students requesting feedback
$result = mysql_query("Select * FROM student WHERE Student_Feedback ='ON'");

//changes feedback to off
$sql = mysql_query("UPDATE student SET Student_Feedback = '' WHERE Student_Feedback ='ON'");

if($myrow = mysql_fetch_array($result))
      {

          do {
                  ?>

            <table border="0" width="100%">
                    <tr>
             <td width="15%">
      <img src="../images/WITLOGO.GIF" height=110 width = 85 border="0"><br>
                  </p>
            </td>
                <td width="85%"><p align ="right"><?php
            printf("%s", $myrow["Student_FirstName"]);
            echo " ";
            printf("%s", $myrow["Student_LastName"]);?><br><?php
            printf("%s", $myrow["Student_Address1"]);?><br><?php
            printf("%s", $myrow["Student_Address2"]);?><br><?php
            printf("%s", $myrow["Student_County"]);?><br><?php
            echo date (" l jS F Y");?><br><?php
                 ?>
            </p>
            </td>
                    </tr>
                  </table>
            <?php
            ?>
            <p align="left">
            <?php
            echo ("Psychometric Test Office,");?><br><?php
            echo ("DID,");?><br><?php
            echo ("Cork Campus,");?><br><?php
            echo ("Dublin Road,");?><br><?php
            echo ("Waterford.");?><br><?php
            echo ("<u>ptoffice@did.ie</u>");?><br><br>
            Dear <?php printf("%s", $myrow["Student_FirstName"]); ?>,<br><br>

            You have recently did a Psychometric Test and requested  further feedback on your test results in the form of a postal letter.  The results of your most recently taken test are as follows.
</p>
<p align = "center">
<?php
$name = $myrow['Student_Username'];
$rank = '1';

$db = mysql_connect("localhost", "root");

mysql_select_db("psytest",$db);

$sql = mysql_query("SELECT * FROM `ranklist` WHERE Student_Username = '$name' ORDER BY `Course_Score` DESC");

if($myrow = mysql_fetch_array($sql))

      {
          echo "<b>The following courses are ranked in order of suitability to your aptitude.</b><br><br>";
            echo "<table border=1 width=50%>\n";
            echo "<tr><td width=15%><b><font color =#0000dd><u>Rank</u></font></b></td><td width=65%><b><font color

=#0000dd><u>Course Title</u></font></b></td><td width=20%><b><font color =#0000dd><u>Course Score</u></font></b></td></tr>\n";

        do {

                  printf("<tr><td><b>$rank</b></td><td><font color =#dd0000>%s</font></td><td>%s</td></tr>\n",

$myrow["Course_Name"], $myrow["Course_Score"]);
            $rank++;
                }
          while ($myrow = mysql_fetch_array($sql));
                  echo "</table>\n";
    }
?>
<br>
<p align = "left">
Please also find enclosed a copy of the Application Handbook which contains further details on all the courses listed above.  If you have any further questions regarding any of the courses please do not hesitate to contact the lecturer listed in the Application Handbook<br><br>

Wishing you all the best with your future studies.<br><br>

Yours sincerely<br><br>

<font size = "6" face ="Freestyle Script">The Test Team</font><br>

</p>
<?php
?>
</p>
            <?php
                }
          while ($myrow = mysql_fetch_array($result));
    }
else {
?>
<p align = "center">
<?php
      echo "<b>There are no user letters currently available for printing!</b>";
?>
<?php
    }
?>
</body>
</html>
Avatar of acslater
acslater

ASKER

Any ideas anyone!!!
ASKER CERTIFIED SOLUTION
Avatar of bloodredsun
bloodredsun
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks for that, helped out