paddy086
asked on
Change HTML page with Java script to PHP page issues
Hi
My page is in HTML with java script called test.html.
When I open it in Dreamweaver and save it as a .php page and open the file in a web browser it just shows text the java doesn't work any more.
The reason I want the test.html changed to test.php is so I can add the PHP script from printphppage.php to the textarea of the test page. all my pages are attached below thanks for your help
Temp.zip
My page is in HTML with java script called test.html.
When I open it in Dreamweaver and save it as a .php page and open the file in a web browser it just shows text the java doesn't work any more.
The reason I want the test.html changed to test.php is so I can add the PHP script from printphppage.php to the textarea of the test page. all my pages are attached below thanks for your help
Temp.zip
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You don't have to open and save - you can just rename
test.html => rename to test.php
If you have a PHP interpreter setup on your web server this should be enough to have it parse your file.
You can then add php code directly to this file.
If after a rename you are not getting expected results then as JEaston mentioned you probably don't have anything setup to interpret PHP
test.html => rename to test.php
If you have a PHP interpreter setup on your web server this should be enough to have it parse your file.
You can then add php code directly to this file.
If after a rename you are not getting expected results then as JEaston mentioned you probably don't have anything setup to interpret PHP
ASKER
Hi I am running a local Webserver XAMPP.
My test.html page has 3 text boxes that use PrintLabelnew.js to enable printing on a DYMO printer.
test.html
PrintLabelnew.js
On LINE 16 of test.html
area>
My test.html page has 3 text boxes that use PrintLabelnew.js to enable printing on a DYMO printer.
test.html
<!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>Print a Label</title>
<script src = "http://labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.latest.js" type="text/javascript" charset="UTF-8"> </script>
<script src = "PrintLabelnew.js" type="text/javascript" charset="UTF-8"> </script>
</head>
<body>
<h1>DYMO Label Framework JavaScript Library Samples: Print Label test 2</h1>
<div id="printDiv">
<label for="textTextArea">Label text:</label><br/>
<textarea name="textTextArea" id="1textTextArea" rows='5' cols='40'></textarea>
<button id="1printButton" onclick="print1();return false;">Print</button>
</div>
<div id="printDiv">
<label for="textTextArea">Label text:</label><br/>
<textarea name="textTextArea" id="2textTextArea" rows='5' cols='40'></textarea>
<button id="2printButton" onclick="print2();return false;">Print</button>
</div>
<div id="printDiv">
<label for="textTextArea">Label text:</label><br/>
<textarea name="textTextArea" id="3textTextArea" rows='5' cols='40'></textarea>
<button id="3printButton" onclick="print3();return false;">Print</button>
</div>
<div id="printAll">
<button id="printAllBtn" onclick="print1(); print2(); print3(); return false">Print All</button>
</div>
</body>
</html>
PrintLabelnew.js
function printStuff(what)
{
try
{
// open label
var labelXml = '<?xml version="1.0" encoding="utf-8"?>\
<DieCutLabel Version="8.0" Units="twips">\
<PaperOrientation>Landscape</PaperOrientation>\
<Id>Address</Id>\
<PaperName>30252 Address</PaperName>\
<DrawCommands/>\
<ObjectInfo>\
<TextObject>\
<Name>Text</Name>\
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />\
<BackColor Alpha="0" Red="255" Green="255" Blue="255" />\
<LinkedObjectName></LinkedObjectName>\
<Rotation>Rotation0</Rotation>\
<IsMirrored>False</IsMirrored>\
<IsVariable>True</IsVariable>\
<HorizontalAlignment>Left</HorizontalAlignment>\
<VerticalAlignment>Middle</VerticalAlignment>\
<TextFitMode>ShrinkToFit</TextFitMode>\
<UseFullFontHeight>True</UseFullFontHeight>\
<Verticalized>False</Verticalized>\
<StyledText/>\
</TextObject>\
<Bounds X="332" Y="150" Width="4455" Height="1260" />\
</ObjectInfo>\
</DieCutLabel>';
var label = dymo.label.framework.openLabelXml(labelXml);
// set label text
label.setObjectText("Text", what);
// select printer to print on
// for simplicity sake just use the first LabelWriter printer
var printers = dymo.label.framework.getPrinters();
if (printers.length == 0)
throw "No DYMO printers are installed. Install DYMO printers.";
var printerName = "";
for (var i = 0; i < printers.length; ++i)
{
var printer = printers[i];
if (printer.printerType == "LabelWriterPrinter")
{
printerName = printer.name;
break;
}
}
if (printerName == "")
throw "No LabelWriter printers found. Install LabelWriter printer";
// finally print the label
label.print(printerName);
}
catch(e)
{
alert(e.message || e);
}
}
function print1()
{
var textTextArea = document.getElementById('1textTextArea');
printStuff(textTextArea.value);
}
function print2()
{
var textTextArea = document.getElementById('2textTextArea');
printStuff(textTextArea.value);
}
function print3()
{
var textTextArea = document.getElementById('3textTextArea');
printStuff(textTextArea.value);
}
On LINE 16 of test.html
<textarea name="textTextArea" id="1textTextArea" rows='5' cols='40'></textarea>
I inserted my php script just in-between cols='40'>PHP-SCRIPT</text<?php
$con = mysqli_connect("localhost","root","PASSWORD","test");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT w1monsick2.*, w1monsick1.* FROM w1monsick2, w1monsick1 WHERE w1monsick2.id2 =2 = w1monsick1.id =1");
$tr1= '<tr><td>Date</td>';
$tr2= '<tr><td>Sick Teacher</td>';
$tr3= '<tr><td>Period</td>';
$tr4= '<tr><td>Cover Teacher</td>';
$tr5= '<tr><td>Subject</td>';
$tr6= '<tr><td>Class</td>';
$tr7= '<tr><td>Room</td>';
echo "<table border='1' height='50' font size='20'>
";
while($row = mysqli_fetch_array($result))
{
$tr1 .="<td>" . $row['datepicker'] . "</td>";
$tr2 .="<td>" . $row['sickteacher2'] . "</td>";
$tr3 .="<td>" . $row['period2'] . "</td>";
$tr4 .= "<td>" . $row['coverteacher2'] . "</td>";
$tr5 .= "<td>" . $row['subject2'] . "</td>";
$tr6 .= "<td>" . $row['class2'] . "</td>";
$tr7 .= "<td>" . $row['room2'] . "</td>";
}
$tr1 .= '</tr>';
$tr2 .= '</tr>';
$tr3 .= '</tr>';
$tr4 .= '</tr>';
$tr5 .= '</tr>';
$tr6 .= '</tr>';
$tr7 .= '</tr>';
echo
$tr1,'
',$tr2,'
',$tr3,'
',$tr4,'
',$tr5,'
',$tr6,'
',$tr7,'
</table>';
mysqli_close($con);
?>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
JEaston I now get what you were saying sorry I didn't understand it earlier
Chris Stanyon you were correct as well
my script is working now when I renamed the test.html to test.php and actually placed it into my localhost directory it worked I should have know that sorry
There is one issue now in the text area my php script dose work as far as it prints the info from my data base but it also
prints the Table structure e.g at the <tr> <td> <tr> <td> on the label
Chris Stanyon you were correct as well
my script is working now when I renamed the test.html to test.php and actually placed it into my localhost directory it worked I should have know that sorry
There is one issue now in the text area my php script dose work as far as it prints the info from my data base but it also
prints the Table structure e.g at the <tr> <td> <tr> <td> on the label
ASKER
I am marking this question as answered as the experts have answered my original question correctly. But I will be opening a new question on my second issue
http://www.mamp.info/en/