Jump to content

cyprus

Members
  • Posts

    68
  • Joined

  • Last visited

    Never

Everything posted by cyprus

  1. If its of help then yes that could be done. I exported it to a file called orders.sql (I dont know if that contains the information you want or do you also want the structure export. How do I get it over to you. Many thanks
  2. Sorry, forgive me, as its the blind leading the blind. But as nobody had come in yet, I did a google search for the error you were getting, don't know if this link is of any help. Regards http://www.modwest.com/help/kb6-265.html
  3. I can paste the where statement for the first submission: WHERE GGroup IN ('1','2') however on selecting the next page, I cannot get anything other than: WHERE GGroup IN (Problem with query: select Orderdate as Ordered,product as Description,item as Code,Duration ,Qty as Quantity,unitprice as Unit,runningtotal as SubTotal from orders WHERE GGroup IN ( You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Also in moving to page 2 the checkbox drops out of being checked, so maybe that causes the error. If I just keep hitting submit, in other words just keep returning the form/page while on page 1, there are no errors. Thanks
  4. Many thanks for still being in there. I tried the code but it rejected the SQL select statement when trying to goto the next page, it was rejecting the where statement. I know the statement is being built as I have echoed it. Why is life so easy? Thanks again
  5. Sitting here, tearing the last strands of hair from my head, I just wonder why I am going down the page pagination route to show a long broken up HTML table when I am submitting the same page back to me. Is there a way to just refil the table each time with ascending/descending query limts, values held in session variables, which simply get counted up/down? Thanks
  6. Thanks. Yes the WHERE string is being passed to the SELECT query, This part works okay after first pass after checkboxes set, and on repetitive submissions. if (isset($_POST['X1'])) {     if (count($_POST['product'])) {     $prodlist = join("','", $_POST['product']);     $where = "WHERE GGroup IN ('$prodlist')";     }     } The WHERE statement gets added in as: .....from orders [b]$where [/b] order by Orderdate, PIndex $limit"; If I didn't have to extend my page to accomodate longer HTML tables being displayed, then all the code worked fine. I was about to add in To/From order dates to complete the page before I then realised my HTML tables could end up quite long.
  7. I tried the following, but with same results, could very well have misinterpreted suggestion: [code]if ($pagenumber == 1) {   echo " First Previous "; } else {   echo " <a href='{$_SERVER['PHP_SELF']}?pagenumber=1&where=$where'>First</a> ";   $prevpage = $pagenumber-1;   echo " <a href='{$_SERVER['PHP_SELF']}?pagenumber=$prevpage&where=$where'>Previous</a> "; } echo " ( Page $pagenumber of $lastpage ) "; if ($pagenumber == $lastpage) {   echo " Next Last "; } else {   $nextpage = $pagenumber+1;   echo " <a href='{$_SERVER['PHP_SELF']}?pagenumber=$nextpage&where=$where'>Next</a> ";   echo " <a href='{$_SERVER['PHP_SELF']}?pagenumber=$lastpage&where=$where'>Last</a> "; }[/code] Modified all href lines. Thanks again
  8. Many thanks, can you enlighten me a bit more on that as I haven't a clue from here on. Do you mean the select query needs to be passed on, or product groups. !! Thanks
  9. Thought I would post the complete code in case it helps. Regards [code]<? session_start(); $_SESSION['Dayte']=date("F j, Y, g:i a"); ?> <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Date</title> </head> <form action="" method="POST"> <BR>          <input type="submit" value="Submit Data" name="X1" > <input type="submit" value="Clear Data" name="X2" > <input type="submit" value="Exit" name="X3" > <BR>  // Offer product selection checkboxes. If page returned from submission then hold values <div align="left"> <table border="1" width="90%" id="table1" bgcolor="#FFFFCC" bordercolor="#000000" cellspacing="0"> <?   $products = array (         1 => 'Digital Betacam',         2 => 'Betacam SP',         3 => 'DVCPro',         4 => 'HDCAM',         5 => 'Mini DV'     );       foreach ($products as $id =>$prod) {         if ($_POST['product']) {             // was value of id in those posted?             $chk = in_array($id, $_POST['product']) ? 'checked' : '';         }         else $chk = ''; ?>        <TD> <?    echo "<input type='checkbox' name='product[]' value='$id' $chk>$prod<br>";               } ?> </TD> </TABLE> <BR>  // If page being resubmitted to itself, use posted values to create select WHERE statement <?   if (isset($_POST['X1'])) {     if (count($_POST['product'])) {     $prodlist = join("','", $_POST['product']);     $where = "WHERE GGroup IN ('$prodlist')";     }     } if (isset($_GET['pagenumber'])) {   $pagenumber = $_GET['pagenumber']; } else {   $pagenumber = 1; } // Connect to database, run query, setup multiple pages for viewing HTML table $username="root"; // $password="password"; $database ="xxx"; //connect to MySQL mysql_connect(localhost,$username); mysql_select_db($database) or die( "Unable to select database");  //$query = "SELECT count(*) FROM Orders"; $query = "select Orderdate as Ordered,product as Description,item as Code,Duration,Qty as Quantity,unitprice as Unit,runningtotal as SubTotal from orders $where order by Orderdate,Pindex"; $result = mysql_query($query) or die('Problem with query: ' . $query . '     '. mysql_error()); $query_data = mysql_fetch_row($result); $numrows = $query_data[0]; $rows_per_page = 10; $lastpage      = ceil($numrows/$rows_per_page); $pagenumber = (int)$pagenumber; if ($pagenumber < 1) {   $pagenumber = 1; } elseif ($pagenumber > $lastpage) {   $pagenumber = $lastpage; } $limit = 'LIMIT ' .($pagenumber - 1) * $rows_per_page .',' .$rows_per_page; //$query = "SELECT * FROM Orders $where $limit"; $query = "select Orderdate as Ordered,product as Description,item as Code,Duration,Qty as Quantity,unitprice as Unit,runningtotal as SubTotal from orders $where order by Orderdate, PIndex $limit"; $result = mysql_query($query) or die('Problem with query: ' . $query . '     '. mysql_error()); if (($result)||(mysql_errno == 0)) { echo "<table border='1' bordercolor='#000000' bgcolor='#FFFFCC' cellspacing='0' width='90%'><tr>";     if (mysql_num_rows($result)>0)     {     //loop thru the field names to print the correct headers           $i = 0;           while ($i < mysql_num_fields($result))     {           echo "<td align='center'><b><font face='Arial' size='1'>".    mysql_field_name($result, $i) . "</font></b></td>";           $i++;     }     echo "</tr>";         //display the data         while ($rows = mysql_fetch_assoc($result))           {       echo "<tr>"; foreach ($rows as $k => $data) { switch ($k) { case 'Unit': case 'SubTotal': $data = '&pound; '.$data; break; case 'Quantity': $data = $data. 'off ';                                   break; case 'OrderDate': $data = date("j-M-Y", strtotime($data)); } echo "<td align='center'><b><font face='Arial' size='1'>". $data . "</font></b></td>";     }     }   }else{     echo "<tr><td colspan='" . ($i+1) . "'>No Results found!</td></tr>"; } echo "</table>"; }else{   echo "Error in running query :". mysql_error(); } // PAGINATION BITS if ($pagenumber == 1) {   echo " First Previous "; } else {   echo " <a href='{$_SERVER['PHP_SELF']}?pagenumber=1'>First</a> ";   $prevpage = $pagenumber-1;   echo " <a href='{$_SERVER['PHP_SELF']}?pagenumber=$prevpage'>Previous</a> "; } echo " ( Page $pagenumber of $lastpage ) "; if ($pagenumber == $lastpage) {   echo " Next Last "; } else {   $nextpage = $pagenumber+1;   echo " <a href='{$_SERVER['PHP_SELF']}?pagenumber=$nextpage'>Next</a> ";   echo " <a href='{$_SERVER['PHP_SELF']}?pagenumber=$lastpage'>Last</a> "; } ?> [/code]
  10. Thanks, I will try and explain. The page/form has six checkboxes on representing 6 product types contained within a table containing archived orders. An HTML table displays the contents of the order table. However a user may wish to show only one or selected product types in the table, so they leave checkboxes checked or unchecked, and press submit which resubmits the same form back, the contents of the checkboxes perform a creation of the WHERE statement used in the database query. The status of checkboxes did remain in the conditions they were set, however selecting further pages in pagnitation cause the checkboxes to drop out and the query reverts to all records when page 2 of the table is shown. Hope you are with me so far. So when it was just the same page returned there were no problems, but in adding extension pages for long HTML tables I have this problem. Regards
  11. Thanks. However I tried it out and I lose my checkbox settings if I submit the page back to itself. Its all been working fine until I introduced page pagination, and its when I change the pages I lose my checkbox settings. Don't know if something in here would be the reason? [code]if ($pagenumber == 1) {   echo " First Previous "; } else {   echo " <a href='{$_SERVER['PHP_SELF']}?pagenumber=1'>First</a> ";   $prevpage = $pagenumber-1;   echo " <a href='{$_SERVER['PHP_SELF']}?pagenumber=$prevpage'>Previous</a> "; } echo " ( Page $pagenumber of $lastpage ) "; if ($pagenumber == $lastpage) {   echo " Next Last "; } else {   $nextpage = $pagenumber+1;   echo " <a href='{$_SERVER['PHP_SELF']}?pagenumber=$nextpage'>Next</a> ";   echo " <a href='{$_SERVER['PHP_SELF']}?pagenumber=$lastpage'>Last</a> "; }[/code] Thanks
  12. I have a series of checkboxes on a form/page. I use the code below which maintains there settings on page re submission. [code]<?         $products = array (         1 => 'Digital Betacam',         2 => 'Betacam SP',         3 => 'DVCPro',         4 => 'HDCAM',         5 => 'Mini DV'     );       foreach ($products as $id =>$prod) {         if ($_POST['product']) {             // was value of id in those posted?             $chk = in_array($id, $_POST['product']) ? 'checked' : '';         }         else $chk = ''; ?>        [/code] However, now I am using page pagination, the checkbox's lose there checked/unchecked status when paging. Any idea how I prevent this happening. Many thanks
  13. Anbody following my footsteps, this reference helped me and worked. Hope it helps someone else. http://www.tonymarston.net/php-mysql/pagination.html
  14. The statement Select Count(*) FROM Table. How do you get a count for [b]certain[/b] records in a table? ie what would the syntax be for eg Towns. Thanks 
  15. Thanks both. I changed the bits sasa suggested, and that brought the page navigation keys alive apart from the Previous link. Its a shame, thought that would have sorted things out using this code, however will junk it and try and find other code. Again thanks both of you for trying to help.
  16. Thought I would post the code in case something was clearer why it did not work. Regards [code] <? session_start(); $_SESSION['Dayte']=date("F j, Y, g:i a"); ?> <?php $username="root"; // $password="password"; $database="Forders"; mysql_connect(localhost,$username); mysql_select_db($database) or die( "Unable to select database");  //$result = mysql_query($query) or die('Problem with query: ' . $query . ' //    '. mysql_error());     $limit          = 10;                    $query_count    = "SELECT count(Ordernumber) FROM Orders";        $result_count  = mysql_query($query_count);        $totalrows      = mysql_num_rows($result_count);      if(empty($page)){         $page = 1;     }             $limitvalue = $page * $limit - ($limit);      $query  = "SELECT Ordernumber FROM Orders LIMIT $limitvalue, $limit";            $result = mysql_query($query) or die("Error: " . mysql_error());      if(mysql_num_rows($result) == 0){         echo("Nothing to Display!");     }     $bgcolor = "#E0E0E0"; // light gray     echo("<table>");         while($row = mysql_fetch_array($result)){         if ($bgcolor == "#E0E0E0"){             $bgcolor = "#FFFFFF";         }else{             $bgcolor = "#E0E0E0";         }     echo("<tr bgcolor=".$bgcolor.">n<td>");     echo($row["Orderdate"]);     echo("</td>n<td>");         }     echo("</table>");     if($page != 1){          $pageprev = $page--;                 echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> ");      }else{         echo("PREV".$limit." ");     }     $numofpages = $totalrows / $limit;          for($i = 1; $i <= $numofpages; $i++){         if($i == $page){             echo($i." ");         }else{             echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");         }     }     if(($totalrows % $limit) != 0){         if($i == $page){             echo($i." ");         }else{             echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");         }     }     if(($totalrows - ($limit * $page)) > 0){         $pagenext = $page++;                   echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>");      }else{         echo("NEXT".$limit);      }         mysql_free_result($result); ?> </html> [/code] MOD EDIT - code tags added. Please use them.
  17. I cut and pasted all the code from the first example into a page, amended all db references, and it just produced a series of n's at the left hand side, the links to goto the next page were dead? Any ideas why it does not burst into life? Thanks.
  18. Thankyou, I have printed the tutorial and have a read tomorow. Looks quite a lot to do, I will cut out color changes unless I can use it to identify product groups in my html table. Also I don't know how its going to slide into  my select queries. Probably all makes sense if I read it - I will. Thanks again
  19. I have an HTML table that dynamically fills from a select query. It works well however I have to think about curbing its height, otherwise my page will be a few miles high. Anybody got a suggestion as to avoiding such a disaster? Thanks
  20. Oh! Thats made me win the title of fool of the day? I should have tried it first, but hadn't a thought it would ever work. Many thanks :-X
  21. I have to include some items in my select query basically just to perform a sort. However I don't want the field appearing in my $Row. Is there a way to hide it? Thanks
  22. Yet again sasa thanks. Just had to swop the "off", ie cart before the horse, but that was minor as it all works, excellent, thanks again
  23. Thanks sasa, that did it!! Regards - Thanks onlyican for reply.
  24. Is it permitted/possible to change a select query statement to create an alias name. I tried below but did not work: $query = "select Total as runningtotal from orders"; runningtotal being the table field name, Total as I want to be displayed later. Thanks
  25.  while ($rows = mysql_fetch_assoc($result))    {      echo "<tr>";      foreach ($rows as $data) [b]I AM TRYING TO DISPLAY CERTAIN COLUMN VALUES HERE DIFFERENTLY TO MY TABLE DATA                  'UnitPrice' to get a preceding £ sign        'Qty'  to be preceded with the word "off"              'RunningTotal' to get a preceding £ sign        'Orderdate' to display date("j-M-Y", strtotime('orderdate'))[/b] [b]I tried a case statement built from previos reference, but cannot find which contains the data to modify. Thanks[/b] echo "<td align='left'><b><font face='Arial' size='1'>". $data . "</font></b></td>";      }    }  }else{    echo "<tr><td colspan='" . ($i+1) . "'>No Results found!</td></tr>";
×
×
  • 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.