Hi Friends ,

I am new to PHP . I have designed a page and using MySQL at backend .
On my page , I have following logic .
1. There are 4 checkboxes and a search button .
2. On the basis of selection of checkboxes when user clicks search button then results are displayed on the same page in a table . My problem is when user selects only one checkbox , layout of page looks fine but when user selects more than 1 checkbox layout gets disorted , although the no. of records in both cases (single check box and multiple check boxex) are same . Also in the results table at last row , I will put a hyperlink which will export the results to excel . All the data is coming fine in both the cases . Problem is only with the layout when more than one checkbox is selected .

Please help . Pasting my code below :

<body>
<form id="form1" name="form1" method="post" action="ds_my_tickets_continue.php">
<table width="88%" align="center" bgcolor="#9CB7AK"> <!-- outermost main table-->
  <tr style="border:1px solid #F00;">
    <td height="27" colspan="2" align="right" >  
    <?php echo '<a href="login_success.php?user='.$userid.' "><img src="images/home.jpg" width="30" height="21" alt="home" /></a>'; ?><?php echo "Welcome ," .$userid ; ?> <input type="submit" name="logout" id="logout" value="Logout" onclick="form.action = 'logout.php';" />
    </td>
  </tr>
  <tr>
    <td height="106" colspan="2" style="border:1px solid  #FFF;">

       <?php

          if($mess != '') {


           echo "<SCRIPT>
              alert('$mess');
           </SCRIPT>";


           }

           $temp_date1 = $_POST['date5'];
           $temp_date2 = $_POST['date6'];

         ?>

    </td>
  </tr>
  <tr valign="top">
    <td width="16%" height="653" style=" border-left:1px solid  #FFF;" align="center"><p>Main Menu</p>
      <table width="84%"> <!-- Menu Table -->
        <tr align="left">
          <td width="13%">1.</td>
          <td width="87%"><?php echo '<a href="cr_ticket.php?user='.$userid.' ">Create Ticket</a>' ; ?></td>
        </tr>
        <tr align="left">
          <td>2.</td>
          <td><?php echo '<a href="ed_tickets.php?user='.$userid.'">Edit tickets</a>' ; ?></td>
        </tr>
        <tr align="left">
          <td>3.</td>
          <td><?php echo '<a href="ds_my_tickets.php?user='.$userid.'">Display My tickets</a>' ; ?></td>
        </tr>
        <tr align="left">
          <td>4.</td>
          <td><?php echo '<a href="ds_all_tickets.php?user='.$userid.'">Display All tickets</a>' ; ?></td>
        </tr>
      </table>  <!-- Menu Table -->
    <p> </p></td>
    <td width="84%" style=" border-left:1px solid   #FFF;"> 

      <table width="86%" height="23" align="center" bgcolor="#C4D9CB"> <!--Searching table-->
            <tr>
              <td width="18%">Search :</td>
              <td width="3%">Date</td>
              <td width="33%">
              <label for="date1">
              <?php

              //get class into the page
              require_once('classes/tc_calendar.php');


            $myCalendar = new tc_calendar("date5", true, true);
            //$myCalendar->setIcon("calendar/images/iconCalendar.gif"); 
             $myCalendar->setIcon("images/iconCalendar.gif");  
            $myCalendar->setDate(1,1,2013);   
            // $myCalendar->setPath("calendar/");    
             $myCalendar->setYearInterval(2000, 2015);    
            $myCalendar->dateAllow('2008-05-13', '2015-03-01');   
            $myCalendar->setDateFormat('j F Y');      
            $myCalendar->setAlignment('left', 'bottom');      
            $myCalendar->setSpecificDate(array("2011-04-01", "2011-04-04", "2011-12-25"), 0, 'year');     
            //$myCalendar->setSpecificDate(array("2011-04-10", "2011-04-14"), 0, 'month');    
            $myCalendar->setSpecificDate(array("2011-06-01"), 0, '');      
             //output the calendar
            $myCalendar->writeScript(); 
            $sel_date = $myCalendar->getDate();

      ?>

              </label></td>
              <td width="5%"> TO</td>
              <td width="41%">

              <label for="date2">
              <?php

              //get class into the page
              require_once('classes/tc_calendar.php');


            $myCalendar = new tc_calendar("date6", true, true);
            //$myCalendar->setIcon("calendar/images/iconCalendar.gif"); 
             $myCalendar->setIcon("images/iconCalendar.gif");  
            $myCalendar->setDate1(1,1,2013);      
            // $myCalendar->setPath("calendar/");    
             $myCalendar->setYearInterval(2000, 2015);    
            $myCalendar->dateAllow('2008-05-13', '2015-03-01');   
            $myCalendar->setDateFormat('j F Y');      
            $myCalendar->setAlignment('left', 'bottom');      
            $myCalendar->setSpecificDate(array("2011-04-01", "2011-04-04", "2011-12-25"), 0, 'year');     
            //$myCalendar->setSpecificDate(array("2011-04-10", "2011-04-14"), 0, 'month');    
            $myCalendar->setSpecificDate(array("2011-06-01"), 0, '');      
             //output the calendar
            $myCalendar->writeScript(); 
            $sel_date = $myCalendar->getDate();

      ?>

              </label></td>
            </tr>
            <tr>
              <td><label>
                <input type="checkbox" name="ch_status[2]" value="New" id="ch_status_2" />
                New</label></td>
              <td> </td>
              <td> </td>
              <td> </td>
              <td> </td>
            </tr>
            <tr>
              <td><label>
                <input type="checkbox" name="ch_status[0]" value="In Process" id="ch_status_0" />
                In Process</label></td>
              <td> </td>
              <td> </td>
              <td> </td>
              <td> </td>
            </tr>
            <tr>
              <td><label>
                <input type="checkbox" name="ch_status[1]" value="Confirmed" id="ch_status_1" />
                Confirmed</label></td>
              <td> </td>
              <td> </td>
              <td> </td>
              <td> </td>
            </tr>
            <tr>
              <td><label>
                <input type="checkbox" name="ch_status[3]" value="Customer Action" id="ch_status_3"  checked="checked"/>
                Customer Action</label></td>
              <td> </td>
              <td> </td>
              <td> </td>
              <td> </td>
            </tr>
            <tr>
              <td><input type="submit" name="search" id="search" value="Search" onclick="form.action = 'ds_my_tickets_continue.php?user=<?php echo $userid ?>';"/></td>
              <td> </td>
              <td> </td>
              <td> </td>
              <td> </td>
            </tr>
          </table> <!--Searching table-->
      <p></p>

