New to SQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Si Petch

    #1

    New to SQL

    Hi,

    I want to set up a search facility on my website an wonder if MySql is the
    way to do it. Heres the basics of the website:

    A database containing information for a set of villas with details such as:
    villa name; location; number of bedrooms; description; prices etc.... Is it
    possible to include references to pictures in the database and then prouce
    each villas own webpage simply from the information in the table into some
    sort of template?

    Then I hope to have a search form that will allow the user to select a
    location and number of bedrooms and a few other options (all from drop down
    boxes) and by submiting this form it will query the database and return the
    user with matching properties, each of which they can then click for full
    details.

    Any information on how to begin implementing such a system would be greatly
    appreciated, as well as the difficulty of the task.

    Many thanks,

    S Petch


  • Ike

    #2
    Re: New to SQL

    What tools do you have? Can you cobble up pages in php/jsp/asp ? It sounds
    like you dont need to get into a more involved architecture like
    applet-servlet-database......f rom what it says you want, I would use MySQL
    and php to get the job done. -Ike

    "Si Petch" <simon.petch@nt lworld.com> wrote in message
    news:0Vckb.614$ 2r6.475135@news fep1-win.server.ntli .net...[color=blue]
    > Hi,
    >
    > I want to set up a search facility on my website an wonder if MySql is the
    > way to do it. Heres the basics of the website:
    >
    > A database containing information for a set of villas with details such[/color]
    as:[color=blue]
    > villa name; location; number of bedrooms; description; prices etc.... Is[/color]
    it[color=blue]
    > possible to include references to pictures in the database and then prouce
    > each villas own webpage simply from the information in the table into some
    > sort of template?
    >
    > Then I hope to have a search form that will allow the user to select a
    > location and number of bedrooms and a few other options (all from drop[/color]
    down[color=blue]
    > boxes) and by submiting this form it will query the database and return[/color]
    the[color=blue]
    > user with matching properties, each of which they can then click for full
    > details.
    >
    > Any information on how to begin implementing such a system would be[/color]
    greatly[color=blue]
    > appreciated, as well as the difficulty of the task.
    >
    > Many thanks,
    >
    > S Petch
    >
    >[/color]


    Comment

    • Ike

      #3
      Re: New to SQL

      What tools do you have? Can you cobble up pages in php/jsp/asp ? It sounds
      like you dont need to get into a more involved architecture like
      applet-servlet-database......f rom what it says you want, I would use MySQL
      and php to get the job done. -Ike

      "Si Petch" <simon.petch@nt lworld.com> wrote in message
      news:0Vckb.614$ 2r6.475135@news fep1-win.server.ntli .net...[color=blue]
      > Hi,
      >
      > I want to set up a search facility on my website an wonder if MySql is the
      > way to do it. Heres the basics of the website:
      >
      > A database containing information for a set of villas with details such[/color]
      as:[color=blue]
      > villa name; location; number of bedrooms; description; prices etc.... Is[/color]
      it[color=blue]
      > possible to include references to pictures in the database and then prouce
      > each villas own webpage simply from the information in the table into some
      > sort of template?
      >
      > Then I hope to have a search form that will allow the user to select a
      > location and number of bedrooms and a few other options (all from drop[/color]
      down[color=blue]
      > boxes) and by submiting this form it will query the database and return[/color]
      the[color=blue]
      > user with matching properties, each of which they can then click for full
      > details.
      >
      > Any information on how to begin implementing such a system would be[/color]
      greatly[color=blue]
      > appreciated, as well as the difficulty of the task.
      >
      > Many thanks,
      >
      > S Petch
      >
      >[/color]


      Comment

      • Mark Sizer

        #4
        Re: New to SQL

        Si Petch wrote:
        [color=blue]
        > Hi,
        >
        > I want to set up a search facility on my website an wonder if MySql is the
        > way to do it. Heres the basics of the website:
        >
        > A database containing information for a set of villas with details such as:
        > villa name; location; number of bedrooms; description; prices etc.... Is it
        > possible to include references to pictures in the database and then prouce
        > each villas own webpage simply from the information in the table into some
        > sort of template?[/color]

        [snip]

        Doing the pictures is pretty easy from PHP.

        Create a BLOB column of the appropriate size (MEDIUM will probably work
        fine). Have a unique key for the picture (if there's only one picture
        per property, putting the blob in the property table will work fine,
        otherwise have a table that links properties to pictures and use the key
        of the picture table).

        Have PHP generate <img> tags that look like this:
        <img src="getpicture .php?id=27">
        Obviously with the correct id value.

        Write a getpicture.php script that SELECTs the appropriate blob and
        returns it. If you limit yourself to one type of picture (e.g. JPEG),
        this is all you need. If you have multiple picture types (e.g. JPEG,
        GIF, PNG), you'll also have to store the picture's MIME type with the
        picture.

        The getpicture.php script has to set the Content-Type header to the
        appropriate MIME type then just "echo" the blob.

        HTH,
        - Mark

        P.S. It's short so I'll post it. This is my getphoto.php script - I use
        it a lot. The common.php.inc just stuffs all the variable, POST, GET,
        FILE, etc... into the $args array. database.php.in c includes a number of
        handy database function, dbConnect() and echoFatalError( ) among them.

        <?php require('../php/common.php.inc' ); ?>
        <?php require('../php/database.php.in c'); ?>
        <?php
        $db_id = dbConnect("test ");

        if ( $args['id'] )
        {
        $id = $args['id'];
        }
        if ( $args['thumb'] )
        {
        $format = "Thumb";
        }
        else
        {
        $format = "Photo";
        }

        if ( $id == "" )
        exit();

        $sql = "SELECT $format FROM Photos WHERE ID = $id";
        $result = @mysql_query( $sql, $db_id );
        if ( !$result )
        {
        echoFatalError( $sql . " failed: " . mysql_error($db _id) );
        }

        $data = @mysql_result($ result, 0, $format);
        if ( $type == "" )
        {
        $type = "image/jpeg";
        }
        Header("Content-type: $type");
        echo $data;
        ?>


        Comment

        • Mark Sizer

          #5
          Re: New to SQL

          Si Petch wrote:
          [color=blue]
          > Hi,
          >
          > I want to set up a search facility on my website an wonder if MySql is the
          > way to do it. Heres the basics of the website:
          >
          > A database containing information for a set of villas with details such as:
          > villa name; location; number of bedrooms; description; prices etc.... Is it
          > possible to include references to pictures in the database and then prouce
          > each villas own webpage simply from the information in the table into some
          > sort of template?[/color]

          [snip]

          Doing the pictures is pretty easy from PHP.

          Create a BLOB column of the appropriate size (MEDIUM will probably work
          fine). Have a unique key for the picture (if there's only one picture
          per property, putting the blob in the property table will work fine,
          otherwise have a table that links properties to pictures and use the key
          of the picture table).

          Have PHP generate <img> tags that look like this:
          <img src="getpicture .php?id=27">
          Obviously with the correct id value.

          Write a getpicture.php script that SELECTs the appropriate blob and
          returns it. If you limit yourself to one type of picture (e.g. JPEG),
          this is all you need. If you have multiple picture types (e.g. JPEG,
          GIF, PNG), you'll also have to store the picture's MIME type with the
          picture.

          The getpicture.php script has to set the Content-Type header to the
          appropriate MIME type then just "echo" the blob.

          HTH,
          - Mark

          P.S. It's short so I'll post it. This is my getphoto.php script - I use
          it a lot. The common.php.inc just stuffs all the variable, POST, GET,
          FILE, etc... into the $args array. database.php.in c includes a number of
          handy database function, dbConnect() and echoFatalError( ) among them.

          <?php require('../php/common.php.inc' ); ?>
          <?php require('../php/database.php.in c'); ?>
          <?php
          $db_id = dbConnect("test ");

          if ( $args['id'] )
          {
          $id = $args['id'];
          }
          if ( $args['thumb'] )
          {
          $format = "Thumb";
          }
          else
          {
          $format = "Photo";
          }

          if ( $id == "" )
          exit();

          $sql = "SELECT $format FROM Photos WHERE ID = $id";
          $result = @mysql_query( $sql, $db_id );
          if ( !$result )
          {
          echoFatalError( $sql . " failed: " . mysql_error($db _id) );
          }

          $data = @mysql_result($ result, 0, $format);
          if ( $type == "" )
          {
          $type = "image/jpeg";
          }
          Header("Content-type: $type");
          echo $data;
          ?>


          Comment

          Working...