Here is my php function:
function displayrecords(){
$sql = "SELECT * FROM mytable";
$QueryResult = @mysql_query($sql) or die (mysql_error());
// more code...
At this point, the function prints out the retuned data in a table:
echo "<table class='table table-striped table-bordered table-hover'>
";
while(($Row = mysql_fetch_assoc($QueryResult)) !== FALSE) {
And here is where the issue begins:
echo "<tr><td><a class=\"open-EditRow btn btn-primary btn-mini\"
data-toggle=\"modal\" href=\"myEditModal\" id=\"".$Row[pk_tId]."\"
title=\"Edit this row\" \">Delete/Edit</a></td>";
There are more printed td
tags after this, but the issue is transferring the id to the modal window. I was told this could be done with straight php and without javascript or ajax.
This is what the code looks like in the modal:
<div class="modal hide fade" id="myEditModal" tabindex="-1" role="dialog"
aria-labelleby="myModalLabel" aria-hidden="true">
<div class="modal-body">
<?php
$id = "<input type=\"text\" name=\"groupId\" id=\"groupId\" value=\"\" />";
$sql = "SELECT resgroup FROM restable WHERE pk_tId = '" . $id . "'";
$result = mysql_query($sql);
As you will notice, the $sql
is reading $id
as an input tag, and therefore, it cannot find the id in the database, and thus returns nothing. I know it starts with the anchor tag inside the echoed table above.
I need to utilize a $_GET
(or POST
) in the anchor tag, but I do not know where to put it. I'm guessing it should go in the id=\"".$Row[pk_tId]."\"
, but how when php is already being used in that id?
I am a visual person, so if you could provide an example, I would be grateful.