get-description-for-selected-tag.php 914 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. require_once("../../php/db_utils.php");
  3. try {
  4. // Connect to the database
  5. $database = db_connect();
  6. // Incoming data
  7. $tag = $_POST["tag"];
  8. $canvasId = $_POST["canvas_id"];
  9. // Declare query
  10. $query = 'SELECT description FROM tags WHERE tag = "' . $tag . '" AND canvas_id = "' . $canvasId . '";';
  11. // Run query
  12. $recordSet = db_query_return($database, $query);
  13. // Get description for the selected tag
  14. $record = mysqli_fetch_assoc($recordSet);
  15. $description = $record["description"];
  16. mysqli_free_result($recordSet);
  17. echo($description);
  18. // Close the connection to the database
  19. db_close($database);
  20. }
  21. catch(Exception $e) {
  22. $errorMsg = $e->getMessage();
  23. print_r($errorMsg);
  24. }
  25. ?>