Jump to content

ober

Staff Alumni
  • Posts

    5,327
  • Joined

  • Last visited

Posts posted by ober

  1. Requery the database or pass it via $_SESSION or some other super global array ($_GET, $_POST, etc).

     

    As an example, I have a configuration table in my database where I store all my global settings.  With each load of the page, it queries the database and loads that information to an array so I have it available to me anywhere I go.

  2. No one is going to write it for you... you need to take the first steps:

     

    1) Learn how to connect to a database

    2) Learn how to query the database

    3) Learn basically display and navigation

     

    None of these are simple enough for someone to just throw some code at you (and that wouldn't help you anyways).  You haven't told us anything about the database structure or the data in it.

     

    You've basically just asked a VERY open-ended question.

  3. PDO is meant to be abstract (able to talk to multiple DBMS systems within one protocol) and therefore you're going to lose some of the database specific functionality.  In my opinion, if your application will only ever use MySQL, why would you ever go to an abstract method for communicating with that database?

     

    Performance aside, that should be enough to keep you away from PDO.  PDO is also not as easy to use and any performance gain, if there is one, would be negligible if your application is written correctly and your database is normalized and indexed properly.

  4. Instead of:

    <div id="database">
          <p class="titel"><?php echo $rij['titel']; ?></p>
          <p> U heeft geselecteerd id <?php echo $rij['id']; ?></p>
          <p> Dit is <?php echo $rij['titel']; ?></p>
       </div>

     

    You'll need to run a query before that that pulls the data out of the database again based on the ID:

     

    $id = mysql_real_escape_string($_GET['id]);
    $query = "SELECT * FROM allposts WHERE id = $id"; 

     

    Does that help?  So instead of $rij, your array would be the row you pull from the database based on the ID.

  5. Cron is server side. It cannot execute JS, which is client side. Without cron, you cannot schedule a page to be executed on a specific interval. The only way to do this is with a meta-refresh or a JS timeout, both of which require a browser to be open all the time.

  6. You have to look at whatever is being passed in the URL.  So once you submit, you probably have something like:

     

    www.whatever.com/page.php?req=submit&field1=5&field2=blah

     

    So in your display of the answer options, you just say:

     

    // $current_option would be the value from the row you are entering into the answer options
    $selected = "";
    if($_POST['field2'] == '".$current_option."')
    {
        $selected = " selected";
    }
    
    echo '<option value="'.$row_getType_of_school['school_type_id'].'" '.$selected.'>'.$row_getType_of_school['school_description'].'</option>';
    

  7. You can certainly do that... but I'd recommend using a database instead of text files.  Each thumbnail would then have a value in a record in the database that would contain the link to the full image/gallery or whatever and you build the links dynamically.  Titles and comments and whatnot would just be additional fields or tables in the database.

     

    Now... asking us for a code example of all of that would be a bit much, but if you need something specific, ask away.

     

     

  8. You shouldn't be dumping an entire page to one variable and then echoing that.  Look into output buffering.  That should solve all of your problems.  ob_start() would be a good function that should lead you to the rest of them.

  9. I didn't notice any mention of testing on the magnetic fields to see what the effects on the human body might be.  Transferring that much power across a room has to have some kind of negative effect, or so I would think.

  10. You are passing it a relative path.  You need to provide an absolute path to the fopen command.

    Uh.... since when?

    OK, so it's not an absolute requirement, but it is generally a good idea.  Otherwise PHP has to do the path resolution itself and effectively search for the file in the file structure (read: extra processing time).  The way this is being handled by this user is also somewhat insecure.  I would never pass a path in my file system with a specific file name via URL.  You're also creating a file based on user input.  ALWAYS a bad idea.  And I know you're just creating a blank file at this point, but I can only assume that there will be more to the script about the contents of the file.

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