Jump to content

cyprus

Members
  • Posts

    68
  • Joined

  • Last visited

    Never

Everything posted by cyprus

  1. Many thanks Barand, mysql_fetch_assoc($result) fixed my problem. Best regards
  2. Can someone spot why this is not working properley. Its supposed to dynamically create an HTML table from a database query. But the columns are getting repeated, and the captions are misplaced. Many thanks [code]<?php if (($result)||(mysql_errno == 0)) { echo "<table border='1' bordercolor='#000000' bgcolor='#FFFFCC' width='80%'><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='left'>". mysql_field_name($result, $i) . "</td>";       // $i++;     }     echo "</tr>";         //display the data     while ($rows = mysql_fetch_array($result))     {       echo "<tr>";       foreach ($rows as $data)       {         echo "<td align='center'>". $data . "</td>";       }     }   }else{     echo "<tr><td colspan='" . ($i+1) . "'>No Results found!</td></tr>";   }   echo "</table>"; }else{   echo "Error in running query :". mysql_error(); } ?> [/code] MOD EDIT code tags added
  3. I have a series of checkboxes on a page/form which allows the user to dynamically build a WHERE statement. $where = "WHERE GGroup IN ('$prodlist')"; Is it possible to add into the above a where condition to select records between two dates? Many thanks.
  4. This may be a tall order, but I am trying to display column names above a dropdown list. I have code that puts data in a list in columns that are correctly spaced apart. I know that the column appears in the variable $cname, 5 lines down from the code below. My problem is $cname values appear multiple times where its echoed as its within code running for every row. Can someone offer suggestion as to how I can get a variable/array containing 1 set of column names that can be displayed either above the list or as a first row within the list. Thanks  // get data lengths       $maxlen=array();       foreach ($data_rows as $k=>$row)       foreach($row as $cname=>$val) {       echo $cname;                  $val = trim($val);             switch ($cname) {         case 'UnitPrice':      $val = '£' . number_format($val,2); break;         case 'Qty':    $val = number_format($val, 0) . ' off'; break;         case 'RunningTotal':      $val = '£' . number_format($val,2); break;         case 'Orderdate':  $val = date("j-M-Y", strtotime($val)); break;     }         $data_rows[$k][$cname] = $val;         $maxlen[$cname] = max($maxlen[$cname], strlen($val));     }         $contents = "<select style=\"font-family:monospace;\" name=\"selectbox\" multiple size=\"$numrows\">\r\n";         foreach ($data_rows as $row) {         $id = $row['id'];         unset ($row['id']);         $contents .= "<option value='$id'>";         $line = '';         foreach($row as $cname=>$val) {         $line .= str_pad($val, $maxlen[$cname]+2, chr(160));    //pad with non breaking spaces         }         $contents .= $line;         $contents .= "</option>\r\n";     }         $contents .= "</select>";         echo "<div>$contents</div>";
  5. Thanks, problem solved. I did not think the page was being submitted as a dropdown list was not filling. Buried deep was an If statement surrounding a $_Post return referenced to submit button named submit. I discovered the page was getting submitted by Barands earlier teaching of printing out all Posted details, so thanks everyone its fixed.
  6. Many thanks all. The form should just submit back to itself. At present there is no directing regarding $_POST values. Mystery?
  7. I have a submit button which will not submit a form if its name is not Submit? The code below shows it in a non working mode, if I replace X1 with the word Submit it works? Many thanks <input type="submit" name="X1" value="Select All Data Required - Click to Submit">
  8. Think I've got it? if (isset($_POST['L1']) && empty($_POST['L1'])) { echo "Its Empty"; } else if (isset($_POST['L1']) && !empty($_POST['L1'])) { echo "It's Full"; }else{ echo "It's really empty from start"; } Seems to behave itself, fingers crossed. Thanks again to you both for comming in. Regards
  9. Thanks again. The second code has a problem, but the first one works. On first page load it does not report any message but in use does the correct thing. I will have a play to see how I can get a first loaded page message of empty. Thanks for your help.
  10. Many thanks Mr Pancake, that got rid of the error. I used this: echo '<pre>', print_r($_POST, true), '</pre>'; if (isset($_POST['L1']) && empty($_POST['L1'])) { echo "Its Empty"; } else { echo "It's Full"; } However the strange thing is when the page/form first loads, it reports being full. However If I fill $_POST['L1'] with a value from list L1, it behaves normally there after. However, thanks Barand, your suggestion of putting the code in above, showed: Array ( ) So it is not empty to begin with? Is that due to the list L1 getting filled later in the code or is that normal. Can I check for a value of Array() being in $_POST['L1'] or is there another way. Thankyou both
  11. Many thanks, however it's unhappy with the function is_empty, fatal error??
  12. I have a form/page with a dropdown list named L1. The form/page submits back to inself, and when getting re-submitted, I am trying to check for Post data. However I cannot figure out the following senario. if (isset($_POST['L1'])==true) { $FT=$_POST['L1']; echo $FT; echo "Its Full!"; } if (isset($_POST['L1'])==false) { $FT=$_POST['L1']; echo $FT; echo "Its Empty!"; } When the form/page first displays, "Its Empty" is echoed as expected. If I do not click on the dropdown box L1, and just submit the form to itself, I get "Its Full".? If when the form/page first displays, I click on list L1 and then submit the form back, I get "Its Full" and the value of $FT. However if I repeat the submission, $FT returns empty as would be expected, but the message "Its Full" still appears. What am I missing?  Thanks
  13. Thanks. That Baagrid is something else!! I miss all my VB goodies like Flexgrid etc. Feel almost homesick now. Certanly very useful, probably a bit expensive for light useage. Had I gone the other way, ie insert checkboxes first instead of programatically growing them, I'd know where they were going to appear. Aynhow all good fun if you can survive it. Regards
  14. Thanks again Barand. VB Hat?, so it still shows does it? I wish it was in VB. What you did worked as ever, thanks again. While there, do you know of any packages that enable HTML to be written around PHP. Sorry to admit I normally cheat and use Frontpage to do all the HTML side, ie making pages look smart, and then go into writing the PHP bits so that I can place things in tables. If I work backwards, then I get in a mess and my page gets created in a tabular form, wasted page areas. Thought I would just ask, thanks again.
  15. I am tring to make my dates look easier to read in a list. I have tried the following, as well as numerous permutaions!! Thanks case 'UnitPrice':$val = '£' . number_format($val,2); break; case 'Qty':    $val = number_format($val, 0) . ' off'; break; case 'RunningTotal':      $val = '£' . number_format($val,2);break; [b]case 'Orderdate':      $val = .date_format(date("j-M-Y", strtotime(['Orderdate']))); break;[/b]
  16. A resounding yes. Cannot say a big enough thankyou. Have a good weekend.
  17. Just a quick one while this post is still fresh. There are 2 column values, Price and Quantity. Is there an easy way to add to the database data being retrieved for the list, the addition of "£" before the price value/data, and "off" after the quantity values. At the moment all prices look like eg 6.00 and the quanties eg 30. If its a lot of work then I will give it a miss as you have done enough already. Thanks
  18. Many thanks. I was thinking there may be an unwanted space somewhere, and whether there was a trim function. I tried your code and it made no difference, however I noticed it to be on one product item where it happens. I went into the database, and found the answer. I had tried adding spaces to the data in the field when I was trying to get columns in line with an ordinary dropdown list code. I removed the bodge that never worked, and hey ho all is well. Everything lines up perfectly. Many thanks again following me through on this nightmare. Best regards
  19. Slight problem - any ideas. I added a few more column selections for the user, and for some reason the columns start wandering out of line in columns 5,6,7. They follow a column 4 which has varying lengths, despite the fact that column 3 is okay following column 2 which has varying lengths. I tried increasing $maxlen[$cname]+2 to +3 but that just moved things along. Any suggestions, thanks
  20. Sorry, my posting saying thanks very much for trying went out just as you must have been putting your posting up. Absolutely brilliant, works just as I wanted it to!!! I had been away for a while and only just been putting it in. I am so greatful to you, I have spent days/hours trying to get it done so I could move on. You have made my weekend, hope yours is going well, many, many thanks again.
  21. Many thanks for trying, very much appreciated.
  22. I know this does not work, as I do not know the correct syntax, but hopefully it will explain what I am trying to do. My problem line is here when either Orderdate or Ordernumber has not been selected by the user to in the select query (in other words he does not want it included in his dropdown list. [code]$_rows[] = array("Orderdate"=>mysql_result($result,$i,"Orderdate"), "Ordernumber"=>mysql_result($result,$i,"Ordernumber"), "Value"=>$i);[/code]   How can I split this up to be in the position of checking each section before finally putting it all into the $_rows[] array? [code]$tryA=array("Orderdate"=>mysql_result($result,$i,"Orderdate");   $tryB=array("Ordernumber"=>mysql_result  ($result,$i,"Ordernumber"),"Value"=>$i);   $_rows[] = array($tryA & "," & $tryB);[/code]  Just wish this was visual basic, could have walked away from it weeks ago. Thanks again  
  23. 1. The dropdown list is filled with all rows of a table 2. The dropdown list shows all the user (checkbox panel selected) columns that he wants. OrderDate  OrderNumber  Description Quantity UnitPrice etc. 3. The dropdown list can show only rows from certain product groups is so wished, again from checkbox selection (selecting 1-6 groups) The list will show nothing on first page/form load, until checkboxes are checked and the form re submitted back to itself. 4. At this stage I need to do nothing on clicking a list item, its just for viewing. Thanks for being patient, I know it's a bit of an odd one. Thanks
  24. Thanks Barand. The form/page has checkboxes on that allow certain COLUMNS of a complete order table (at present everything thats in the database) As well as this they have checkboxes which allow for the list to contain 1-6 product groups of all records in the table (this goes into a where statement) So basically the form allows a dynamic contruction of a select query which then gets relevant data. The problem arises when it gets to the dropdown list, which has non dynamically constructed lines of code. So if something gets ommitted from what it's expecting then it errors. The page/form gets submitted back to itself, so the first pass there is no data for the dropdown to show anything. The dropdown code provides column spacing so the list looks uniform. Once I can get passed this problem, I can look at providing the users a chance to select all orders between dates, but until then I am stuck. Does that help? Thanks
×
×
  • 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.