Jump to content

peppericious

Members
  • Posts

    124
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

peppericious's Achievements

Member

Member (2/5)

0

Reputation

  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?
×
×
  • 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.