Jump to content

Omzy

Members
  • Posts

    314
  • Joined

  • Last visited

    Never

Posts posted by Omzy

  1. I've got a localhost Apache server on my Windows machine

     

    I want to be able to create multiple sites under http://localhost, so for example:

     

    http://localhost/site1

    http://localhost/site2

    http://localhost/site3

     

    The problem with this is that relative URLs don't always work, for example if I have a have a common header file (header.php) which contains a reference to a stylesheet (<link rel="stylesheet" type="text/css" href="styles.css" />) and I include() header.php on all pages, it won't work for pages that are in a subfolder of that site, for example: http://localhost/site1/subfolder1/index.php

     

    index.php includes header.php but the stylesheet reference points to the current folder, however styles.css is in the "root" of that site. If I change "styles.css" to "/styles.css" it looks in the root of "localhost" rather than the root of the site.

     

    So is there any way to specify in Apache/PHP what the base path of the site should be? I've tried "RewriteBase" in .htaccess but that doesn't quite work..

  2. Here is my database structure (simplified):

     

    TABLE properties

     

    id (PK, INT, AUTO INC)

    prop_vebraid (INT)

     

    TABLE images

     

    id (PK, INT, AUTO INC)

    image_url (VARCHAR)

    prop_vebraid (INT)

     

    I am using MySQL database with MyISAM format, which is why I don't have any foreign keys in the database.

     

    I want to retrieve images.image_url where images.prop_vebraid = properties.prop_vebraid

     

    But I'm having difficulty doing this. I'm not getting the desired results.

     

    Does anyone have any idea how I can do this and output the image url on each match? images.prop_vebraid is not unique by the way.

     

    I think I need some sort of inner join?

  3. I am running Apache on Windows. My DocumentRoot is:

     

    C:/apache/web sites

     

    The site is at:

     

    C:/apache/web sites/mysite/index.php

     

    In index.php there is a common include file (header.php) with a stylesheet link as follows:

     

    <link rel="stylesheet" type="text/css" href="styles.css" />

     

    So far so good. But I have a directory within "mysite":

     

    C:/apache/web sites/mysite/advertising/index.php

    Again in index.php there is the include file, but obviously the style sheet reference is pointing to the current folder.

     

    I tried changing the path of the stylesheet link to "/styles.css" and "../styles.css" but this obviously will give the root file an invalid path.

     

    How can I satisfy both conditions? Do I have to specify a RewriteBase or something?

  4. Using a framework is exactly what I DON'T want to do.

     

    All I want to do is apply the concepts of MVC to my current applications. These applications are not massive, they are relatively small. A framework comes with far too much baggage and is too much overkill, so I'd rather just code my own functions.

     

    For example my current site is handcoded with PHP and XHTML all in the same file, there is no separation of business logic and presentation logic whatsoever. But the whole site consists of only 16 PHP files in total. I know once I start MVCing my site I will probably end up with 3x more files than I currently have but that's not as bad as implementing a framework which consists of hundreds of files (the majority of which I'll probably never use). I know frameworks do have their advantages and are designed as a "one for all" solution but I'd rather just code exactly what I need to myself!

  5. I'm looking to rewrite all my forms using the MVC concept, I've tried searching Google for help on this but there isn't anything useful/relevant!

     

    So let's suppose I want to create a simple form with fields login and password. These fields also need to be validated. Can someone give me a BASIC idea of how the code should be written, using the MVC concept.

     

    Regards.

  6. It's pretty much straightforward I would have thought?

     

    cart.php is a shopping cart, as the filename would suggest. When the user is happy with the contents of the cart they can hit "Checkout Now" which is a submit button linked to a form which posts the SESSION variables to PayPal. The PayPal screen opens in the same window.

     

    All I want is for the SESSION to be destroyed if the user submits the form. If they don't submit the form then everything stays as it is!

  7. cart.php:

     

    echo '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
    
    foreach($_SESSION as $index => $value)
    {
    echo '<input type="hidden" name="'.$index.'" value="'.$value.'" />';
    }
    
    echo '<input type="submit" value="Checkout Now" /></form>';
    

     

    I want the $_SESSION to be emptied/destroyed once the form has been submitted.

  8. I have a form which captures customer's details, such as Name, Address, Date of Birth, etc, and then displays them back to the user (and sends me an email with the details) upon submission, as follows:

     

    foreach($_POST as $key => $value)
    {
    echo "$key : $value";
    }
    

     

    This works fine for me, but I have now split up the Date of Birth field into 3 seperate fields - Day, Month, Year. But I still want it to be output as one field (Date of Birth) at the end.

     

    Because I'm outputting $_POST this is proving to be difficult. Can anyone help?

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