Jump to content

peppericious

Members
  • Posts

    124
  • Joined

  • Last visited

Everything posted by peppericious

  1. I have a "vocab list" on a page in the form of a ul with li items. The number of vocab entries (li items) varies. I'd like to display the vocab in two adjacent columns. For argument's sake, suppose there are 19 items in the list, like this: <ul> <li>blah</li> <li>blah</li> <li>blah</li> <li>...</li> </ul> Is there a way of counting the number of li items, splitting the list in two, and then displaying the content like this, in two divs: <div>Col 1 <ul> <li>blah</li> <li>blah</li> <li>blah</li> <li>blah</li> </ul> </div> <div>Col 2 <ul> <li>blah</li> <li>blah</li> <li>blah</li> </ul> </div> Frankly, I have no idea how to go about this. Thanks in advance if anyone can shed light for me...
  2. I teach 6 different class groups, named "A" to "F", respectively. I have a small homework database from which I want to display the most recent 1 item of homework (record) for the class groups I have on any particular day of the week. So, for example, if it's Monday today, I want to display 5 items of homework, in order, for groups "A", "B", "C", "D" and "E". On the other hand, if it's Thursday today, I want to display 3 items of homework, in the order "F", "E" and "D", as that is the way my class groups are ordered on Thursday. I've created a switch statement and a select query as follows but the query isn't pulling the records out as I want them. Can anyone tell me what I'm doing wrong in the select query? How should I combine the auto-incrementing id column and the classgroups column so that the records are displayed as I want them?... (Right now, Tuesday, it's displaying D, C, B, A but it should be displaying A, B, C, D…) TIA switch (date("l")) { case 'Monday': $ord = "`id` DESC, FIELD(`classgroup`, 'A', 'B', 'C', 'D', 'E')"; $lim = 5; break; case 'Tuesday': $ord = "`id` DESC, FIELD(`classgroup`, 'A', 'B', 'C', 'D')"; $lim = 4; break; case 'Wednesday': $ord = "`id` DESC, FIELD(`classgroup`, 'F', 'C', 'E')"; $lim = 3; break; case 'Thursday': $ord = "`id` DESC, FIELD(`classgroup`, 'F', 'E', 'D')"; $lim = 3; break; case 'Friday': $ord = "`id` DESC, FIELD(`classgroup`, 'F', 'B', 'A')"; $lim = 3; break; } $q = "SELECT `id`, `classgroup`, `body`, `pointcles`, `arevoir`, DATE_FORMAT(created, '%a, %b %D') as `cr` FROM `homework` ORDER BY $ord LIMIT $lim";
  3. ... ahh, easy when explained. I've initialised the datepicker now, too, for the additional inputs and everything is working perfectly. Much appreciated, thanks.
  4. I'm trying to invoke jquery datepicker for multiple "inv_date" inputs in the same form but it's only appearing for the first instance. My form is like this: <form method='post' action=''> <div id='inputs_wrapper'> <div class='inputs'> <div class='element'> <label for='company'>Company</label> <input type='text' class='ind_input' name='company[]' value='' /> </div> <div class='element'> <label for='inv_date'>Invoice Date</label> <input type='text' name='inv_date[]' class='ind_input' value=''/> </div> <div class='element'> <label for='inv_no'>Invoice #</label> <input type='text' class='ind_input price' name='inv_no[]' value='' /> </div> <div class='element'> <label for='description'>Description</label> <input type='text' class='ind_input' name='description[]' value='' /> </div> <div class='element'> <label for='inv_total'>Invoice Total</label> <input type='text' class='ind_input price' name='inv_total[]' value='' /> </div> <!-- new elements start --> <div class='element'> <select name='payt_type[]' id='payt_type'> <option value='' selected='selected'>Payment Method...</option> <option value='vd'>Visa Debit</option> <option value='v'>Visa</option> <option value='so'>Standing Order</option> <option value='c'>Cash</option> </select> </div> <div class='element'> <select name='category[]' id='category'> <option selected='selected' value=''>Category...</option> <option value='tr'>Translation</option> <option value='pr'>Printing</option> <option value='pp'>P&P</option> <option value='ad'>Advertising</option> <option value='hd'>Hardware</option> <option value='sw'>Software</option> <option value='cns'>Consumables</option> <option value='comm'>Communications</option> <option value='snd'>Sundries</option> </select> </div> <div class='element'> <div class='radios'>VAT: <label style='display:inline'><input type='radio' name='vat_rate[]_0' value='0' id='vat_rate_0' />0</label> <label style='display:inline'><input type='radio' name='vat_rate[]_0' value='.23' id='vat_rate_1' />23</label> <label style='display:inline'><input type='radio' name='vat_rate[]_0' value='.135' id='vat_rate_2' />13.5</label> </div> <!-- new elements end --> <!-- <a href='#' class='removeclass' style='position: absolute; right: 10px;'>X</a> --> </div> </div> <!-- inputs collection end --> <div class='clearer'> </div> </div> <!-- inputs wrapper end --> <input type='submit' name='submit' value='Submit' /> </form> ... and I'm appending additional inputs with this: <script type='text/javascript'> $(document).ready(function() { // select input text on click $(function(){ $(document).on('click','input[type=text]',function(){ this.select(); }); }); /////////// $(function() { $('input[name^="inv_date"]').each(function() { $(this).datepicker(); }); }); var max_inputs = 8; //maximum input boxes allowed var inputs_wrapper = $("#inputs_wrapper"); //Input boxes wrapper ID var add_button = $("#add_more_inputs"); //Add button ID var x = inputs_wrapper.length; //initlal text box count var field_count=1; //to keep track of text box added $(add_button).click(function (e) //on add input button click { if(x <= max_inputs) //max input box allowed { field_count++; //text box added increment //add input box $(inputs_wrapper).append("<div class='inputs'><div class='element'><label for='company'>Company</label><input type='text' class='ind_input' name='company[]' value='' /></div><div class='element'><label for='inv_date'>Invoice Date</label><input type='text' name='inv_date[]' class='ind_input' value=''/></div><div class='element'><label for='inv_no'>Invoice #</label><input type='text' class='ind_input price' name='inv_no[]' value='' /></div><div class='element'><label for='description'>Description</label><input type='text' class='ind_input' name='description[]' value='' /></div><div class='element'><label for='inv_total'>Invoice Total</label><input type='text' class='ind_input price' name='inv_total[]' value='' /></div><div class='element'><select name='payt_type[]'> <option value='' selected='selected'>Payment Method...</option> <option value='vd'>Visa Debit</option> <option value='v'>Visa</option> <option value='so'>Standing Order</option> <option value='c'>Cash</option></select></div><div class='element'><select name='category[]'><option selected='selected' value=''>Category...</option><option value='tr'>Translation</option><option value='pr'>Printing</option><option value='pp'>P&P</option><option value='ad'>Advertising</option><option value='hd'>Hardware</option><option value='sw'>Software</option><option value='cns'>Consumables</option><option value='comm'>Communications</option><option value='snd'>Sundries</option></select></div><div class='element'><div class='radios'>VAT: <label style='display:inline'><input type='radio' name='vat_rate[]_"+field_count+"' value='0' id='vat_rate_"+field_count+"' />0</label> <label style='display:inline'><input type='radio' name='vat_rate[]_"+field_count+"' value='.23' id='vat_rate_"+field_count+"' />23</label> <label style=display:inline'><input type='radio' name='vat_rate[]_"+field_count+"' value='.135' id='vat_rate_"+field_count+"' />13.5</label></div></div><a href='#' class='removeclass' style='position: absolute; right: 10px;'>X</a></div>"); x++; //text box increment } return false; }); $("body").on("click",".removeclass", function(e){ //user click on remove text if( x > 1 ) { $(this).parent('div').remove(); //remove text box x--; //decrement textbox } return false; }) }); </script> ... but the datepicker is appearing for only the first "inv_date" instance, as I said. Can anyone tell me what I'm doing wrong? TIA.
  5. I need to mark up a lot of dialogues, which will be created on an ongoing basis. Every second paragraph will be spoken by alternate participants in the dialogue. The dialogues will always be like this, with the participants' names at the start of the paragraphs... <p>Joe: Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall...</p> <p>Jill: The Grand Ol' Duke of York, he had ten thousand men...</p> <p>Joe: And so on and so forth</p> <p>Jill: And whatever the weather</p> But they will need to be marked up like this: <div class='dlg'> <div class='person_1'>Joe</div> <div class='spk_1'>Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall...</div> </div> <div class='dlg'> <div class='person'>Jill</div> <div class='spk'>The Grand Ol' Duke of York, he had ten thousand men...</div> </div> <div class='dlg'> <div class='person_1'>Joe</div> <div class='spk_1'>And so on and so forth</div> </div> <div class='dlg'> <div class='person'>Jill</div> <div class='spk'>And whatever the weather</div> </div> Can anyone suggest a way of doing the conversion? Thanks in advance.
  6. You're using mysql and mysqli extensions in the same script. Don't think you can do that... Also, second-last line should be: mysql_close($link); .. rather than: $mysql_close($link);
  7. Only the table rows should be echoed within the loop. The opening and closing table tags should be outside. So, you should have: $query = mysql_query($sql); //give resource the variables echo "<table border='1' cellpadding='2' cellspacing='3' width='100%'>"; // << table top *outside* the loop while ($row = mysql_fetch_array($query)) { //display results for hour defined by SQL if (!$query) { // add this check. die('Invalid query: ' . mysql_error()); } //-------------------End of SQL for daily stats echo "<tr><th>Hour</th><th>Total Quantity</th><th>Total Value</th><th>Average Quantity</th><th>Average Value</th><th>Average Value per Item</th></tr>"; echo "<tr><td>" .$row['HOUR']; echo "</td><td>" .$row['Total Quantity']; echo "</td><td>" .$row['Total Value']; echo "</td><td>" .$row['Average Quantity']; echo "</td><td>" .$row['Average Value']; echo "</td><td>" .$row['Average Value Per Item']; echo "</td></tr>"; } echo "</table>"; // << table bottom *outside* the loop ?>
  8. If you do want to use a loop, initialise a counter before the loop starts and then increment it before the bottom of the loop: $sql = "SELECT * FROM `users` ORDER BY `gold` DESC LIMIT 50"; $qry = mysql_query($sql); $counter = 1; // create a counter before the loop starts while ($res = mysql_fetch_array($qry)) { echo $counter . " " . $res['username'] . " " . $res['gold'] . "<br />"; $counter++; // add 1 to counter for each iteration of loop }
  9. Thank you so, so much for your help with this. It works perfectly. I can't say I understand right of the bat how it works, exactly, but I'm studying it right now... One final question now, as I look at your code: what does this line do, exactly? $results[$result][] = $id;
  10. .. thanks, but I'm flummoxed now. I have no idea how to manipulate my post data such that I can build a query like the above. I'll have to think again.
  11. .. yes, thanks. However, I cannot figure out how to do that... Could I impose on you for some pointers?...
  12. .. that's giving me this, for example: Array ( [result] => Array ( [1] => senior [2] => junior [3] => senior [4] => senior [5] => unsuccessful ) [submit] => Run update ) ... but those data aren't getting written to the db when I click submit. I'm still getting 'There was a problem updating the records...'. Any thoughts?
  13. Thanks, Barand. I'm closer to my destination but the update isn't working. I'm getting 'There was a problem updating the records...'. Can you see anything obviously problematic in my code below? <?php include('includes/mysqli_connect.php'); // if the form is submitted, mark 'successful' children in db if(isset($_POST['submit'])) { $result = $_POST['result']; $list_of_ids = join(',', $_POST['result']); $sql = "UPDATE table1 SET `result` = $result WHERE id IN ($list_of_ids)"; $r = mysqli_query($dbc, $sql); if(!$r) { echo "<p style='color:red'>There was a problem updating the records. Please try again later.</p>"; } } // get the children and display them (if they're not marked for deletion) $q = "SELECT `id`, `child`, `result` FROM table1 WHERE `delete` = 0"; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) > 0) { $output = '<form method="post"><table width="100%" cellpadding="2">'; while ($row = mysqli_fetch_array($r)) { $id = $row['id']; $child = $row['child']; $output .= "<tr> <td>$id</td> <td>$child</td> <td><label> <input type='radio' name='result[$id]' value='senior' /> Senior</label> <label> <input type='radio' name='result[$id]' value='junior' /> Junior</label> <label> <input type='radio' name='result[$id]' value='reserve' /> Reserve</label> <label> <input type='radio' name='result[$id]' value='unsuccessful' /> Unsuccessful</label> </td> </tr>"; } $output .= "</table> <input type='submit' name='submit' id='submit' value='Run update' /> </form>"; echo $output; }
  14. Children are applying to play on teams. There are more children than there are places, so some will get to play for the Senior team, some for the Junior team, some will be Reserve, and some will be Unsuccessful. I want to be able to pull up all children and assign their application result in the db in one update process. I have figured out - eventually, thanks to other posts I've seen here - how to do such a single-query-multiple-records-update using just one 'successful' checkbox for each child, using this code: <?php include('includes/mysqli_connect.php'); // if the form is submitted, mark 'successful' children in db if(isset($_POST['submit'])) { $list_of_ids = join(',', $_POST['child']); $sql = "UPDATE table1 SET `result` = 'successful' WHERE id IN ($list_of_ids)"; $r = mysqli_query($dbc, $sql); if(!$r) { echo "<p style='color:red'>There was a problem updating the records. Please try again later.</p>"; } } // get the children and display them $q = "SELECT `id`, `child`, `result` FROM table1 WHERE `delete` = 0"; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) > 0) { $output = '<form method="post">'; while ($row = mysqli_fetch_array($r)) { $id = $row['id']; $child = $row['child']; $result = $row['result']; $output .= "<p><input type='checkbox' value='$id' name='child[]'> $child: <strong>$result</strong></p>"; } $output .= "<p><input type='submit' name='submit' value='Update Records' /></p> </form>"; echo $output; } However, I have not succeeded in figuring out how to modify the above code so that each child has 4 radio buttons (Senior, Junior, Reserve, Unsuccessful), rather than the single checkbox. Thanks in advance for your help which would allow me do that...
  15. Thanks for your help with this, which I'm working to try to implement. In the meantime, I've created a little form with 'from' and 'to' datepicker inputs. According to the dates entered in those, I have an sql query to retrieve the appropriate records for whatever time period I wish. $q = "SELECT company, description, vat, (total-vat) as subtotal, total, MONTHNAME(inv_date) as month, DAY(inv_date) as day FROM purchase WHERE inv_date >= '$from' AND inv_date <= '$to' ORDER BY inv_date";
  16. No, there will always be invoices for every month pair.
  17. Ok, so far I've just got this... a chronological list of invoices. As I say, though, I'd like to group them in 2-month periods... <?php include('includes/mysqli_connect.php'); $q = "SELECT company, description, vat, (total-vat) as subtotal, total, inv_date FROM purchase ORDER BY inv_date"; $r = mysqli_query($dbc, $q); $retrieved = mysqli_num_rows($r); if ($retrieved > 0) { $records_output = '<table width="100%" cellpadding="2"> <tr> <td>Company</td> <td>Invoice Date</td> <td>Vat</td> <td>Subtotal</td> <td>Total</td> <td>Inv Date</td> </tr> '; while ($row = mysqli_fetch_array($r)) { $company = $row['company']; $description = $row['description']; $vat = $row['vat']; $subtotal = $row['subtotal']; $total = $row['total']; $inv_date = $row['inv_date']; $records_output .= "<tr> <td>$company</td> <td>$description</td> <td>$vat</td> <td>$subtotal</td> <td>$total</td> <td>$inv_date</td> </tr>"; } $records_output .= '</table'; } echo $records_output;
  18. .. er, I'm not building any report yet because I don't know how. I'm simply retrieving all records, sorted by inv_date, as follows: SELECT inv_number, vat, total, inv_date FROM `invoices` order by inv_date;
  19. I've written a script to help me keep track of VAT on invoices. It all works fine. However, I would like to group invoices in 2-month periods. How can I query the invoices table such that records are returned in 2-month periods according to the inv_date? In other words, I want to be able to display a table like this, grouped Jan/Feb, Mar/Apr, etc, with VAT and Inv totals... Jan/Feb --------------------------------------------------------------- Inv. no. | Desc. | Inv. Date | Vat Amount | Inv. Total xxx | xxxx | 22-01-2013 | 23.82 | 127.37 xxx | xxxx | 28-01-2013 | 14.81 | 79.21 xxx | xxxx | 14-02-2013 | 20.96 | 112.08 --------------------------------------------------------------- 59.59 318.66 Mar/Apr --------------------------------------------------------------- Inv. no. | Desc. | Inv. Date | Vat Amount | Inv. Total xxx | xxxx | 17-03-2013 | 19.97 | 106.77 xxx | xxxx | 18-03-2013 | 20.69 | 110.62 xxx | xxxx | 14-04-2013 | 2.80 | 14.99 --------------------------------------------------------------- 43.46 232.38 May/June --------------------------------------------------------------- Inv. no. | Desc. | Inv. Date | Vat Amount | Inv. Total xxx | xxxx | .......... | ..... | ..... xxx | xxxx | .......... | ..... | ..... --------------------------------------------------------------- --.-- ---.00 Any help will be much appreciated.
  20. No, indeed I don't have any experience working for big companies or governments. And, yes, I can well imagine planning and approval time makes up proportionately much more time than coding does. I'm not suggesting for a moment that all this time shouldn't be billed for. Still though, 33,000 hours of whatever at a hundred an hour? It's hard for me to imagine that this particular site could warrant such investment...
  21. ... but, with all due respect, requinix, the cost shouldn't have anything to do with who's got the cheque book... whether that be a government, or an individual. The cost should be based on the amount of time and expertise required to build the site. As for 'reasonable', that's the very question: I know they're crude calculations but 3.3m would pay 16 people 100k a year for 2 years, even if they did no other work. By the way, requinix, are you saying that, given the tools the developers appear to have used, they've done a good job (but that if they'd used different tools, they could have done better?... I just wondered about what you said regarding ASP.NET WebForms...) As for usability, I find the site to be something of a mess. There seem to be boxes everywhere, placed in a seemingly haphazard fashion, which makes navigation very unintuitive.
  22. It was reported today that Tourism Ireland paid 2.5 million euro to have this site built. An additional 500k euro was paid for the 'ireland.com' domain name, according to the report. So, at today's exchange rate, we're talking about 3.3m USD for the build, plus 670k USD for the domain. Is this not a staggeringly high cost for the development?... Someone please tell me I'm missing something crucial that justifies this cost... Thoughts, anyone?
×
×
  • 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.