简体   繁体   中英

how can i Display individual records details in another page using php

The following code is showing only the record list and i want when we click on a link then it go to another page which will suppose to show only the record details of a selected title. Currently, it always shows the same details. now what is the solution of show only the records details of a selected title

<table class="table table-striped table-bordered bootstrap-datatable datatable">// the record list table 
          <thead>
            <tr>
              <th>ID</th>
              <th>Course Name</th>
              <th>Duration</th>
              <th>Subjects</th>
              <th>Status</th>
              <th>Actions</th>
            </tr>
          </thead>   
          <tbody>
            <?php $getcourseslist = find_all("select * from course");
                while(@$getcourses = fetch_array($getcourseslist)){
             ?>
          <tr>
            <td><?= $getcourses->id; ?></td>
            <td> <a href="viewcoursedetails.php"><?= $getcourses->title;?></td></a>
            <td><?= $getcourses->duration/12; ?> Years</td>
            <td class="center">
              <?php $getsubjects= find_all("select * from subjects where courseid='$getcourses->id'");
                while(@$getsubs = fetch_array($getsubjects)){
               ?>
               <?= $getsubs->name; ?><br>
              <?php } ?>
              </td>
            <td class="center">
              <?php if($getcourses->status == 1){ ?>
              <span class="label label-success">Active</span>
              <?php }
                else{
               ?>
               <span class="label label-important">Blocked</span>
              <?php } ?>
            </td>
            <td class="center">

              <a class="btn btn-success" href="editcourse.php?course=<?= $getcourses->id; ?>">
                <i class="halflings-icon white edit"></i>  
              </a>
              <?php if($getcourses->status == 1){ ?>
              <a class="btn btn-danger" href="disable.php?course=<?= $getcourses->id; ?>&&action=block&&page=courses">
                <i class="halflings-icon white trash"></i> 
              </a>
              <?php }
                else{
               ?>
              <a class="btn btn-danger" href="disable.php?course=<?= $getcourses->id; ?>&&action=unblock&&page=courses">
                <i class="halflings-icon white trash"></i> 
              </a>
              <?php } ?>
            </td>
          </tr>
          <?php } ?>

          </tbody>
        </table>            
      </div>
    </div><!--/span-->

  </div><!--/row-->

// The following code is supposed to show only the record details of a selected title. Currently, it always shows the same detail list of previous page.//

Course Details View





             <tr>
                <th>ID :</th>
                <td><?= $getcourses2->id; ?></td>
              </tr>
              <tr>
                <th>Course Name :</th>
                <td><?= $getcourses2->title; ?></td>
              </tr>
              <tr>
                <th>Duration :</th>
                <td><?= $getcourses2->duration/12; ?> Years</td>
              </tr>
              <tr>
                <th>Subjects :</th>
                <td class="center">
              <?php $getsubjects= find_all("select * from subjects where courseid='$getcourses->id'");
                while(@$getsubs = fetch_array($getsubjects)){
               ?>
               <?= $getsubs->name; ?><br>
              <?php } ?>
              </td>
              </tr>
              <tr>
                <th>Monthly Fee :</th>
                <td><?= $getcourses2->monthlyfee ; ?></td>
              </tr>
              <tr>
                <th>Examination Fee :</th>
                <td><?= $getcourses2->examinationfee; ?></td>
              </tr>
              <tr>
                <th>Addmission Fee :</th>
                <td><?= $getcourses2->addmissionfee; ?></td>
              </tr>
              <tr>
                <th>Status :</th>
                <td class="center">
              <?php if($getcourses2->status == 1){ ?>
              <span class="label label-success">Active</span>
              <?php }
                else{
               ?>
               <span class="label label-important">Blocked</span>
              <?php } ?>
            </td>
              </tr>
              <tr>
                <th>Actions :</th>
                 <td class="center">

              <a class="btn btn-success" href="editcourse.php?course=<?= $getcourses->id; ?>">
                <i class="halflings-icon white edit"></i>  
              </a>
              <?php if($getcourses2->status == 1){ ?>
              <a class="btn btn-danger" href="disable.php?course=<?= $getcourses->id; ?>&&action=block&&page=courses">
                <i class="halflings-icon white trash"></i> 
              </a>
              <?php }
                else{
               ?>
              <a class="btn btn-danger" href="disable.php?course=<?= $getcourses->id; ?>&&action=unblock&&page=courses">
                <i class="halflings-icon white trash"></i> 
              </a>
              <?php } ?>
            </td>
          </tr>
          <?php } ?>


              </thead>
              <tbody>

            </table>
enter code here

change the table titles contents to anchor tags for example as

<a href="?sortby=id">ID</a>

and then in server side , process the query as

$sort = 'id'; if(isset($_REQUEST['sortby'])&&str_replace(' ','',$_REQUEST['sortby'])!="") $sort = $_REQUEST['sortby']; $queryText= "select * from table_name where order by ".$sort;

make sure that the value passed by the href is the attribute name in your sql table

this code makes the query to work as sorted default by id.. if a user uses another title, it will switch as needed.

hopes this works..

NOTE: people interested in down voting, please specify the reason

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM