Hi there, i'd post a month ago a feature that i needed, during this month i was trying to make it work but i cant, i have half of the way to acomplish this but i cannot store the value on the database.I'm editing the ticket-view.inc.php file, below the ticket status part.This is the code i was working on. Can somebody can help me to achieve this? <?php        $servername = "localhost";        $username = "root";        $password = "dummypassword";        $dbname = "mydatabase";// Create connection$conn = new mysqli($servername, $username, $password, $dbname);// Check connectionif ($conn->connect_error) {    die("Connection failed: " . $conn->connect_error);}$sql = "SELECT value,id FROM my_table where list_id=4"; //query correct on the list i've already created$result = $conn->query($sql);if ($result->num_rows > 0) {    // output data of each row?> <tr>    <td width="120" style="vertical-align">    <label><strong><?php echo __('Diagnostico');?>:</strong></label>   </td>   <td> <select name="diagnosis"><?php    while($row = $result->fetch_assoc()) {        echo sprintf('<option value="%d">%s</option>',$row."",$row."");    }} else {    echo "0 results";}$conn->close();//at this point everything ok, check the picture below.?></select>        </td></tr>         </tbody>        </table><?php //is my code on the right place?                if(isset($_POST)){//take the boton (submit button "Post Reply")                $conn = new mysqli($servername, $username, $password, $dbname);                // Check connection                if ($conn->connect_error) {                    die("Connection failed: " . $conn->connect_error);                }                $value = $_POST; //take the value selected from my select                $sql = "UPDATE hd_ticket SET diagn_list ='$value' where ticket_id='1975'";//test only for the ticket id, need to obtain the ticket id from a variable but so far, i couldn't :(                $result = $conn->query($sql);                echo "<script type='text/javascript'>alert('SQL: '+ $sql);</script>";//trying to debug what im sending to the database                $conn->close();}?>Thanks in advice, here the picture showing the correct sql consult

select.PNG

ok, i found a way to resolve this using this code:<html><head><title>PHP</title></head><body>Hola!<br>    <form id="reply"  action="" name="reply" method="post"> <?php        $servername = "localhost";        $username = "root";        $password = "password";        $dbname = "test";// Create connection$conn = new mysqli($servername, $username, $password, $dbname);// Check connectionif ($conn->connect_error) {    die("Connection failed: " . $conn->connect_error);}$sql = "SELECT value,id FROM hd_list_items where list_id=4"; //query sql$result = $conn->query($sql);if ($result->num_rows > 0) {    // output data of each row?> <tr>    <td width="120" style="vertical-align"><!--copiar desde aqui -->    <label><strong><?php echo __('Diagnostico');?>:</strong></label>   </td>   <td> <select name="diagnosis"><?php    while($row = $result->fetch_assoc()) {        echo sprintf('<option value="%d" id="%d">%s</option>',$row."",$row."",$row."");    }} else {    echo "0 results";}$conn->close();?></select>        </td></tr>        <p  style="text-align;">            <input class="save pending" type="submit" value="boton" name="boton" id="boton">        </p>    </form><?php                if(isset($_POST)){                   $conn = new mysqli($servername, $username, $password, $dbname);                // Check connection                if ($conn->connect_error) {                    die("Connection failed: " . $conn->connect_error);                }                $value = $_POST;                $sql = "UPDATE hd_ticket SET diagn_list ='$value' where ticket_id='1976'";//watch out ' and "                $result = $conn->query($sql);                $conn->close();                }    } ?></body></html>the thing is, when i try to integrate it inside my ticket.view.inc.php i cannot make it work (no error message but the database dont update the value of my field), how can I debug it? any ideas to solve the problem?

7 days later

Solved! I was editing wrong file. The post can be found on this link ://forum.osticket.com/d/discussion//add-custom-list-selection-to-the-sticky-bar#latest

Write a Reply...