Mixing Programing Languages
-
I really am not sure what I am doing. I know enough coding to get myself in trouble.
What I am trying to do is create a page that my users can go to and print off a PDF that is filled out with a lot of data from a Mysql Database. I am having a problem writing the code in the code manager though and I want to know if I am missing something, or if I am trying to do something with this that it is not meant to do.
(In the end it should look something like this: https://content.instructables.com/ORIG/F32/Y0FV/J8F5Q3W5/F32Y0FVJ8F5Q3W5.png?auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=5a45ebe2850f9ab8d04792009d63d6a5)
Specifically, you will notice that I have to put “\” in the code at places where is normally should not go. why this is working, I have no clue. I assume I am confusing the system into doing what I want it to do. I have no clue if this is the correct way to achieve what I am looking for or not.
Here is a copy of my code with some info scrubbed.
<?php
$servername = “Removed”;
$username = “Removed”;
$password = “Removed”;
$dbname = “Removed”;
$current_user = wp_get_current_user();// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die(“Connection failed: ” . $conn->connect_error);
}//$sql = “SELECT * FROM LARP_Characters WHERE Username = ‘”.$current_user->user_login.”‘”;
//$sql = “SELECT * FROM LARP_Characters”;
$sql = “SELECT * FROM LARP_Characters WHERE Status = ‘Active’ ORDER BY ‘Name'”;
$result = $conn->query($sql);if ($result->num_rows > 0) {
echo “<form>”;
echo “Choose a Character: “;
echo “<select name=’Character_Name’>”;// output data of each row
while($row = $result->fetch_assoc()) {
$selected = ($row[‘Character_Name’] == $_GET[‘Character_Name’]) ? “selected” : “”;
echo “<option value='”.$row[‘Character_Name’].”‘ $selected>”.$row[‘Character_Name’].”</option>”;
}echo “</select><br>”;
echo “<br /><input type=’submit’ value=’Load Character Sheet’><br><br>”;
echo “</form>”;
} else {
echo “0 results ; $sql ; “.json_encode($current_user);
}if ($_GET[‘Character_Name’]) {
//echo $_GET[‘Character_Name’];//$sql = “SELECT * FROM LARP_Characters WHERE Character_Name = ‘”.$_GET[‘Character_Name’].”‘”;
//$sql = “SELECT * FROM LARP_Characters WHERE Username = ‘”.$current_user->user_login.”‘ AND Character_Name = ‘”.$_GET[‘Character_Name’].”‘”;
//$sql = “SELECT * FROM LARP_Characters WHERE Approved = ‘Yes'”;
$sql = “SELECT * FROM LARP_Characters WHERE Status = ‘Active’ ORDER BY ‘Name’ ASC”;
$result = $conn->query($sql);if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
//echo “<div class=\”character-sheet\”><div style=\”overflow-x:auto\”>
echo “<div class=\”character-sheet\”><div style=\”page-break-before:always ; margin: 0 auto ; width:100% ; \”>
<table border=\”0\”>
<tbody>
<tr>
<td colspan=\”1\”>Player: </td>
<td colspan=\”3\”>” . $row[“Name”]. “</td>
<td colspan=\”1\”>Name: </td>
<td colspan=\”3\”>” . $row[“Character_Name”]. “</td>
</tr>
<tr>
<td colspan=\”4\”>Occupation: ” . $row[“Occupation”]. ” – ” . $row[“Monthly_Gain”]. “</td>
<td colspan=\”2\”>Mortality? </td>
<td colspan=\”2\”>” . $row[“Mortality”]. ” – ” . $row[“Mortality_Rating”]. “</td>
</tr>
<tr>
<td colspan=\”2\”><div style=\”text-align:center\”>Currency</div></td>
<td colspan=\”1\”><div style=\”text-align:right\”>Copper Pieces: </div></td>
<td colspan=\”1\”>” . $row[“CP”]. “</td>
<td colspan=\”1\”><div style=\”text-align:right\”>Silver Pieces: </div></td>
<td colspan=\”1\”>” . $row[“SP”]. “</td>
<td colspan=\”1\”><div style=\”text-align:right\”>Gold Pieces: </div></td>
<td colspan=\”1\”>” . $row[“GP”]. “</td>
</tr>
<tr>
<td colspan=\”1\”><div style=\”text-align:right\”>Ammo: </div></td>
<td colspan=\”1\”>” . $row[“Ammo”]. “</td>
<td colspan=\”1\”><div style=\”text-align:right\”>Arrows: </div></td>
<td colspan=\”1\”>” . $row[“Arrows”]. “</td>
<td colspan=\”1\”><div style=\”text-align:right\”>Locks: </div></td>
<td colspan=\”1\”>” . $row[“Locks”]. “</td>
<td colspan=\”1\”><div style=\”text-align:right\”>Ailment: </div></td>
<td colspan=\”1\”>” . $row[“Ailments”]. “</td>
</tr>
<tr>
<td colspan=\”2\”><div style=\”text-align:right\”>Other Possessions: </div></td>
<td colspan=\”6\”>” . $row[“Other_Items”]. “</td>
</tr>
</tr>
<td colspan=\”8\”>
<table border=\”1\” width=\”100%\”>
<tbody>
<tr>
<td></td>
<td><div style=\”font-weight: bold\”>Animal</div></td>
<td><div style=\”font-weight: bold\”>Chemical</div></td>
<td><div style=\”font-weight: bold\”>Plant</div></td>
<td><div style=\”font-weight: bold\”>Ore</div></td>
<td><div style=\”font-weight: bold\”>Stone</div></td>
<td><div style=\”font-weight: bold\”>Magic</div></td>
<td><div style=\”font-weight: bold\”>Technology</div></td>
</tr>
<tr>
<td><div style=\”font-weight: bold\”>Common</div></td>
<td>” . $row[“Common_Animal”]. ” </td>
<td>” . $row[“Common_Chemical”]. ” </td>
<td>” . $row[“Common_Plant”]. ” </td>
<td>” . $row[“Common_Ore”]. ” </td>
<td>” . $row[“Common_Stone”]. ” </td>
<td>” . $row[“Common_Magic”]. ” </td>
<td>” . $row[“Common_Technology”]. ” </td>
</tr>
<tr>
<td><div style=\”font-weight: bold\”>Scarce</div></td>
<td>” . $row[“Scarce_Animal”]. ” </td>
<td>” . $row[“Scarce_Chemical”]. ” </td>
<td>” . $row[“Scarce_Plant”]. ” </td>
<td>” . $row[“Scarce_Ore”]. ” </td>
<td>” . $row[“Scarce_Stone”]. ” </td>
<td>” . $row[“Scarce_Magic”]. ” </td>
<td>” . $row[“Scarce_Technology”]. ” </td>
</tr>
<tr>
<td><div style=\”font-weight: bold\”>Rare</div></td>
<td>” . $row[“Rare_Animal”]. ” </td>
<td>” . $row[“Rare_Chemical”]. ” </td>
<td>” . $row[“Rare_Plant”]. ” </td>
<td>” . $row[“Rare_Ore”]. ” </td>
<td>” . $row[“Rare_Stone”]. ” </td>
<td>” . $row[“Rare_Magic”]. ” </td>
<td>” . $row[“Rare_Technology”]. ” </td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td colspan=\”8\”>
____________________________________________________________________________________________________________________________________________________
</td>
</tr>
<tr>
<td colspan=\”8\”>
<table border=\”1\” width=\”100%\”>
<tbody>
<tr>
<td colspan=\”8\”><div style=\”text-align:Center\”>Abilities</div></td>
</tr>
<tr>
<td>Background Ability: </td>
<td colspan=\”7\”>” . $row[“BGA”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>Upgrades: ” . $row[“BGA_Notes”]. “</td>
</tr>
<tr>
<td>Ability 1: </td>
<td colspan=\”7\”>” . $row[“A1”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>Upgrades: ” . $row[“A1_Notes”]. “</td>
</tr>
<tr>
<td>Ability 2: </td>
<td colspan=\”7\”>” . $row[“A2”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>Upgrades: ” . $row[“A2_Notes”]. “</td>
</tr>
<tr>
<td>Ability 3: </td>
<td colspan=\”7\”>” . $row[“A3”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>Upgrades: ” . $row[“A3_Notes”]. “</td>
</tr>
<tr>
<td>Ability 4: </td>
<td colspan=\”7\”>” . $row[“A4”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>Upgrades: ” . $row[“A4_Notes”]. “</td>
</tr>
<tr>
<td>Ability 5: </td>
<td colspan=\”7\”>” . $row[“A5”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>Upgrades: ” . $row[“A5_Notes”]. “</td>
</tr>
<tr>
<td>Ability 6: </td>
<td colspan=\”7\”>” . $row[“A6”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>Upgrades: ” . $row[“A6_Notes”]. “</td>
</tr>
<tr>
<td>Ability 7: </td>
<td colspan=\”7\”>” . $row[“A7”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>Upgrades: ” . $row[“A7_Notes”]. “</td>
</tr>
<tr>
<td>Ability 8: </td>
<td colspan=\”7\”>” . $row[“A8”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>Upgrades: ” . $row[“A8_Notes”]. “</td>
</tr>
<tr>
<td>Ability 9: </td>
<td colspan=\”7\”>” . $row[“A9”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>Upgrades: ” . $row[“A9_Notes”]. “</td>
</tr>
<tr>
<td>Ability 10: </td>
<td colspan=\”7\”>” . $row[“A10”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>Upgrades: ” . $row[“A10_Notes”]. “</td>
</tr>
</tbody>
</table>
</td>
</tbody>
</table></div></div>
<br> <br><div class=\”character-sheet\”><div style=\”page-break-before:always ; margin: 0 auto ; width:100% ; \”>
<table border=\”5\” width=\”100%\”>
<tbody>
<tr>
<td colspan=\”8\”>
<div style=\”background-color: lightgrey; text-align: Center;\”>Known Recipies</div>
</td>
</tr>
<tr>
<td colspan=\”8\”>
<div style=\”background-color: lightgrey; text-align: Center;\”>Recipes You Have Learned</div>
</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP1”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP2”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP3”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP4”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP5”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP6”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP7”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP8”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP9”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP10”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP11”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP12”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP13”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP14”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP15”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP16”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP17”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP18”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP19”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>” . $row[“RP20”]. “</td>
</tr>
<tr>
<td colspan=\”8\”>
<div style=\”background-color: lightgrey; text-align: Center;\”>End of Event Check-In</div>
</td>
</tr>
<tr>
<td colspan=\”1\”>
<div style=\”background-color: lightgrey; text-align: right;\”>Refered By:</div>
</td>
<td colspan=\”3\”>________________________________________</td>
<td colspan=\”1\”>
<div style=\”background-color: lightgrey; text-align: right;\”>Event Name:</div>
</td>
<td colspan=\”3\”>_________________________________________________________</td>
</tr>
<tr>
<td colspan=\”2\”>
<div style=\”background-color: lightgrey; text-align: right;\”>Event Number<br></div>
</td>
<td colspan=\”2\”>
<div>#1 <input type=\”checkbox\”> | #2 <input type=\”checkbox\”> | #3+ <input type=\”checkbox\”></div>
</td>
<td colspan=\”1\”>
<div style=\”background-color: lightgrey; text-align: right;\”>Date:</div>
</td>
<td colspan=\”3\”>_________________________________________________________</td>
</tr>
<tr>
<td colspan=\”1\”>
<div style=\”background-color: lightgrey; text-align: Right;\”>Mortality<br></div>
</td>
<td colspan=\”1\”>__________</td>
<td colspan=\”1\”>Unlearned Recipies</td>
<td colspan=\”5\”>__________________________________________________________________________________________________</td>
</tr>
<tr>
<td>
<div style=\”background-color: lightgrey; text-align: right;\”>Copper<br></div>
</td>
<td>__________</td>
<td colspan=\”1\”>Artifacts</td>
<td colspan=\”5\”>__________________________________________________________________________________________________</td>
</tr>
<tr>
<td>
<div style=\”background-color: lightgrey; text-align: right;\”>Silver<br></div>
</td>
<td>__________</td>
<td colspan=\”6\”>___________________________________________________________________________________________________________________</td>
</tr>
<tr>
<td>
<div style=\”background-color: lightgrey; text-align: right;\”>Gold<br></div>
</td>
<td>__________</td>
<td colspan=\”1\”>Crafted Itmes</td>
<td colspan=\”5\”>__________________________________________________________________________________________________</td>
</tr>
<tr>
<td>
<div style=\”background-color: lightgrey; text-align: right;\”>Arrows<br></div>
</td>
<td>__________</td>
<td colspan=\”6\”>___________________________________________________________________________________________________________________</td>
</tr>
<tr>
<td>
<div style=\”background-color: lightgrey; text-align: right;\”>Ammo<br></div>
</td>
<td>__________</td>
<td colspan=\”1\”>Other Items</td>
<td colspan=\”5\”>__________________________________________________________________________________________________</td>
</tr>
<tr>
<td>
<div style=\”background-color: lightgrey; text-align: right;\”>Locks<br></div>
</td>
<td>__________</td>
<td colspan=\”6\”>___________________________________________________________________________________________________________________</td>
</tr>
<tr>
<td>
<div style=\”background-color: lightgrey; text-align: right;\”>Ailment<br></div>
</td>
<td>__________</td>
<td colspan=\”1\”>Abilities Trained</td>
<td colspan=\”5\”>__________________________________________________________________________________________________</td>
</tr>
<tr>
<td>
<div style=\”background-color: lightgrey; text-align: right;\”>Ailment Lvl</div>
</td>
<td>__________</td>
<td colspan=\”1\”>CSP (GM Only)</td>
<td colspan=\”5\”>__________________________________________________________________________________________________</td>
</tr>
<tr>
<td> </td>
<td>
<div style=\”background-color: lightgrey; text-align: Center;\”>Animal</div>
</td>
<td>
<div style=\”background-color: lightgrey; text-align: Center;\”>Chemical</div>
</td>
<td>
<div style=\”background-color: lightgrey; text-align: Center;\”>Plant</div>
</td>
<td>
<div style=\”background-color: lightgrey; text-align: Center;\”>Ore</div>
</td>
<td>
<div style=\”background-color: lightgrey; text-align: Center;\”>Stone</div>
</td>
<td>
<div style=\”background-color: lightgrey; text-align: Center;\”>Magic</div>
</td>
<td>
<div style=\”background-color: lightgrey; text-align: Center;\”>Technology</div>
</td>
</tr>
<tr border=\”5px\”>
<td>
<div style=\”background-color: lightgrey; text-align: Right;\”>Common<br></div>
</td>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
</tr>
<tr>
<td>
<div style=\”background-color: lightgrey; text-align: Right;\”>Scarce<br></div>
</td>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
</tr>
<tr>
<td>
<div style=\”background-color: lightgrey; text-align: Right;\”>Rare<br></div>
</td>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
<td><div style=\”text-align: Center;\”>__________</td></div>
</tr>
<tr>
<td>
<div style=\”background-color: lightgrey; text-align: Right;\”>Quest Mats:</div>
</td>
<td colspan=\”7\”>____________________________________________________________________________________________________________________________________
</td>
</tr>
</tbody>
</table></div></div>
<br> <br>“;
}
} else {
echo “Unable to Load Character Details”;
}
}$conn->close();
?>`
`If anyone is able to tell me an easier or better way to do what I am trying to do, please share it with me.
- The topic ‘Mixing Programing Languages’ is closed to new replies.