Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. The URL is only rewritten internally, the user still sees whatever they enter into the address bar (example.com/mine).
  2. Ah, I think you're talking about variable variables: $name = 'foo'; $value = 'bar'; $$name = $value;
  3. I'll take your word for it, but I'm a bit bored of the whole super hero genre now. Is gaining super powers at 18 year old that like puberty for an alien?
  4. You'd already have the data structured like that if you used mysql_fetch_assoc (or equivalent if not using MySQL).
  5. As Thorpe said, you don't need to create a directory. You can use the Apache module mod_rewrite to rewrite the request URL from "example.com/mine" to something like "example.com/profile.php?username=mine". Create a file called ".htaccess" in your web root directory, and add: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z0-9_\.-]+)$ profile.php?username=$1 </IfModule> Create a file called profile.php, and just add the following for now: <?php print_r($_GET); ?> Then go to 'yourserver.com/mine'.. You should see the array printed out containing the username parameter.
  6. Superman return[ed] a few years back, and that was s***!
  7. There's a collection of sort functions that may be useful to you, including usort which allows you call a function which decides on the order logic.
  8. Will it be the same file downloaded multiple times, or multiple files downloaded once? If the latter you're probably going to struggle with this as you can't 'stream' files through a browser like that. Your server would have to download the >500MB file prior to allowing the user to download it. Dependent on your server's connection speed and how many users will be downloading at once, it could be a long wait. If it's the same file however, or several that are frequently used, I'd download a cached version periodically to your own server.
  9. Have a look into extract.
  10. You can just use .submit(). Also note that I've switched it to use an ID, as you can have multiple elements with the same class: <form name="formName" action=""> <input type="text" name="message" id="message" /> <input type="submit" /> </form> <script type="text/javascript"> $('form[name=formName]').submit(function() { var message = $('#message').val(); if (!$.trim(message)) { // problem } }); </script>
  11. I don't think you're using the right function to be honest. greatest() requires multiple values in order to return the greatest out of them, you're just passing a single value. Within the join 'on' clause you need to specify how to join `clan_matches` to `clan_match_players`, not the condition. Also you wouldn't use a LEFT JOIN here as that would join the data regardless, you need use a normal JOIN and specify the condition on which to join the tables within the where clause.
  12. Would depend entirely upon the type of report. Is it just a dump of the data into an Excel Spreadsheet for example? Is there any logic or sums that need to be performed for totals or conditional display of data?
  13. This is fairly basic and doesn't cover removing elements from the list, but it's a good start to work from: The jQuery: // assign the click event to the button $('#addButton').click(function() { // get the input object var input = $('#addInput'); // create a new hidden input for value $('form[name=listForm]').append('<input type="hidden" name="hiddenList[]" value="' + input.val() + '" />'); // append to the visible list $('#selectedList').append('<br />' + input.val()); // finally clear the value of the input and set focus back input.val('').focus(); }); Demo HTML: <form name="listForm" method="post" action=""> <input type="text" id="addInput" /> <input type="button" id="addButton" value="Add" /> <div id="selectedList"></div> </form> To extend it to be able to remove elements, you'll need to associate each item in the list to the relevant hidden input using a common ID..
  14. jQuery.trim() takes a string input, not a selector.
  15. My guess is that it's down to the HTML. Semantic, valid mark-up can play a big part in SEO these days; it's what's used by the search engines to interpret what an element is on the page. For example the links on the right side of the menu (audition, videos, etc.), are written using a table: <table style="width: 100%"> <tr> <td style="width: 363px" class="copyright2"><a class="copyright" title="Matt Cardle Audition 1" href="Audition1/">Audition</a> <img src="images/arrow.png" width="10" height="10" /></td> <td class="copyright2"><a class="copyright" title="Matt Cardle Videos" href="Videos/">Videos</a> <img src="images/arrow.png" width="10" height="10" /></td> </tr> <tr> <td class="copyright2" style="width: 363px"><a class="copyright" title="Matt Cardle Bootcamp" href="Bootcamp/">Bootcamp</a> <img src="images/arrow.png" width="10" height="10" /></td> <td class="copyright2"><a class="copyright" title="Matt Cardle Live Shows" href="Live-Shows/">Live Shows</a> <img src="images/arrow.png" width="10" height="10" /></td> </tr> <tr> <td class="copyright2" style="width: 363px"><a class="copyright" title="Matt Cardle Guestbook" href="Guestbook/">Guestbook</a> <img src="images/arrow.png" width="10" height="10" /></td> <td class="copyright2"><a class="copyright" href="Legal/">Privacy Policy</a> <img src="images/arrow.png" width="10" height="10" /></td> </tr> <tr> <td class="copyright2" style="width: 363px"><a class="copyright" title="Matt Cardle Judges Houses" href="Judges-Houses/">Judges Houses</a> <img src="images/arrow.png" width="10" height="10" /></td> <td class="copyright2"><a class="copyright" href="Legal/">Terms and C&#39;s</a> <img src="images/arrow.png" width="10" height="10" /></td> </tr> </table> I've remove a lot of the tabbed white space to make it more readable, but with some fairly simple CSS rules this hog of mark-up could be re-written to (note the etc. comment of course): <ul class="footer_links"> <li class="l"><a title="Matt Cardle Audition 1" href="Audition1/">Audition</a></li> <li class="r"><a title="Matt Cardle Videos" href="Videos/">Videos</a></li> <li class="l"><a title="Matt Cardle Bootcamp" href="Bootcamp/">Bootcamp</a></li> <li class="r"><a title="Matt Cardle Live Shows" href="Live-Shows/">Live Shows</a></li> <!-- etc --> </ul> That kind of rework throughout the code would increase your mark-up : content ratio considerably. From what I can see there's also a lot of empty tables, broken code, deprecated tags, etc, etc. You're also not making use of any header (<h#>) tags, which allow you to add a meaningful header to the page that'll search engines pay a lot of attention to when indexing your content. I can't see any paragraph (<p>) tags used. Links with the text 'read more', which obviously don't describe what you're linking to - 'read more about ...' is much better. There's a lot of room for improvement to be honest.
  16. For this day: select sum(power) from feed where `date` = curdate() For this week: select sum(power) from feed where week(`date`) = week(curdate()) and year(`date`) = year(curdate()); For this month: select sum(power) from feed where month(`date`) = month(curdate()) and year(`date`) = year(curdate()); For this year: select sum(power) from feed where year(`date`) = year(curdate()); I've not got suitable data laying around to test these, but they should work fine. To get the sum for a particular day/week/month/year, not the current, you can just pass the value like this: select sum(power) from feed where month(`date`) = month('2010:01:01') and year(`date`) = year('2010:01:01') Also you'll notice the back ticks (`) around the date field name; that's because 'date' is a reserved word in MySQL, as is 'time', that you should avoid naming tables to prevent any ambiguity.
  17. Which one?
  18. What's so bad about your post getting moved to the right topic? You got an answer regardless.
  19. I've spent most of the day working in vim, a black background, and when I opened your web site my eyes virtually bled out! Even now they've adjusted better it's still a little too bright, but in a way I can't workout whether I like it or not - I certainly won't forget it though. Everything else about it; the imagery, fonts, layout, coding, etc. all seem perfect..
  20. 1) Yes, you should always provide a non-JavaScript alternative. While the vast majority of users will have JS enabled, some people don't, some mobile devices won't support it, some older browsers may not support your code, there may be a JS error else-where that stops the login working, etc. 2) Ignace is saying that you have to assume the user is computer illiterate. While the message may make perfect sense to you, to someone else it could be misleading and/or confusing.
  21. Okay, first of all you don't need to connect and close the connection for each query. You'd be better off taking the connection code and storing within a separate file, so that at the top of any code requiring a connection you can just include it. global "connection.php" file: <?php $con = mysql_connect("localhost","root",""); mysql_select_db("uni", $con) or trigger_error('MySQL error: ' . mysql_error()); ?> code for this file: <?php // include connection require_once 'path/to/connection.php'; $result = mysql_query("SELECT * FROM course") or trigger_error('MySQL error: ' . mysql_error()); // notice below I've used single quotes for strings as it's easier to write HTML echo '<select name ="cid[]" multiple="multiple" size="10">'; while($row = mysql_fetch_array($result)) { // previously you hadn't set the value of the option echo '<option value="' . $row['CourseID'] . '">' . $row['CourseName'] . '</option>'; } echo '</select>'; // ---------------- $result = mysql_query("SELECT * FROM student") or trigger_error('MySQL error: ' . mysql_error()); // you don't want to pass the student ID as an array so remove the block brackets echo '<select name="sid">'; while($row = mysql_fetch_array($result)) { // same problem as before echo '<option value="' . $row['StudentID'] . '">' . $row['StudentName'] . '</option>'; } echo '</select>'; // ---------------- if (!empty($_POST['sid']) && !empty($_POST['cid'])) { $student = mysql_real_escape_string($_POST['sid']); $sql = "INSERT INTO take (StudentID, CourseID) VALUES"; foreach ($_POST['cid'] as $key => $course) { $sql .= ($key != 0) ? ", " : " "; $sql .= "('" . $student . "', '" . mysql_real_escape_string($course) . "')"; } $query = mysql_query($sql) or trigger_error('MySQL error: ' . mysql_error()); if (mysql_affected_rows($query) > 0) { echo mysql_affected_rows($query) . ' rows added.'; } } ?> Tidied up the code and fixed a couple of bugs which I've put comments next to. Unfortunately though it sounds like you're having a server problem, as opposed to the code - although I'm not familiar with that error message. Could you send a screen shot of the error to make things easier? Edit: Of course you'll need a way to submit the form, don't forget.
  22. Hit the nail perfectly on the head there.
  23. This should handle updating the database: if (!empty($_POST['studentID']) && !empty($_POST['courseIDs'])) { $student = mysql_real_escape_string($_POST['studentID']); $sql = "INSERT INTO take (st_id, course_id) VALUES"; foreach ($_POST['courseIDs'] as $key => $course) { $sql .= ($key != 0) ? ", " : " "; $sql .= "('" . $student . "', '" . mysql_real_escape_string($course) . "')"; } $query = mysql_query($sql) or trigger_error('MySQL error: ' . mysql_error()); if (mysql_affected_rows($query) > 0) { echo 'Success'; } } Very rushed as I'm leaving soon. Just remember to add the correct input names ('studentID', 'courseIDs' in my code) to your form. Also for multiple select fields you need to add "[]" to the end of the name (e.g. name="courseIDs[]"), in order to submit the data as an array; otherwise only the last selected option will be sent.
  24. Looks good at first sight.. but could you provide a test user/pass please?
  25. Sorry I'm not sure I follow 100%. The way you've posted these they look like two separate files, yeah? You want to select 1 student and multiple courses, from the same page, then enter the selected data into another table? If so, what table? What's the table structure like?
×
×
  • 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.