0

This may be a simple question. But as a beginner I need help.
In my table created by simple HTML and used PHP to extract values from mysql, I need a column which should display an image on selecting the row from the table. How is it possible in PHP. Is it make use of jQuery to load dynamically. Please help.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • 2
    some code and some more elaborate question will be helpful – Vaibs_Cool Dec 15 '14 at 07:06
  • well if it is like showing up a check icon on the row which is selected, then this can be done using jquery itself, no need for php scripting. just add a click event to the rows and add the icon in the event handler. – dreamweiver Dec 15 '14 at 07:07
  • can you show, what you have tried ? – Praveen Dabral Dec 15 '14 at 07:08
  • its simply this : I created a table using HTML , and loaded the values from mysql using queries in PHP. but now i need to make a column to show the images along with the table. –  Dec 15 '14 at 07:08
  • use for loop for that matter and echo the images in respective column.. – Vaibs_Cool Dec 15 '14 at 07:10
  • Then just add a td and display the image using `` tag. Why do you need jquery for that? – Aditya Dec 15 '14 at 07:10
  • ^ i think because on selecting the next row should display another image –  Dec 15 '14 at 07:24

2 Answers2

0

You can use jQuery to display image. First by default on load column should not visible. Add style="display:none:' in column

On clicking row remove style using jQuery.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Jigisha Variya
  • 207
  • 1
  • 8
0

If you want to display image on click, then you need to use Jquery.

For simple you can create this feature like this,

First load all the images in table in specific class defined row but make its css attribute display:none;

in jquery you can write script like this....

$('.class-of-row').click(function(){
    $('.class-of-row.class-of-image').css("display","none"); /* to hide other image on click on specif row */
    $(this).child('.class-of-image').css("display","block"); /* To make visible image of clicked row */
});
rut2
  • 706
  • 1
  • 9
  • 29
  • one basic doubt : how to make a whole column to be used for displaying image in the table. Should i have to use another table and append it along? –  Dec 15 '14 at 07:26
  • @master mind sorry can not get your confusion... can you please eleborate in detail. – rut2 Dec 15 '14 at 07:29
  • my current table has headers and the corresponding fields. Now i am adding "Image" as the new column and i dont want cells in it, but the whole area of the table column to represent the image. Still confused? sorry iam studying the possibilities of my application –  Dec 15 '14 at 07:32
  • No it is no necessary... If you want to add image in existing table you can use simple jquery append like this $('.class-of-tr').append(""); – rut2 Dec 15 '14 at 07:41
  • thanks , can you give me some links where i can study on it...please –  Dec 15 '14 at 07:43
  • This can be useful.. http://mrbool.com/how-to-add-edit-and-delete-rows-of-a-html-table-with-jquery/26721 http://stackoverflow.com/questions/171027/add-table-row-in-jquery and please refere http://api.jquery.com/append/ and other functions like - .prepend(), .html(), .remove() – rut2 Dec 15 '14 at 07:46
  • i think appending the whole column will change the size of webpage. Is it better to add a new table then. in that case, by default let it show the first row image . –  Dec 15 '14 at 07:55
  • LOL.. dude fix width of table or its parent div.. . – rut2 Dec 15 '14 at 07:59