Still to do: Requery names for objects and replace with classname
index.php
<body> <h1>Loadout Creator</h1> <form action="insert.php" method="post"> <label for="loadoutname">Loadout Name:</label> <input type="text" name="loadoutname" id="loadoutname"> <br> <?php $sql = "SELECT name FROM tarsenal WHERE type='bag' GROUP BY name;"; $result = mysqli_query($mysqli,$sql); if (!is_null($result)) { echo '<label for="backpack">Backpack:'; echo '<select name="bag">'; echo '<option value="" name="bag" id="bag">none</option>'; $num_results = mysqli_num_rows($result); for ($i=0;$i<$num_results;$i++) { $row = mysqli_fetch_array($result); $name = $row['name']; echo '<option name="bag" id="bag" value=" ' .$name. '">' .$name. '</option>'; } echo '</select>'; echo '</label>'; echo "<br>"; } $sql = "SELECT name FROM tarsenal WHERE type='headgear' GROUP BY name;"; $result = mysqli_query($mysqli,$sql); if (!is_null($result)) { echo '<label>Headgear:'; echo '<select name="headgear">'; echo '<option value="" name="headgear" id="headgear">none</option>'; $num_results = mysqli_num_rows($result); for ($i=0;$i<$num_results;$i++) { $row = mysqli_fetch_array($result); $name = $row['name']; echo '<option name="headgear" id="headgear" value="' .$name. '">' .$name. '</option>'; } echo '</select>'; echo '</label>'; echo "<br>"; } $sql = "SELECT name FROM tarsenal WHERE type='uniform' GROUP BY name;"; $result = mysqli_query($mysqli,$sql); if (!is_null($result)) { echo '<label>Uniform:'; echo '<select name="uniform">'; echo '<option value="" name="uniform" id="uniform">none</option>'; $num_results = mysqli_num_rows($result); for ($i=0;$i<$num_results;$i++) { $row = mysqli_fetch_array($result); $name = $row['name']; echo '<option name="uniform" id="uniform" value="' .$name. '">' .$name. '</option>'; } echo '</select>'; echo '</label>'; echo "<br>"; } mysqli_close($mysqli); ?> <input type="submit" value="Submit"> </form> </body>
input.php
<?php // Setup connection to mySQL db $link = new mysqli("localhost", "root", "1234", "arsenal"); // Error handler if connection to db fails if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } // Escape user inputs for security $bag = mysqli_real_escape_string($link, $_REQUEST['bag']); $headgear = mysqli_real_escape_string($link, $_REQUEST['headgear']); $uniform = mysqli_real_escape_string($link, $_REQUEST['uniform']); $loadoutname = mysqli_real_escape_string($link, $_REQUEST['loadoutname']); $format = '"class %s { displayName = "%s"; uniformClass = "%s"; backpack = "%s"; weapons[] = { "rhs_weap_m4a1" }; linkedItems[] = { "%s", "rhsusf_iotv_ocp_Rifleman", "rhsusf_acc_M952V", "rhsusf_acc_compm4", "rhsusf_acc_grip2", "ItemCompass", "ItemWatch", "ItemMap" }; items[] = { #include "Uniform.hpp" }; };'; $armaexport = sprintf($format, $loadoutname, $loadoutname, $uniform, $bag, $headgear); // Attempt insert query execution $sql = "INSERT INTO loadouts (loadoutname, headgear, bag, uniform, armaexport) VALUES ('$loadoutname', '$headgear', '$bag', '$uniform', '$armaexport')"; if(mysqli_query($link, $sql)){ echo "Records added successfully."; echo $armaexport; } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } // Close connection mysqli_close($link); ?>
GUI
Output
MyPHPAdmin