<table width="86%" align="center" bgcolor="#C4D9CB">

            <tr >
              <td width="4%" style="border:1px solid  #FFF;">TId</td>
              <td width="7%" style="border:1px solid  #FFF;">Date</td>
              <td width="9%" style="border:1px solid  #FFF;">Status</td>
              <td width="11%" style="border:1px solid  #FFF;">Priority</td>
              <td width="13%" style="border:1px solid  #FFF;">Created By</td>
              <td width="18%" style="border:1px solid  #FFF;">Description</td>
              <td width="12%" style="border:1px solid  #FFF;">Close Date</td>
              <td width="11%" style="border:1px solid  #FFF;">Assigned to</td>
              <td width="15%" style="border:1px solid  #FFF;">Category</td>     
            </tr>
            <?php
             include 'data_selection.php' ;


          require_once("excelwriter.class.php");
           $excel=new ExcelWriter("billreport.xls");
          if($excel==false) 
            echo $excel->error;

            $myArr=array("");
            $myArr=array("Product Report");
            $excel->writeLine($myArr);
            $myArr=array("");
            $excel->writeLine($myArr);
            $myArr=array("ticket id","Description","date","Assigned to");
            $excel->writeLine($myArr);
            $from=$_POST['from'];
            $to=$_POST['to'];


        if(is_array($_POST['ch_status'])){
            foreach ($_POST['ch_status'] as $id)
            {

                $query  = "SELECT * FROM master_ticket WHERE status = '$id' and date >= '$temp_date1' and date <= '$temp_date2'";
               $result = mysql_query($query) ; // or die(mysql_error()); 

               do { ?>
              <tr >
                <td style="border:1px solid  #FFF;"><?php echo $row['tid']; ?></td>
                <td style="border:1px solid  #FFF;"><?php echo $row['date']; ?></td>
                <td style="border:1px solid  #FFF;"><?php echo $row['status']; ?></td>
                <td style="border:1px solid  #FFF;"><?php echo $row['priority']; ?></td>
                <td style="border:1px solid  #FFF;"><?php echo $row['createdby']; ?></td>
                <td style="border:1px solid  #FFF;"><?php echo $row['desc']; ?></td>
                <td style="border:1px solid  #FFF;"><?php echo $row['closedate']; ?></td>
                <td style="border:1px solid  #FFF;"><?php echo $row['assignedto']; ?></td>
                <td style="border:1px solid  #FFF;"><?php echo $row['categ'];?> </td> <?php $myArr=array($row_rs_ds_my_tickets['tid'],$row_rs_ds_my_tickets['desc'],$row_rs_ds_my_tickets['date'],$row_rs_ds_my_tickets['assignedto']);
        $excel->writeLine($myArr);?>
              </tr>
  <?php } while ($row = mysql_fetch_assoc($result)); ?>

          </table>


            <?php   
            }} // forech($_POST['ch_status'] as $id) ?>


    <p> </p> </td>

  </tr>
  <tr>
    <td height="21" colspan="2" style="border:1px solid  #FFF;" align="right"><b>Designed By : Achal Mehra</b></td>
  </tr>
</table> <!-- outermost main table-->
  </form > 
</body>

Recommended Answers

All 2 Replies

Member Avatar for LastMitch

I am new to PHP . I have designed a page and using MySQL at backend .

Is this code related to datepicker?

Hi LastMitch ,

Yes code is realted to date picker .
I am using one Java script to show a calendr to user where he picks date
and selects the checkboxes and then database is searched to show the results

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.