0

Hi Coders,
I am really in need of your help......

Table of contents are available with action buttons,
When i click on a particular action button say for examble edit,the id of that particular row should be passed to the edit space,so that i can pull all other values from the database for editing.....(Here we are not loading any new page....all the code is in the same page)
Here i used javascript to pass the value but as php is running in the server side and javascript in the client side,the value is passed only after the second click....

Thanks for your help in advance.....

Regards,
Passion Coder.

2
Contributors
2
Replies
7
Views
5 Years
Discussion Span
Last Post by passioncoder
0

You will need to show what you have. Paste the relevant pieces of code, or the url if you have this online somewhere.

0
<table>
    <tr>
    <td>
    S.No
    </td>
    <td>
    Column Name
    </td>
    <td>
    Action Buttons
    </td>
    </tr>
    <?php
    if($_POST['term'])
    {
    $data = mysql_query("SELECT * FROM institute where instiname like '%$term%'")
    or die(mysql_error());
    }
    else
    {
    $data = mysql_query("SELECT * FROM institute")
    or die(mysql_error());
    }
    $var =1;
    while($info = mysql_fetch_array( $data ))
    {
    ?>
    <tr>
    <td>
    <?php echo $var;?>
    </td>
    <td>
    <?php echo $info['instiname'] ;?>
    </td>
    <td>
    <img src="images/b_edit.png" title="Edit">
    </td>
    </tr>
    </table>
    <?php
    }
    ?>

Here when i click on the edit image,a form should open with

<form>
   Column Name:
   <input type="text" name="ColumnName" value="<?php echo $info['instiname'] ; ?>" />
   </form>

And this form should be in place of our table above....(Replace table with edit form once image(action button) is clicked)And also the id of that particular row should be passed.So that it can be updated to the db again.

I tried to replace using show hide div. as follows and its working:

<div id="columnDetails">
 <table>
    <tr>
    <td>
    S.No
    </td>
    <td>
    Column Name
    </td>
    <td>
    Action Buttons
    </td>
    </tr>
    <?php
    if($_POST['term'])
    {
    $data = mysql_query("SELECT * FROM institute where instiname like '%$term%'")
    or die(mysql_error());
    }
    else
    {
    $data = mysql_query("SELECT * FROM institute")
    or die(mysql_error());
    }
    $var =1;
    while($info = mysql_fetch_array( $data ))
    {
    ?>
    <tr>
    <td>
    <?php echo $var;?>
    </td>
    <td>
    <?php echo $info['instiname'] ;?>
    </td>
    <td>
   <!-- <img src="images/b_edit.png" title="Edit">-->
    <input type="image" src="images/b_edit.png"              onclick=if(document.getElementById('editContent').style.display=='none') 
        {                                                       document.getElementById('editContent').style.display='';
                                                    document.getElementById('columnDetails').style.display='none';
        }
        else
        {
        document.getElementById('editContent').style.display='none';
        document.getElementById('columnDetails').style.display='';
        }
    </td>
    </tr>
    </table>
    <?php
    }
    ?>
</div>

The div to be replaced is

 <div id="editContent" style="display: none;" >
<form>
Column Name:
<input type="text" name="ColumnName" value="<?php echo $info['instiname'] ; ?>" />
</form>
</div>

Now help me to pass the id of the column name selected/clicked to the edit form.

Thanks & Regards,
Passion Coder.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.