Jump to content

Jessica

Staff Alumni
  • Posts

    8,968
  • Joined

  • Last visited

  • Days Won

    41

Posts posted by Jessica

  1. Well, your complaint is that it's printing all the numbers up to $number_pages. You want it to print up to $num_pages_list.

     

    You also are starting at 1 right now. You say you want to start at the current page.

     

    There are two things to change.

  2. ...

     

    You should only call the login_form() function when your form has been submitted. Not every single page. When the form is submitted, it will go to the file which is designated in the action attribute of the form element. That page should check to see if the form was submitted by seeing if $_POST['submit'] (or whatever you called the button) isset. If isset returns true, attempt to login.

  3. It's a magic function, PHP just knows. It's magic. :-P

     

    I found a tutorial which explained that instantiating a class tells the __autoload which class is an argument.

    .

     

    Like that.

     

     

    And the reason it's better is once you have more than one file to include, you have now reduced your code significantly.

  4. You cannot have two HTML elements of any kind with the same ID. Your HTML looks correct because the selects have different ids. You can try passing each ID to your function, after you re-write the function to accept IDs.

     

    However, to select all select elements, you can use 'select'. Then use jQuery to iterate over them.

  5. Okay, don't even bother trying to do it that way.

     

    Pass the values to the function. Plus, a function shouldn't really echo anything, it should just return the data. You don't need a function to do what you're trying to do, just the foreach() wherever your values are already defined.

     

    Stop using global completely. Forget that word exists.

  6. Why you should have 4 titles?

     

    A table should not have repeating values and columns itself!

     

    Google - "Database optimization" or EXPLAIN your table data here.

    Tiles. Not titles.

     

    OP: Your table that stores the information should have a column (called something like orderBy [but not order because thats reserved]) and you can order them in there, then ORDER BY in your clause. You can look at creating a nice interface for actually ordering them using jQuery's sortable plugin.

  7. echo "<td><a href='hotels-in-sharm-el-sheikh-egypt-with%20roadmaps-maps-locations-and%20landmarks-diving-boat-trips-excursions.php?q=" . $row['name'] . "'>More Information</a></td>";
    It looks fine in our syntax highlighter. Get a better editor.
  8. What does this have to do with regular expressions?

     

     

    I'd suggest using a third-party application for a shopping cart. But if you want to go through the trouble of doing it yourself, you need to learn to code using current best practices. Use PDO or at least mysqli. Don't randomly close and open PHP for no reason. Don't put variables in strings for no reason. You've got a lot to learn.

  9. A. Use Code tags. (The <> button)

     

    B. This is WAY TOO MUCH CODE.

    $week = (strtotime(date('Y-m-d 00:00:00',time())) / 7 * 86400) % 6;
    You're creating the current timestamp, converting it to a string for midnight of this day, then converting that BACK into a timestamp. Then dividing it by 7 and multiplying it by 86400 (So you're trying to get a week's worth of seconds here, you already did some math), then getting the remainder when you divide it by 6. WHY ARE YOU DOING THIS INSANE THING?

     

    You need to go read the documentation for date() because you are using it way wrong. There is a format parameter to get the current week. It will be way more accurate than your method.

     

    C. You also need to read on what modulo does. Any number % 6 can NEVER produce/equal 6.

     

    D. You're repeating the same thing over and over regardless of what week it is. You're doing the opposite of what programming should be - you've made way more work for yourself.

     

    <?php
    $week = (date('W') % 6)+1;
    echo "<b>Woche {$week}</b><br>
    <br>
    Montag Woche {$week}<br />
    Dienstag Woche {$week}<br />
    Mittwoch Woche {$week}<br />
    Donnerstag Woche {$week}<br />
    Freitag Woche {$week}<br />
    Samstag Woche {$week}<br />
    Sonntag Woche {$week}<br />";
    
    Or even:

    $days = array('Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag');
    $week = (date('W') % 6)+1;
    echo "<b>Woche {$week}</b><br><br>";
    foreach($days AS $day){
        echo "{$day} Woche {$week}<br>";
    }
    It depends what you intend to do next really.
  10. In the future, please post just the relevant code here, in code tags.

    You also need to better describe your problem. What "never gets through"? What part of your code is the problem?

     

    Try some debugging by doing a print_r($_POST) before your if(isset()) part, and see just what part isn't set.

    Also use && not and.

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