Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. The ideal data structure would be like this: $categories = array( 'Bathroom Items' => array( array( 'Item' => 'bath mat', 'Description' => 'bath mat' ), array( 'Item' => 'bath towels', 'Description' => 'bath towels' ), // ... More items ... ), 'Bedroom Items' => array( array( 'Item' => 'pillows', 'Description' => 'pillows' ), array( 'Item' => 'alarm clock', 'Description' => 'alarm clock' ), // ... More items ... ) ); You can generate this structure from your CSV structure like this: $categories = array(); $count = 0; foreach ($CSVArray as $row) { if ($count > 1 && !empty($row[0])) { $category = $row[0]; $item = $row[3]; $description = $row[4]; if(!isset($categories[$category])) { $categories[$category] = array(); } $categories[$category][] = array( 'Item' => $item, 'Description' => $description ); } Once you have that structure you can use it like this: foreach($categories as $name => $data) { echo "<optgroup label='$name'>"; foreach($data as $item) { echo "<option value='{$item['Item']}'>{$item['Item']} ({$item['Description']})</option>"; } echo '</optgroup>'; }
  2. It goes down to the default width and height of block elements. By default, a block element has the full width of it's container and the height of the content within it. You can verify that by taking an unstyled <div> and putting a border on it. You can't get a meaningful percentage value of height when the height you're getting a percentage of depends on the height you're setting the percentage to.
  3. With any element in the document, a percentage height only works if the parent element has an explicit height. Both the <html> and <body> elements should have their height set to 100%. This works: <!DOCTYPE html> <html> <head> <script src="http://maps.googleapis.com/maps/api/js"> </script> <script> function initialize() { var mapProp = { center:new google.maps.LatLng(51.508742,-0.120850), zoom:5, mapTypeId:google.maps.MapTypeId.ROADMAP }; var map=new google.maps.Map(document.getElementById("googleMap"), mapProp); } google.maps.event.addDomListener(window, 'load', initialize); </script> <style> html,body { height: 100%; } </style> </head> <body> <div id="googleMap" style="width:500px;height:100%;"></div> </body> </html>
  4. If the file itself saved as UTF-8? Make sure to do so in your text editor.
  5. You would need to associate the two arrays by their index, so the best way to do that would be an ordinary for loop. $abc = array('Mark','Laura'); $add = array('cocktails','champagne'); $length = count($abc); for($index = 0; $index < $length; $index++) { echo $abc[$index] . ' ' . $add[$index]; echo '<br>'; } But the ideal data structure would be this: $data = array( array( 'name' => 'Mark', 'drink' => 'cocktails' ), array( 'name' => 'Laura', 'drink' => 'champagne' ) ); foreach($data as $row) { echo $row['name'] . ' ' . $row['drink']; echo '<br>'; }
  6. The first one dropdown doesn't work because in the onchange attribute you're not actually calling the function. It should be <select id="mySelect" onchange="myFunction()">
  7. They way to do this is to have global variables and use setInterval. Here's an example: var i = 0; var count = 10; function loop() { if(i < count) { // Do something i++; } } setInterval(loop, 500); In Javascript, the browser stops until a while loop has ended, so you can't use a while loop for timing.
  8. That's completely wrong. HTML 5 is not XHTML.
  9. It happens because you're only changing the color when the checkbox changes. If the checkbox starts off checked no change has occurred, so the program is not checking whether the textarea should be colored or not. The solution is to use both the change event and the load event. Here's an example: var checkbox = document.getElementById('colorsToggle'); var textarea = document.getElementById('textField'); checkbox.onchange = toggle; window.onload = toggle; function toggle() { if(checkbox.checked) { textarea.className = "tan"; } else { textarea.className = ""; } }
  10. Ingolme

    <stype> tag?

    You shouldn't put a <style> tag inside a CSS file because it's an HTML tag, not CSS. Only CSS should go in a CSS file.
  11. You use the <video> tag to embed videos onto the page. You can embed an MP4 file using it. Here's a tutorial page on how to use the <video> tag so that it will work properly on all HTML 5 browsers: http://www.w3schools.com/html/html5_video.asp
  12. You still have a lot to learn. HTML alone can't do that. You need CSS ontop of it at the bare minimum, and then Javascript ontop of that. Just take your time learning HTML and CSS, don't expect to be able to create anything complex until you've mastered it. Every profession requires experience, there is no quick and easy way around that.
  13. Ingolme

    xml

    Without any context, I can't tell you. XML on its own does nothing. Applications read XML and do something with it. If you can tell me which application uses this XML then perhaps I can find out what it does.
  14. I wouldn't rely on orientation media queries, just set media queries for the different possible screen widths that arise from different orientations. Though the better solution would be to make your CSS device independent and not add media queries targeting individual devices.
  15. I put this into your editor and it worked: <script>alert(5)</script> Make sure to wrap your Javascript code in <script> tags.
  16. At the bottom of the page is a link that says "report error". If you click on it you can send a description of the mistake you found on the page you're currently viewing.
  17. People can build their own browsers to bypass any HTML 5 security features.
  18. Ingolme

    SQLSTATE[42000]

    I'd need to see your full SQL query to know what the problem is. It's a syntax error in your SQL.
  19. They both look the same to me. Can you explain what you wanted it to look like?
  20. It's done on the server because the client's device may not implement the proper hashing algorithms. Also, a person could bypass any attempted client-side hashing if it's done with Javascript. If implemented poorly, client-side hashing is hardly different than using plain text passwords, because the listener does not even need to know the original password, they just need to send the result of the hashed string.
  21. Ingolme

    Need help

    What does the code in contact_form.php look like?
  22. No, hashing is not ever done on the client.
  23. I think its because you put a capital "C" on "Change"
  24. I think we're missing context here. It looks like you already managed to add some red text.
  25. The switch statement is not the optimal structure to use in this situation. Why do you want to use it?
×
×
  • Create New...