Jump to content

Displaying MYSQL resuts in hidden div


koop1koop

Recommended Posts

I am trying to display the results of a mysql query in a popup div! I have tried alsorts that I can think of but now I am asking for help... the code I have submitted shows results being returned in a table but when the lik is clicked to open the hidden div it just displays the results for the firs row only...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Dispatches Results</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel='stylesheet' href='sample.css' type='text/css'>
<style type='text/css'>
.dragme { cursor: move }
</style>
<script type='text/javascript'>
var ie = document.all;
var nn6 = document.getElementById &&! document.all;

var isdrag = false;
var x, y;
var dobj;

function movemouse( e ) {
  if( isdrag ) {
    dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
    dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
    return false;
  }
}

function selectmouse( e ) {
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";

  while (fobj.tagName != topelement && fobj.className != "dragme") {
    fobj = nn6 ? fobj.parentNode : fobj.parentElement;
  }

  if (fobj.className=="dragme") {
    isdrag = true;
    dobj = document.getElementById("styled_popup");
    tx = parseInt(dobj.style.left+0);
    ty = parseInt(dobj.style.top+0);
    x = nn6 ? e.clientX : event.clientX;
    y = nn6 ? e.clientY : event.clientY;
    document.onmousemove=movemouse;
    return false;
  }
}

function styledPopupClose() {
  document.getElementById("styled_popup").style.display = "none";
}

document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");
</script>
</head>
<body>
  


<div align="center"><br />
<?php
include "inc/config.inc.php";

?>
<?php
$m       =    $_GET["m"];
$y       =    $_GET["y"];
$sort    =    $_GET["sort"];
if(!isset($sort)) $sort = mon;
if(!isset($m)) $m = date("F");
if(!isset($y)) $y = date("Y") 
?>
  <table width="710" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>     </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td><a href="index.php">Home</a></td>
    </tr>
    <tr>
      <td colspan="6"><div align="center">Select image to download CSV file for the <strong>month</strong> in view  </div></td>
    </tr>
    <tr>
      <td colspan="6"><div align="center">
     <a href="inc/csv.php?m=<?php echo $m ?>&y=<?php echo $y ?>">
     <img src="../images/iconCSV.gif" alt="Download CSV" title="Download_CSV" width="50" height="50" border="0" id="Download_CSV" /></a></div></td>
    </tr>
    <tr>
      <td width="54" rowspan="3"> </td>
      <td width="55" rowspan="3"> </td>
      <td width="466"> </td>
      <td width="41" rowspan="3"> </td>
      <td width="45" rowspan="3"> </td>
      <td width="49" rowspan="3"> </td>
    </tr>
    <tr>
      <td>

     <form id="form1" name="form1" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?php echo $m ?>&y=<?php echo $y ?>">
      <select  name="m" id="m">
              <option style="font-weight:bold" value="<?php echo $m ?>" selected="selected"><?php echo $m ?></option>
              <option value="January">January</option>
              <option value="February">February</option>
              <option value="March">March</option>
              <option value="April">April</option>
              <option value="May">May</option>
              <option value="June">June</option>
              <option value="July">July</option>
              <option value="August">August</option>
              <option value="September">September</option>
              <option value="October">October</option>
              <option value="November">November</option>
              <option value="December">December</option>
          </select>      
         
         <select name="y" id="y">
              <option style="font-weight:bold" value="<?php echo $y ?>" selected="selected"><?php echo $y ?></option>
              <option value="2010">2010</option>
              <option value="2009">2009</option>
            </select>
      <input type="submit" name="Submit" value="Submit" />
      </form></td>
    </tr>
    <tr>
      <td>Results for <strong><?php echo $m ?> <?php echo $y ?></strong></td>
    </tr>
  </table>

  <?php

$sql="SELECT * FROM $table WHERE mon = '".$m."' AND yea = '".$y."' Order by $sort";

      $query = mysql_query($sql);
      $total_results = mysql_num_rows($query);
      $limit = "15"; //limit of archived results per page.
      $total_pages = ceil($total_results / $limit); //total number of pages
      if (empty($page))
      {
      $page = "1"; //default page if none is selected
      }
      $offset = ($page - 1) * $limit; //starting number for displaying results out of DB
      $query = "SELECT * FROM $table WHERE mon = '".$m."'AND yea = '".$y."' Order by $sort LIMIT $offset, $limit";
      $result = mysql_query($query);

      //This is the start of the normal results...
     echo "
