Jump to content

[HELP] Table Help


MannyG

Recommended Posts

Hello I have joined this forum for the sole purpose of trying to get this problem resolved so if you would please take a few minutes of your day to help out I would appreciate it very much.

 

I am a working on a dynamic table that communicates with a database (MySQL) where I can query results and such. In this table it works as a sort of "progress page" that shows test-results for certain test-cases on some products. However I am a co-op student and this is my first time working with PHP (and Javascript but I need help with the PHP part of things I guess?..) and in the table I created I have each row that is displayed to automatically have a button created beside it so that I can use that button to edit that particular row. The tricky part is I do not know how to make that button to be individual to a specific row and not end up changing the entire tables results (instead of being independent to that row it is with). I am not even sure I am explaining it correctly but I hope so. Basically this button works as an "edit" button so that it prompts an edit screen where you can change a row's results (and it will take your new added information and query it into the database).

 

Now I will provide a sort of scenario that will give you a better idea of how I want this to work...

So let us assume that there is 4 rows of data in the database and the table outputs these 4 rows, well if I add 40 more rows of data into the database the table will now output (upon a refresh of the html page) 44 rows. So I need the "edit" button to be dynamic so that it has a single relationship with the row it is in

 

Here is the code of my creation of the button.

<?php 
         ## Display Table and database results
    while($results = mysql_fetch_array($build_device_test)){
        
        echo"<tr>";
        echo    "<td class='side' >".$results['version']."</td>";
        echo    "<td class='CBundle' >" .$results['bundle']."</td>";
        echo    "<td class='CDevice' >".$results['devicename']."</td>";
        echo    "<td class='CJava' ></td>";
        echo    "<td class='CMMS' ></td>";
        echo    "<td class='CBranch' ></td>";
        echo    "<td class='CJC' ></td>";
        echo    "<td class='selection' ><button type='button' onclick='disp_prompt()'>Edit</button></td>"; 
     /* I am creating   the button for each row that is displayed on the table, and the disp_prompt is a basic login javascript thing I did based on alert box for the sake of seeing how to make it work. */
        echo"</tr>";
        }

echo"</tbody>";
echo"</table>";
?>

 

I have thought of using grid control, and so I used the slgrid open source which can be found here however I cannot use their edit screen nor can I use massive joins (as I have set up in my code).

 

I cannot disclose any specific information as these test cases are sensitive upon release (for the companies...and my job's sake) and I apologize for the length of this post or the difficulty of this problem.

Thank you,

 

Manny

Link to comment
Share on other sites

Why don't you just put a link?

 

Like

 

<?php 
         ## Display Table and database results
    while($results = mysql_fetch_array($build_device_test)){
        
        echo"<tr>";
        echo    "<td class='side' >".$results['version']."</td>";
        echo    "<td class='CBundle' >" .$results['bundle']."</td>";
        echo    "<td class='CDevice' >".$results['devicename']."</td>";
        echo    "<td class='CJava' ></td>";
        echo    "<td class='CMMS' ></td>";
        echo    "<td class='CBranch' ></td>";
        echo    "<td class='CJC' ></td>";
        echo    "<td class='selection' ><a href='delete.php?id='".$results['id']."' onclick='disp_prompt()'>Delete</a></td>"; 
     /* I am creating   the button for each row that is displayed on the table, and the disp_prompt is a basic login javascript thing I did based on alert box for the sake of seeing how to make it work. */
        echo"</tr>";
        }

echo"</tbody>";
echo"</table>";
?>

 

Then on delete.php , run those codes

 

<?php

//connection info first


$id = $_GET['id'];

$sql = "DELETE FROM mytable WHERE id = '$id'";
$result = mysql_query($sql) or die(mysql_error());

if($result){
echo 'Yay, it has been removed';
}
?>

 

Edit : you might want to show your Javascript disp_prompt() function.. I believe it might take the ID as it's argument !

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.