Fetching data trough checkboxes in laravel problem










0














I am trying to get data from two different tables using two separate queries in Laravel. But I want to display these two tables data with two different check boxes, for example if I want to see publications detail or education detail or both, please help what I should to do with my view.



My code is shown here:



Controller code is ExampleController.php



<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use DB;
use Auth;


class ExampleController extends Controller


public function index()


$result = DB::table('education')->get();
$data = DB::table('publications')->get();

return view('triel',compact('result','data'));





My view file is trail.blade.php and its code is given.



@extends('layouts.app')
@section('content')
<div class="container"><br>
<h1>Irfan Khan Triel Page</h1>

<div class="text text-success text-center">
PHD Research
</div>
<table class="table">
<tr>
<th>
PHD Research Area
</th>
<th>University</th>
<th>Country</th>
</tr>

@foreach($result as $value)
<tr>
<td>$value->research_area</td>

<td>$value->univ</td>

<td>$value->country</td>
</tr>
@endforeach
</table>

<div class="text text-success text-center">
Publications Detail
</div>
<table class="table">
<tr>
<th>
Title
</th>
<th>Status</th>
<th>Year</th>
</tr>

@foreach($data as $value)
<tr>
<td>$value->title</td>

<td>$value->status</td>

<td>$value->year</td>
</tr>
@endforeach

</table>

@endsection


My route file is given here.



Route::get('triel','ExampleController@index');


Please modify my view to take these two results separately by checkboxes.










