Jump to content

CroNiX

Staff Alumni
  • Posts

    1,469
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by CroNiX

  1. The problem you were having here:

    $get_available_towns[] = $town;
    
    $get_available_towns = array();

    Is that you add $town to the $get_available_towns array, which is fine, but then you reset the $get_available_towns array to be empty immediately after that so it will never contain anything.

  2. It adds a new element to the end of $get_available_towns array.

    $towns = array('New York', 'Portland', 'Boston');
    
    //Add Chicago to the $towns array
    $towns[] = 'Chicago';

    $towns now equals

    array(
     0 => 'New York',
     1 => 'Portland',
     2 => 'Boston',
     3 => 'Chicago'
    )
  3. Maybe instead of using jQuery's fade(), which cycles through hundreds of transparency levels, make your own "effect" and only use 3 colors of gray going from dark to white. So instead of hundreds of transitions/character or word, it is only cycling through 3 or so. If it's transitioning from word to word fast enough, the illusion would be kind of the same but spare a lot of processing overhead. On my way out the door, but if I think of it later I can play around with it and see if I can come up with something efficient and useful.

  4. I know it would look cool, but that will take a lot of processing to do that and most likely it wouldn't be smooth and would end up being jerky, especially on mobile/slower devices. I've done it for single letters in a word, but not each letter of an entire paragraph, or even worse multiple paragraphs. It would probably be better doing words instead of letters.

  5. Well, that's not valid HTML for your <select> dropdown. each one needs to be it's own option, not separated by <br>.

     

    Each option needs to look like:

    <option value="what gets sent with the form">Text to display in dropdown</option>

     

    So change this:

    while($row = mysqli_fetch_array($result)) {
    echo $row['tankname'];
    echo "<br>";
    }

    to

    while($row = mysqli_fetch_array($result)) {
    
      echo '<option value="' . $row['tankname'] . '">' . $row['tankname'] . '</option>';
    }

    and then remove the

    <option>
    
    </option>

    from the <select> in the HTML so it's just:

    <select id="tankname" type='text' name="tankname">
    <?php include_once '/include/dropdowns/water-parameters-dd.inc.php'; ?>
    </select>
  6. just assign the css selector to .add class, then add the class to #presidentInfo:

     

    example:

     

    1. CSS

    .odd tr:nth-child(odd) {
               background-color: #ccc;
               }
    

    2. All jquery script ( no need extra code )

            <script>
    
                $.getJSON('data.json', function(data) {
                    var output = "<table id='data'><tr><th>First Name:</th><th>Last Name:</th><th>Month of Inauguration:</th><th>Year of Inauguration:</th></tr>";
                    for (var i in data.Presidents) {
                        output += "<tr><td>" + data.Presidents[i].firstName + "</td><td>" + data.Presidents[i].lastName + "</td><td>" + data.Presidents[i].YearInauguratedPresident.month + "</td><td>" + data.Presidents[i].YearInauguratedPresident.year + "</td></tr>";
                    }
    
                    output += "</tr></table>";
                    $('#PresidentInfo').html(output).addClass("odd");
                });
            </script>
    

    @CroNiX, according the docs, this (.ready) function/method will be executed after the DOM is done.

    right, but when the dom is ready his ajax call hasn't fired yet.

  7. Because you first apply the 'odd' class to nothing upon domready (the table isn't created yet), and then retrieve the json and populate the table. Apply the odd class after you retrieve the json/create the table.

     

    also you can write this javascript:

    document.getElementById("PresidentInfo").innerHTML=output;

    with jQuery:

    $('#PresidentInfo').html(output);
  8. Sorry, I've never attempted that. I haven't been able to find an example of a conditional JOIN and from what I read it wasn't possible. Just about all the answers said to use a IF/CASE in the select and a OUTER JOIN on the table.

  9. why do you create so many extra variables that you never reuse? And create variables and then just store them in another variable?

    1. $date = date('dmy');
      $prefix="Temp-";
      $suffix=$date;
      $filename=$prefix.$suffix.".csv"; // Solution
      
      
    $filename = 'Temp-' . date('dmy') . '.csv';
  10. That is MUCH cleaner and very good for the PHP/HTML separation. You really shouldn't use PHP to output HTML like you originally were unless there is no other way. Doing that means PHP actually has to parse it, which takes a bit of extra processing, which takes additional time to do. Also, editors won't be able to typehint/colorize HTML if it's wrapped in PHP tags, as it's considered a PHP string at that point and not an HTML tag.

     

    I just question the < you have in the image tag right before the height="300"

     

    You will also probably want to use a HTML5 doctype and NOT XHTML. Otherwise some code will be invalid as you have written it as you don't close certain tags, like <img />. In XHTML, every HTML tag needs to be terminated.

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