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:
- <?php include("auth.php"); ?>
- <html>
- <head>
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
- <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
- <script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
- <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
- </head>
- <body>
- <div data-role="page" id="home">
- <div data-role="header" data-theme="a">
- <h1>Test</h1>
- </div>
- <img class="bulge_shadow" src="_/images/bulge_shadow.png" alt="bulge_shadow">
- <div data-role="content">
- <p class="medium_text">ONLY THE TOP ENTRY WILL WORK AT PRESENT <br><br>Select any inputs you wish to delete</p>
- <?php
- $db_host = '***';
- $db_user = '***';
- $db_pwd = '***';
- $database = '***';
- $table = '***';
- if (!mysql_connect($db_host, $db_user, $db_pwd))
- die("Can't connect to database");
- if (!mysql_select_db($database))
- die("Can't select database");
- $result = mysql_query("SELECT * FROM `***` WHERE username = '$_SESSION[USERNAME]' ORDER BY datestamp DESC LIMIT 15");
- if (!$result) {
- die("Query to show fields from table failed");
- }
- $fields_num = mysql_num_fields($result);
- for($i=0; $i<$fields_num; $i++)
- {
- $field = mysql_fetch_field($result);
- }
- while($row = mysql_fetch_row($result))
- {
- ?>
- <ul data-role="listview" data-inset="true" data-split-theme="a" data-split-icon="delete" data-theme="a" value="<?php echo "$row[0]"?>">
- <li><a href="" >
- <img src="_/images/chillies/li_<?php echo "$row[3]"?>.jpg"/>
- <h3><?php echo "$row[4] x $row[3]"?></h3>
- <p><?php echo "$row[1]"?></p>
- <a href="#confirm_del" data-rel="popup" data-position-to="window" data-transition="pop">Delete Record</a>
- </a>
- </li>
- </ul>
- <div data-role="popup" id="confirm_del" data-theme="a" data-overlay-theme="b" class="ui-content" style="max-width:340px; padding-bottom:2em;">
- <form method="post" action="delete.php" name="delrecord" data-ajax="false">
- <h3>Delete Record</h3>
- <p>Please confirm you wish to delete entry <?php echo "$row[0]"?></p>
- <div data-role="fieldcontain">
- <input type="hidden" id="id" name="id" value="<?php echo "$row[0]"?>">
- <input type="submit" value="Submit" id="submit" data-theme="b">
- <a href="#harvest" data-role="button" data-rel="back">Cancel</a>
- </div>
- </form>
- </div>
-
- <?php
- }
-
- mysql_free_result($result)
- ?>
- <a href="input.php" rel="external" data-role="button" data-theme="b" data-transition="slide">Done</a>
- <p class="small_text"> Logged in as <?php echo $_SESSION['USERNAME'];?> </p>
- </div>
- <div data-role="footer" data-position="fixed" data-theme="b">
- <p class="footer_text" >Test App</p>
- </div>
- </div>
- </body>
- </html>