Jump to content

klepec

Members
  • Posts

    45
  • Joined

  • Last visited

Posts posted by klepec

  1. I want to display it like this:

     

    Company title:

    Mladi Tehnik d.o.o.

     

    Company branches:

    Stari Tehnik

    Pizzerija 5ka

    Gostilna Kekec

    Blejski Tehnik

     

    Company products:

    Testna 1

    Testna 2

    Mickino Kolo

     

     

    The main issue that im having is the duplicated results. I want every entry to be displayed only once. (Like shown above).

     

    Thanks

  2. Hello guys,

    this is my query with two left joins (tried to join bcompany - main table WITH bpoint and bug):

    SELECT cName, cAddr, sName, uNaslov FROM bcompany c LEFT JOIN bpoint p ON c.companyID = p.companyID LEFT JOIN bug b ON c.companyID = b.cID WHERE c.companyID='$cID';

     

     

    First table bcompany is a main one, and there is always exactly one result row.

    Both tables bpoint and bug relate to bcompany via the companyID column. These two tables will not necessarily have any records.

    Thats why i used left joins, to always get the information of bcompany table no matter if there are any results in other tables or not.

     

     

    My problem are doubled results of those two joined tables. I can understand multiple results for the main table, but not for the joined two.

    How can i get rid of them?

     

    Output:

     

    bcompany:

    Mladi Tehnik d.o.o.

    Mladi Tehnik d.o.o.

    Mladi Tehnik d.o.o.

    Mladi Tehnik d.o.o.

    Mladi Tehnik d.o.o.

    Mladi Tehnik d.o.o.

    Mladi Tehnik d.o.o.

    Mladi Tehnik d.o.o.

    Mladi Tehnik d.o.o.

    Mladi Tehnik d.o.o.

    Mladi Tehnik d.o.o.

    Mladi Tehnik d.o.o.

     

    bpoint:

    Stari Tehnik

    Stari Tehnik

    Stari Tehnik

    Pizzerija 5ka

    Pizzerija 5ka

    Pizzerija 5ka

    Gostilna Kekec

    Gostilna Kekec

    Gostilna Kekec

    Blejski Tehnik

    Blejski Tehnik

    Blejski Tehnik

     

     

    bug:

    Testna 1

    Testna 2

    Mickino kolo

    Testna 1

    Testna 2

    Mickino kolo

    Testna 1

    Testna 2

    Mickino kolo

    Testna 1

    Testna 2

    Mickino kolo

  3. Hello,

    I use same header for all pages, which include user authentication code (login sessions), main menu, logo and login information html.

     

    HEADER:

     

    <?php
    
    .. user authentication
    
    ?>
    
    <head>
    CSS
    JQuery
    </head>
    
    <body>
    <center>
    Logo
    Main menu
    Login information (username, logout itd... / login-regster button when not logged in)

     

    The header is "included" in all the pages.

     

    Now to the question. How to check if pages are public (accessible for non-registered users) or not?

    I usually redirected the non-registered users to login page, but how to handle it when some pages are public and some are not?

    I obviously cant use header since it is page independent.

     

    Thanks

     

  4. Can anyone suggest how to make pagination for search results?

     

    The problem here is that WHERE (search criterias / input fields filled by user) resets every time you go to other page (page1, page2, page3).

     

    Also, there is not always the same number of criterias because empty fields (fields ommited by user) are left out.

     

    Thanks

  5. I have two databases, lets name them database ONE and database TWO.

    Every database record has an id of its author (user). There are no limits for records per user.

     

    I would like to run a statistics page for each user.

     

    For example, when John logs in:

     

    John | 20 of A (list) | 150 of B (list)

    demo code:

     

    $a = mysql_query("SELECT * FROM A WHERE userID='$userID'");
    $b = mysql_query("SELECT * FROM B WHERE userID='$userID'");
    
    $a_num=mysql_num_rows($a);
    $b_num=mysql_num_rows($b);
    
    $echo "$userID | $a_num of A <a href='/a/$userID'>(list)</a> | $b_num of B <a href='/b/$userID'>(list)</a> ";

     

    So, is check for number of records an optimal solution when number of database records come to few hundred or maybe thousand?

    Is there any better way to run statistics? Maybe a separate database which counts records for each user?

     

    Thanks in advance :)

  6. Is there anything wrong if I name html array names (for later php use) like that: name="pic[0]", name="pic[1]", name="pic[2]" instead of just setting all names to: name="pic[]"?

     

    I am using jquery validate plugin so i need unique field names, otherwise only first element with the given name gets validated.

     

    Thanks

  7. Sorry, i forgot to mention, it is a phpmyadmin.

    Database was created in phpmyadmin's SQL command line: CREATE DATABASE something;

     

    I would just like to be able to delete it the same way, but the phpmyadmin does not let me (it says that this command is disabled).

  8. Why cant i drop databases in fresh WAMP 2.2d x64 installation?

     

    When i type DROP DATABASE 'something' -  it says that statement has been disabled.

     

    Is there a way to enable it?

     

    Thanks

  9. <?php
    
    $access = 'admin';
    
    $admin = $access == 'admin' ? ' OR 1' : '';
    
    $query="SELECT esName, esID, esAddress FROM estates WHERE
        (esName LIKE '$req' OR esID LIKE '$req')
        AND userID='$userID'$admin";
    
    echo $query;

     

    This looks good :) Can i ask what "OR 1" does?

  10. I think you will have to explain this a bit more in detail? The solution I see to your question is far too obvious for it to be the solution...

     

    if($access=='admin'){
    
    }

    o.O

     

    Hey,

    Like i said i would like that condition inside mysql query, not writing another query for admins using php if statement.

    The problem here is that i have like 10 different queries for 10 different databases and writing another admin query for each one would be a big mess.

  11. I have a search form. $req is a keyword or an ID number input by user.

    As you can see, query checks only for rows where userID matches the current login userID.

     

    My question is, how to transform (not independent query for admins) the query to search all rows if user $access is admin (no matter the administrator's own userID).

     

    <?php
    
    $userID="something"; (from session)
    $access="something" (from session / user or admin)
    
    $query="SELECT esName, esID, esAddress FROM estates WHERE
        (esName LIKE '$req' OR esID LIKE '$req')
        AND userID='$userID'";
    
    mysql_query($query);
    
    ?>
    

     

    Thanks in advance :)

  12. I have multiple forms within one php file.

     

    What is the best structure to use?

     

    if (isset($_POST["one"])) {
        include...
    }
    if (isset($_POST["two"])) {
        include...
    }
    if (isset($_POST["three"])) {
        include...
    }

     

    OR

     

    if (isset($_POST["one"])) {
        include...
    }
    else if (isset($_POST["two"])) {
        include...
    }
    else if (isset($_POST["three"])) {
        include...
    }

     

     

    thanks

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