share|improve this question




























    0














    I am trying to get data from two different tables using two separate queries in Laravel. But I want to display these two tables data with two different check boxes, for example if I want to see publications detail or education detail or both, please help what I should to do with my view.



    My code is shown here:



    Controller code is ExampleController.php



    <?php

    namespace AppHttpControllers;

    use IlluminateHttpRequest;
    use DB;
    use Auth;


    class ExampleController extends Controller


    public function index()


    $result = DB::table('education')->get();
    $data = DB::table('publications')->get();

    return view('triel',compact('result','data'));





    My view file is trail.blade.php and its code is given.



    @extends('layouts.app')
    @section('content')
    <div class="container"><br>
    <h1>Irfan Khan Triel Page</h1>

    <div class="text text-success text-center">
    PHD Research
    </div>
    <table class="table">
    <tr>
    <th>
    PHD Research Area
    </th>
    <th>University</th>
    <th>Country</th>
    </tr>

    @foreach($result as $value)
    <tr>
    <td>$value->research_area</td>

    <td>$value->univ</td>

    <td>$value->country</td>
    </tr>
    @endforeach
    </table>

    <div class="text text-success text-center">
    Publications Detail
    </div>
    <table class="table">
    <tr>
    <th>
    Title
    </th>
    <th>Status</th>
    <th>Year</th>
    </tr>

    @foreach($data as $value)
    <tr>
    <td>$value->title</td>

    <td>$value->status</td>

    <td>$value->year</td>
    </tr>
    @endforeach

    </table>

    @endsection


    My route file is given here.



    Route::get('triel','ExampleController@index');


    Please modify my view to take these two results separately by checkboxes.










    share|improve this question


























      0












      0








      0







      I am trying to get data from two different tables using two separate queries in Laravel. But I want to display these two tables data with two different check boxes, for example if I want to see publications detail or education detail or both, please help what I should to do with my view.



      My code is shown here:



      Controller code is ExampleController.php



      <?php

      namespace AppHttpControllers;

      use IlluminateHttpRequest;
      use DB;
      use Auth;


      class ExampleController extends Controller


      public function index()


      $result = DB::table('education')->get();
      $data = DB::table('publications')->get();

      return view('triel',compact('result','data'));





      My view file is trail.blade.php and its code is given.



      @extends('layouts.app')
      @section('content')
      <div class="container"><br>
      <h1>Irfan Khan Triel Page</h1>

      <div class="text text-success text-center">
      PHD Research
      </div>
      <table class="table">
      <tr>
      <th>
      PHD Research Area
      </th>
      <th>University</th>
      <th>Country</th>
      </tr>

      @foreach($result as $value)
      <tr>
      <td>$value->research_area</td>

      <td>$value->univ</td>

      <td>$value->country</td>
      </tr>
      @endforeach
      </table>

      <div class="text text-success text-center">
      Publications Detail
      </div>
      <table class="table">
      <tr>
      <th>
      Title
      </th>
      <th>Status</th>
      <th>Year</th>
      </tr>

      @foreach($data as $value)
      <tr>
      <td>$value->title</td>

      <td>$value->status</td>

      <td>$value->year</td>
      </tr>
      @endforeach

      </table>

      @endsection


      My route file is given here.



      Route::get('triel','ExampleController@index');


      Please modify my view to take these two results separately by checkboxes.










      share|improve this question















      I am trying to get data from two different tables using two separate queries in Laravel. But I want to display these two tables data with two different check boxes, for example if I want to see publications detail or education detail or both, please help what I should to do with my view.



      My code is shown here:



      Controller code is ExampleController.php



      <?php

      namespace AppHttpControllers;

      use IlluminateHttpRequest;
      use DB;
      use Auth;


      class ExampleController extends Controller


      public function index()


      $result = DB::table('education')->get();
      $data = DB::table('publications')->get();

      return view('triel',compact('result','data'));





      My view file is trail.blade.php and its code is given.



      @extends('layouts.app')
      @section('content')
      <div class="container"><br>
      <h1>Irfan Khan Triel Page</h1>

      <div class="text text-success text-center">
      PHD Research
      </div>
      <table class="table">
      <tr>
      <th>
      PHD Research Area
      </th>
      <th>University</th>
      <th>Country</th>
      </tr>

      @foreach($result as $value)
      <tr>
      <td>$value->research_area</td>

      <td>$value->univ</td>

      <td>$value->country</td>
      </tr>
      @endforeach
      </table>

      <div class="text text-success text-center">
      Publications Detail
      </div>
      <table class="table">
      <tr>
      <th>
      Title
      </th>
      <th>Status</th>
      <th>Year</th>
      </tr>

      @foreach($data as $value)
      <tr>
      <td>$value->title</td>

      <td>$value->status</td>

      <td>$value->year</td>
      </tr>
      @endforeach

      </table>

      @endsection


      My route file is given here.



      Route::get('triel','ExampleController@index');


      Please modify my view to take these two results separately by checkboxes.







      php mysql laravel






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 19:43









      marc_s

      570k12811021250




      570k12811021250










      asked Nov 12 at 18:41









      Bilal Khan

      11




      11






















          1 Answer
          1






          active

          oldest

          votes


















          0














          There are many ways that can be done to achieve what you're trying. The example I am showing is using Jquery.




          1. Add an Id to your tables e.g



            <table class="table" id="publication-detail">
            <table class="table" id="research-detail">




          2. Add event on click listener to your checkboxes. When one of the checkboxes gets clicked, lets say publication, then hide your research-detail table. e.g.



            $(".checkbox-publication").click(function()
            $("#research-detail").css('display', 'none');
            $("#publication-detail").css('display', 'block');
            );



          And vice versa. If both of them clicked, display both tables.



          If you want to use something more advanced and efficient try Ajax.



          1. https://api.jquery.com/click/

          2. https://api.jquery.com/css/

          3. https://api.jquery.com/jQuery.ajax/





          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268232%2ffetching-data-trough-checkboxes-in-laravel-problem%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            There are many ways that can be done to achieve what you're trying. The example I am showing is using Jquery.




            1. Add an Id to your tables e.g



              <table class="table" id="publication-detail">
              <table class="table" id="research-detail">




            2. Add event on click listener to your checkboxes. When one of the checkboxes gets clicked, lets say publication, then hide your research-detail table. e.g.



              $(".checkbox-publication").click(function()
              $("#research-detail").css('display', 'none');
              $("#publication-detail").css('display', 'block');
              );



            And vice versa. If both of them clicked, display both tables.



            If you want to use something more advanced and efficient try Ajax.



            1. https://api.jquery.com/click/

            2. https://api.jquery.com/css/

            3. https://api.jquery.com/jQuery.ajax/





            share|improve this answer

























              0














              There are many ways that can be done to achieve what you're trying. The example I am showing is using Jquery.




              1. Add an Id to your tables e.g



                <table class="table" id="publication-detail">
                <table class="table" id="research-detail">




              2. Add event on click listener to your checkboxes. When one of the checkboxes gets clicked, lets say publication, then hide your research-detail table. e.g.



                $(".checkbox-publication").click(function()
                $("#research-detail").css('display', 'none');
                $("#publication-detail").css('display', 'block');
                );



              And vice versa. If both of them clicked, display both tables.



              If you want to use something more advanced and efficient try Ajax.



              1. https://api.jquery.com/click/

              2. https://api.jquery.com/css/

              3. https://api.jquery.com/jQuery.ajax/





              share|improve this answer























                0












                0








                0






                There are many ways that can be done to achieve what you're trying. The example I am showing is using Jquery.




                1. Add an Id to your tables e.g



                  <table class="table" id="publication-detail">
                  <table class="table" id="research-detail">




                2. Add event on click listener to your checkboxes. When one of the checkboxes gets clicked, lets say publication, then hide your research-detail table. e.g.



                  $(".checkbox-publication").click(function()
                  $("#research-detail").css('display', 'none');
                  $("#publication-detail").css('display', 'block');
                  );



                And vice versa. If both of them clicked, display both tables.



                If you want to use something more advanced and efficient try Ajax.



                1. https://api.jquery.com/click/

                2. https://api.jquery.com/css/

                3. https://api.jquery.com/jQuery.ajax/





                share|improve this answer












                There are many ways that can be done to achieve what you're trying. The example I am showing is using Jquery.




                1. Add an Id to your tables e.g



                  <table class="table" id="publication-detail">
                  <table class="table" id="research-detail">




                2. Add event on click listener to your checkboxes. When one of the checkboxes gets clicked, lets say publication, then hide your research-detail table. e.g.



                  $(".checkbox-publication").click(function()
                  $("#research-detail").css('display', 'none');
                  $("#publication-detail").css('display', 'block');
                  );



                And vice versa. If both of them clicked, display both tables.



                If you want to use something more advanced and efficient try Ajax.



                1. https://api.jquery.com/click/

                2. https://api.jquery.com/css/

                3. https://api.jquery.com/jQuery.ajax/






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 13 at 13:09









                adis

                162115




                162115



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268232%2ffetching-data-trough-checkboxes-in-laravel-problem%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    政党

                    天津地下鉄3号線