LIST Split - How to utilise distinct button values

LIST Split - How to utilise distinct button values

I have a MySQL query that brings back several rows of data from the table. I am trying to press the split view delete icon and have that value (database distinct value of 'id') transfer across to the popup dialog to confirm an action and then that in turn sends the id via POST to delete.php

The current code I have put together I can only get the first row's id to work and I cannot figure out what is needed to pass to the popup and delete.php or should I say I don't know how to do it! Still pretty new to this so apologies if it's a complete mess...

Here's my code:

  1. <?php include("auth.php"); ?>
  2. <html>
  3. <head>
  4. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
  5. <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  6. <script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
  8. </head>
  9. <body>
  10. <div data-role="page" id="home">
  11. <div data-role="header" data-theme="a">
  12. <h1>Test</h1>
  13. </div>
  14. <img class="bulge_shadow" src="_/images/bulge_shadow.png" alt="bulge_shadow">
  15. <div data-role="content">
  16. <p class="medium_text">ONLY THE TOP ENTRY WILL WORK AT PRESENT <br><br>Select any inputs you wish to delete</p>

  17. <?php
  18. $db_host = '***';
  19. $db_user = '***';
  20. $db_pwd = '***';

  21. $database = '***';
  22. $table = '***';

  23. if (!mysql_connect($db_host, $db_user, $db_pwd))
  24.    die("Can't connect to database");

  25. if (!mysql_select_db($database))
  26.    die("Can't select database");

  27. $result = mysql_query("SELECT * FROM `***` WHERE username = '$_SESSION[USERNAME]' ORDER BY datestamp DESC LIMIT 15");
  28. if (!$result) {
  29.    die("Query to show fields from table failed");
  30. }
  31. $fields_num = mysql_num_fields($result);
  32. for($i=0; $i<$fields_num; $i++)
  33. {
  34.    $field = mysql_fetch_field($result);
  35. }
  36. while($row = mysql_fetch_row($result))
  37. {
  38. ?> 
  39. <ul data-role="listview" data-inset="true" data-split-theme="a" data-split-icon="delete" data-theme="a" value="<?php echo "$row[0]"?>">
  40. <li><a href="" >
  41. <img src="_/images/chillies/li_<?php echo "$row[3]"?>.jpg"/>
  42. <h3><?php echo "$row[4] x $row[3]"?></h3>
  43. <p><?php echo "$row[1]"?></p>
  44. <a href="#confirm_del" data-rel="popup" data-position-to="window" data-transition="pop">Delete Record</a>
  45. </a>
  46. </li>
  47. </ul>
  48. <div data-role="popup" id="confirm_del" data-theme="a" data-overlay-theme="b" class="ui-content" style="max-width:340px; padding-bottom:2em;">
  49. <form method="post" action="delete.php" name="delrecord" data-ajax="false">
  50. <h3>Delete Record</h3>
  51. <p>Please confirm you wish to delete entry <?php echo "$row[0]"?></p>
  52. <div data-role="fieldcontain">
  53. <input type="hidden" id="id" name="id" value="<?php echo "$row[0]"?>">
  54. <input type="submit" value="Submit" id="submit" data-theme="b">
  55. <a href="#harvest" data-role="button" data-rel="back">Cancel</a>
  56. </div>
  57. </form>
  58. </div>
  59. <?php 
  60. }
  61. mysql_free_result($result)
  62. ?>
  63.            <a href="input.php" rel="external" data-role="button" data-theme="b" data-transition="slide">Done</a>
  64.            <p class="small_text"> Logged in as <?php echo $_SESSION['USERNAME'];?> </p>
  65. </div>
  66. <div data-role="footer" data-position="fixed" data-theme="b">
  67.     <p class="footer_text" >Test App</p>
  68. </div>
  69. </div>
  70. </body>
  71. </html>