1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Small PHP Code

Discussion in 'PHP' started by sonu21, Jan 29, 2012.

  1. #1
    Hello Guys,I have one simple problem I am creating a PHP site with database.All works great but I want a php code which can hide a row from a click.Like I have table in Database like users then I required a simple code which can hide users details with a button click.

    Thanks in Advanced................

    sonu21, Jan 29, 2012 IP
  2. techimtiyaz

    techimtiyaz Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    put id in the table i.e. <table id="tbl" ....>...</table>
    and put some button click call a jquery function
    i.e. <a href="javascript:void(0)" onclick="hideTable();">hide</a>
    and in javascript use
    function hideTable()
    { $("#tbl").hide(); }
    don't forget to include jQuery.
    techimtiyaz, Jan 29, 2012 IP
  3. maureeeteeeee

    maureeeteeeee Member

    Likes Received:
    Best Answers:
    Trophy Points:
    Or if you want to use Legacy Javascirpt, this is good too

    var myRow = document.getElementById('#tlb');
    if ( myRow.style.display == 'block' || myRow.style.display == '' ){
         myRow.style.display = 'none';
    } else {
         myRow.style.display = 'block';
    Code (markup):
    This functions toggle the display of the row. If it's shown, it hides. Otherwise, it displays it.

    If you just want it to thide, remove the else {} part.
    maureeeteeeee, Feb 1, 2012 IP
  4. sonu21

    sonu21 Member

    Likes Received:
    Best Answers:
    Trophy Points:
    Hello Guys,I mean I want to hide Database row with a link or button ?

    Thanks For Your Reply.Please help me
    sonu21, Feb 2, 2012 IP
  5. QZAX

    QZAX Greenhorn

    Likes Received:
    Best Answers:
    Trophy Points:
    you can not do that with php.

    techimtiyaz and maureeeteeeee gave the right solution. These scripts are activated on "onclick" event of the button.
    With php you the only thing you can do is redirect to other page on button click. The redirected page will have no users details.
    I don't think this is what you wanted. I guess you do not want the page to be refreshed or changed. PHP can not do that.

    You need Javascript or jquery for that. jquery is also a javascript.
    I suggest you to go with javascript solution instead of jquery because if you use jquery you will need to include the jquery file too. and including jquery for such a small task is not a good idea.

    What maureeeteeeee gave you is the best solution for you.
    QZAX, Feb 8, 2012 IP