<table  border='1' cellspacing='0' cellpadding='2'>
<tr>
<th width='90'align='center'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=num&m=".$m."&y=".$y."'>
Order Number</a></th>
<th width='90'  align='center'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=ref&m=".$m."&y=".$y."'>
Multicare Ref</a></th>
<th width='120' align='center'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=loan&m=".$m."&y=".$y."'>
Loan</a></th>
<th width='150'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=dealer&m=".$m."&y=".$y."'>
Dealer</a></th>
<th width='80' >
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=customer&m=".$m."&y=".$y."'>
Customer</a></th>
<th width='150'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=destination&m=".$m."&y=".$y."'>   
Destination</a></th>
<th width='150'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=product&m=".$m."&y=".$y."'>
Product</a></th>
<th width='25' align='center'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=qty&m=".$m."&y=".$y."'>
QTY</a></th>
<th width='150'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=serial&m=".$m."&y=".$y."'>
Serial</a></th>
<th width='115'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=del_date&m=".$m."&y=".$y."'>
Delivery Date</a></th>
<th width='100'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=method&m=".$m."&y=".$y."'>
Method</a></th>
<th width='115'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=return_date&m=".$m."&y=".$y."'>   
Return Date</a></th>
<th width='115'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=date_returned&m=".$m."&y=".$y."'>
Date Retuned</a></th>
<th width='115' align='center'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=box&m=".$m."&y=".$y."'>
Box</a></th>
<th width='100'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=mon&m=".$m."&y=".$y."'>
Month</a></th>
<th width='60'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=yea&m=".$m."&y=".$y."'>
Year</a></th>
<th width='60'>
<a href='".$PHP_SELF."?showold=yes&page=$i&sort=yea&m=".$m."&y=".$y."'>
Notes</a></th>
</tr>";

      while ($row = mysql_fetch_array($result))
      {
      // display your results as you see fit here.
echo "<tr bgcolor='".$row['colour']."'>";
echo "<td align='center'>". $row['num'] ."</td>";
echo "<td align='center'>". $row['ref'] ."</td>";
echo "<td align='center'>". $row['loan'] ."</td>";
echo "<td>". $row['dealer'] ."</td>";
echo "<td>". $row['customer'] ."</td>";
echo "<td>". $row['destination'] ."</td>";
echo "<td>". $row['product'] ."</td>";
echo "<td align='center'>". $row['qty'] ."</td>";
echo "<td>". $row['serial'] ."</td>";
echo "<td align='center'>". $row['del_date'] ."</td>";
echo "<td align='center'>". $row['method'] ."</td>";
echo "<td align='center'>". $row['return_date'] ."</td>";
echo "<td align='center'>". $row['date_returned'] ."</td>";
echo "<td align='center'>". $row['box'] ."</td>";
echo "<td align='center'>". $row['mon'] ."</td>";
echo "<td align='center'>". $row['yea'] ."</td>";
echo "<td align='center'>"; ?>
<div onClick='document.getElementById("styled_popup").style.display="block"'><input type="hidden" name="id" value="<?php  $id=$row['id']; ?>"/><?php echo $row['note']; ?> <?php echo $id; ?> </div>
<div id='styled_popup' name='styled_popup' style='width: 380px; height: 300px; display:none; position: absolute; top: 150px; left: 150px;'>
<table width='380' cellpadding='0' cellspacing='0' border='0'>
<tr>
<td><img height='23' width='356' src='images/x11_title.gif' class='dragme'></td>
<td><a href='javascript:styledPopupClose();'><img height='23' width='24' src='images/x11_close.gif' border='0'></a></td>
</tr>
<tr><td colspan='2' style='background: url("images/x11_body.gif") no-repeat top left; width: 380px; height: 277px;'>
<?php 
echo $row['id'];

echo "". $row['id'] ."";
?>
</td></tr>
</table>
</div>

<?php
"
</td>";
echo "</tr>";

} 
echo "</table>";
?>


     <?php
      mysql_close();
      // This is the Previous/Next Navigation
      echo "<font face=Verdana size=1>";
      echo "Pages:($total_pages) Total:($total_results) "; // total pages
      if ($page != 1)
      {
      echo "<a href=$PHP_SELF?page=1&sort=$sort&m=".$m."&y=".$y."><< First</a>   "; // First Page Link
      $prevpage = $page - 1;
      echo " <a href=$PHP_SELF?page=$prevpage&sort=$sort&m=".$m."&y=".$y."><<</a> "; // Previous Page Link
      }
      if ($page == $total_pages)
      {
      $to = $total_pages;
      }
      elseif ($page == $total_pages-1)
      {
      $to = $page+1;
      }
      elseif ($page == $total_pages-2)
      {
      $to = $page+2;
      }
      else
      {
      $to = $page+3;
      }
      if ($page == 1 || $page == 2 || $page == 3)
      {
      $from = 1;
      }
      else
      {
      $from = $page-3;
      }
      for ($i = $from; $i <= $to; $i++)
      {
      if ($i == $total_results) $to=$total_results;
      if ($i != $page)
      {
      echo "<a href=$PHP_SELF?showold=yes&page=$i&sort=$sort&m=".$m."&y=".$y.">$i</a>";
      }
      else
      {
      echo "<b><font face=Verdana size=2>[$i]</font></b>";
      }
      if ($i != $total_pages)
      echo " ";
      }
      if ($page != $total_pages)
      {
      $nextpage = $page + 1;
      echo " <a href=$PHP_SELF?page=$nextpage&sort=$sort&m=".$m."&y=".$y.">></a> "; // Next Page Link
      echo "   <a href=$PHP_SELF?page=$total_pages&sort=$sort&m=".$m."&y=".$y.">Last >></a>"; // Last Page Link
      }
      echo "</font>";
      // This is the end of the Previous/Next Navigation
?>
</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/194170-displaying-mysql-resuts-in-hidden-div/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.