Results 1 to 9 of 9

Thread: upload and arranging data

  1. #1
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    921
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default upload and arranging data

    Hey guys,
    I'm looking for a script that can upload data, and show them after chosing certain criterias. F.ex: a visitor types his adress in, and another visitor can find his data by chosing different inputs (by name, city,...).
    Might be done with php, but please note that I am no good at that whatsoever (after looking at this forum, I often feel that I'm no good at any language ...).

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    you would like to do two things here.. 1 upload 2 searchability

    there are tutorials on here about how to upload files / etc into a databse
    having another person able to search is just another query and you can do it any server-side language... I would suggest whatever you are most comfortable / already exists on the site. eg( if your site uses php its not wise to do this in asp or visa versa )

    searching the database for a specific item is really dependant on the criteria you wish to allow them to search but a basic query is soemthing like
    Code:
    SELECT field(s) FROM table WHERE field = 'condition'
    but without more details as to what you wish accomplish all we can give are the generic versions.

  3. #3
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    921
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    What I'd like to find is that I can give his current company and contact data, so that another, by chosing an item, can find my data.

    F.ex.: I am looking for the sales manager of CC, so I look into 'Sales Manager' and 'CC', and then come up with the adress, tel, etc.
    It's like building up a network.

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    to me I would think that this should be spread over a couple of tables, however it all depends on how your database is set up I will do it the way I would do it, and also I will do it as if they were all in 1 table

    Code:
    SELECT c.company_name, che.title, che.work_telephone, e.fname, e.surname, e.address, e.home_telephone FROM Company_has_employees AS che LEFT JOIN employees AS e ON che.employee_id = e.employee_id LEFT JOIN company AS c ON che.company_id = c.company_id WHERE c.company_name = 'CC' AND che.title = 'Sales Manager'"
    now let me brake that down.
    SELECT c.company_name, che.title, che.work_telephone, e.fname, e.surname, e.address, e.home_telephone
    grabs the fields that will be displayed to the user from the appropriate tables
    FROM Company_has_employees AS che LEFT JOIN Employees AS e ON che.employee_id = e.employee_id LEFT JOIN Company AS c ON che.company_id = c.company_id
    uses the reference table Company_has_employees to bridge between the company info and the employee info... this is best for optimization because plugging in a unique id is cuts down on maintanence and provides the ability for 1 person to work for multiple companies / have multiple titles. The joins are based upon the reference table lining them up / pulling them in according to the appropriate unique identity.
    NOTE: Table AS abbreviation is a method of shortening what you need to write... if you did not want to use the abbreviation / do not feel comfortable in how to use it I would suggest that you write out the whole table like
    Code:
    SELECT Company.company_name, Company_has_employees.title, Company_has_employees.work_telephone, Employees.fname, Employees.surname etc...
    WHERE c.company_name = 'CC' AND che.title = 'Sales Manager'"
    this is how the field is widdled down to get a specific result... in your case you want the company CC and the title of Sales Manager.

    this example is assuming the database is structured somewhat like
    TABLE Company_has_employees
    company_id
    employee_id
    title
    work_telephone

    TABLE Company
    company_id
    company_name

    TABLE Employees
    employee_id
    fname
    surname
    address
    home_telephone

    okay that was how I would do it in an optimized database, if all the info is in 1 table the query will be alot smaller but accomplish the same thing
    Code:
    SELECT company_name, title, work_telephone fname, surname, home_telephone, address FROM People WHERE company_name = 'CC' AND title = 'Sales Manager'
    with a database structure like
    TABLE People
    company_name
    fname
    surname
    title
    work_telephone
    address
    home_telephone

    both of them accomplish the same thing but in the first example the database is optimized for redundancy.


    if you give us a better picture of the structure of your database we can help you create a more customized query, however I, we, suggest that you try it out yourself first and bring any questions / errors that you receive.

  5. #5
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    921
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    Wow, thanks so much for your reply, that seems to be very much into details. But I don't understand it, sorry. How exactly would this look like, if you were to place the html code of a page; how would your code be placed in it ? Then I can see how it works, and start playing with it (hopefully).

  6. #6
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    you couldn't use that in a html page. as I said before you would need some sort of server-side programming language. I will use php as an example.
    PHP Code:
    <?php

    $db 
    = array(
         
    'host' => 'localhost',
         
    'username' => 'mysqluser',
         
    'password' => 'mysqlpass',
         
    'dbname' => 'database_name'
    );

    $link mysqli_connect($db['host'], $db['username'], $db['password'], $db['dbname'])
         or die(
    "Error: Trouble connecting to the server");

    if( 
    $link )
    {
         
    $query mysql_query("__my_query__");
         if( !
    $query ) { die("Error: Trouble query cannot execute") }
         else
         {
               while( 
    $row mysql_fetch_assoc($query) )
               {
                      
    doSomething();
               }
         }
    }
    ?>

  7. #7
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    921
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    Thanks a lot. So I upload this file, and then I only need a html file where the choices can be made, like in a contact form, and make the action go to the php-page, right ?
    Where will the data be stored ? And how will they grafically come up ?
    Lots of questions, as I have absolutely no idea how this works ...

  8. #8
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by chechu View Post
    Thanks a lot. So I upload this file, and then I only need a html file where the choices can be made, like in a contact form, and make the action go to the php-page, right ?
    umm I would suggest using a php page from the get go.
    Where will the data be stored ? And how will they grafically come up ?
    that example is how to get data from a mysql database via PHP

    Lots of questions, as I have absolutely no idea how this works ...
    then maybe you should read http://www.php-mysql-tutorial.com/ and if you have any specific questions we can answer those

  9. #9
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    921
    Thanks
    121
    Thanked 2 Times in 2 Posts

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •