Jump to content

Search the Community

Showing results for tags 'query'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

  1. Tauheed

    MySQL query help

    I don't have MySQL experience, I need some help to write a query for my work. I need a query that count transaction for a week, for example, I wanna run the query every Friday and want to see the result from last Friday to Thursday, I mean just last week's data. The start date is last Friday (11/12/2021) and the End date is Thursday (11/18/2021). It is a weekly process that I can run every week to download the output. There are two tables, sales, and customers. The customer table has fields such as "customer_id", FirstName, LastName, etc and the sales table has "id" which is the same as customer_id from customer table, salesDate, etc. I want to count data of those who are customer_id match to the sales table. I would like to ignore some of the users as well like our IT team has a couple of test users that uses for testing. for example testuser1 and testuser2. I would like the query to not count these two users. Here is an example that I want to make work. Can someone please help me to write the query? SELECT COUNT(CustomerID) AS NumberOfCustomer FROM Customer INNER JOIN Sales ON ID = CustomerID where user != (testuser1 and testuser2 where sales date between last Friday to Thursday; Thanks!
  2. Hi, I've got a table with waypoints in my db (called points), these waypoints combine to a route due to the the timestamp in the start and stop column. Now I would like to change the date and/or date + hour to use the track on a different date or start at a differnt hour. But i also would like to keep the intervals between the records. ID Name Lat Lon Start Stop 526 Waypoint X 52.14722000 6.39720000 2020-03-30 20:37:32.0 2020-03-30 20:47:32.0 527 Waypoint Y 52.14670000 6.39139000 2020-03-30 20:47:32.0 2020-03-30 20:52:32.0 528 Waypoint Z 52.14248000 6.39125000 2020-03-30 20:52:32.0 2020-03-30 20:57:32.0 529 Waypoint X 52.14722000 6.39720000 2020-03-30 20:57:32.0 2020-03-30 21:02:32.0 530 Waypoint Y 52.14670000 6.39139000 2020-03-30 21:02:32.0 2020-03-30 21:07:32.0 531 Waypoint Z 52.14248000 6.39125000 2020-03-30 21:07:32.0 2020-03-30 21:12:32.0 532 Waypoint X 52.14722000 6.39720000 2020-03-30 21:12:32.0 2020-03-30 21:17:32.0 533 Waypoint Y 52.14670000 6.39139000 2020-03-30 21:17:32.0 2020-03-30 21:22:32.0 534 Waypoint Z 52.14248000 6.39125000 2020-03-30 21:22:32.0 2020-03-30 21:27:32.0 535 Waypoint X 52.14722000 6.39720000 2020-03-30 21:27:32.0 2020-03-30 21:32:32.0 536 Waypoint Y 52.14670000 6.39139000 2020-03-30 21:32:32.0 2020-03-30 21:37:32.0 Is it possible to use an update querey to change only a part of a datetime stamp? See the colored examples shown below. 2020-03-30 20:37:32.0 2020-03-30 20:37:32.0 Thanks in advance for your help. Arjan
  3. Hiral

    Help in SQL query

    Hello Everyone, I am writing a query in SQL to pull the first date an employee became a teacher with no break in service. using the job table here to find effective date when a employee became teacher like example. 1. Teacher - 1/1/18. 2. coordinator- 2/1/18 3. Teacher- 3/1/18 Here in result I need the last entry as there is no gap in that title now.
  4. Hi, the error log says that the executing document has an unexpected quotation mark in line 32, however - the lines following the http 500 error from the php error_log - come from crypto_methods.php and are printed below... (all sensitive information has been replaced with *****) [05-Feb-2019 19:20:58 UTC] PHP Parse error: syntax error, unexpected '"' in /home/*****/public_html/crypto_methods.php on line 32 31. foreach ($ciphers as $key => $value) { 32. $sql = "INSERT INTO crypto (crypto_no, crypto_descr) VALUES (" . $key . ", /"" . $value . "/");"; 33. $result = $conn->query($sql); 34. }
  5. Hello W3S - me again... So i have this little peace of code: if( isset($_POST['FORMNAME_submit_search']) ) { $qur = ""; @$SearchKeywords = mysqli_real_escape_string($dblink, $_POST['FORMNAME_SogProfilBar_Keywords']); // Search Bar Profil Keywords @$MinAlder = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MinAlder']); // Minimum Alder @$MaxAlder = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MaxAlder']); // Maximum Alder @$Landsdel = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Landsdel']); // Landsdel @$Kon = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Kon']); // KĆøn @$MinHojde = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MinHojde']); // Minimum HĆøjde @$MaxHojde = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MaxHojde']); // Maximum HĆøjde @$Etnicitet = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Etnicitet']); // Etnicitet @$Sprog = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Sprog']); // Sprog @$MinVaegt = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MinVaegt']); // Minimum VƦgt @$MaxVaegt = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MaxVaegt']); // Maximum VƦgt @$Tatoveringer = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Tatoveringer']); // Tatoveringer @$Kategorier = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Kategorier']); // Kategorier // SĆøgning af ALT starter her. $query = " SELECT users.users_id, any_value(users.users_fornavn), any_value(users.users_mellemnavn), any_value(users.users_efternavn), any_value(users.users_email), any_value(users.users_city), any_value(users.users_zipcode), any_value(users.users_birthday_date), any_value(users.users_address), any_value(users.users_tlf_telefon), any_value(users.users_tlf_mobil), users_info.usersinfo_FK_users_id, any_value(users_info.usersinfo_id), any_value(users_info.usersinfo_profilesearch_viewable), any_value(users_info.usersinfo_hojde_cm), any_value(users_info.usersinfo_vaegt_kg), any_value(users_info.usersinfo_ErfaringKvalifikationer), any_value(users_info.usersinfo_beskaeftigelse), any_value(users_info.usersinfo_FK_usersinfoHairColor_id), any_value(users_info.usersinfo_FK_usersinfoEyeColor_id), any_value(users_info.usersinfo_FK_usersinfoBukseBredde_id), any_value(users_info.usersinfo_FK_usersinfoBukseLaengde_id), any_value(users_info.usersinfo_FK_usersinfoBluseStorrelse_id), any_value(users_info.usersinfo_FK_usersinfoSkoStorrelse_id), any_value(users_info.usersinfo_FK_usersinfoLandsdel_id), any_value(users_info.usersinfo_FK_usersinfoEtnicitet_id), any_value(users_info.usersinfo_FK_usersinfoTatoveringer_id), any_value(users_info.usersinfo_FK_usersinfoKategorier_id), any_value(users_info.usersinfo_FK_usersinfoSprog_id) FROM users INNER JOIN users_info ON users.users_id = users_info.usersinfo_FK_users_id "; // Search patterns - needs editing! from old-original to my version so it fits! include_once("index.search_patterns_setup.php"); // fortsƦtter herunder $query .= " GROUP BY users_id, usersinfo_FK_users_id"; $result = mysqli_query($dblink, $query) or die(mysqli_error($dblink)); if( mysqli_num_rows($result) > 0 ) { while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { //echo '<p>her er jeg!</p>'; // indsƦt sĆøge resultater her! (DET ING VIIIIRKER!) $output = '<p>'.$query.'</p>'; echo $output; echo '<p>'.$row['users_fornavn'].'</p>'; } } else { $row = '<p>Der var desvƦrre ingen resultater pĆ„ din sĆøgning. PrĆøv igen.</p>'; echo $row; $output = '<p>'.$query.'</p>'; echo $output; die(); } } else { include_once("index.no_search_show_cards_profiles.php"); } The small code above is the main file. This code here is where i check for patterns and what has been checked in the form for searching etc... /////////////////////////// ALDER /////////////////////////// if( $MinAlder > 0 ) { echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; // dob = Date Of Birth $time = new DateTime('now'); $newtime = $time->modify('-'.$MinAlder.' year')->format('Y-m-d'); $query .= $clause." users_birthday_date <= '$newtime' "; } if( $MaxAlder > 0 ) { //echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; // dob = Date Of Birth $time = new DateTime('now'); $newtime = $time->modify('-'.$MaxAlder.' year')->format('Y-m-d'); $query .= $clause." users_birthday_date >= '$newtime' "; } /////////////////////////// KƘN /////////////////////////// if( !empty($Kon) ) { echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersGender_id = '$Kon' "; } /////////////////////////// LANDSDEL /////////////////////////// if( !empty($Landsdel) ) { echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoLandsdel_id = '$Landsdel' "; } /////////////////////////// ETNICITET /////////////////////////// if( !empty($Etnicitet) ) { echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoEtnicitet_id = '$Etnicitet' "; } /////////////////////////// TATOVERINGER /////////////////////////// if( !empty($Tatoveringer) ) { // nĆ„r jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoTatoveringer_id = '$Tatoveringer' "; } /////////////////////////// SPROG /////////////////////////// if( !empty($Sprog) ) { // nĆ„r jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoSprog_id = '$Sprog' "; } /////////////////////////// KATEGORIER /////////////////////////// if( !empty($Kategorier) ) { // nĆ„r jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoKategorier_id = '$Kategorier' "; } /////////////////////////// VƆGT /////////////////////////// if( $MinVaegt>0 && $MaxVaegt<1 ) { $reg_vaegt_max="999"; } if( $MaxVaegt>0 && $MinVaegt<1 ) { $reg_vaegt_min="1"; } if( $MinVaegt>0 || $MinVaegt>0 ) { // nĆ„r jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause."userinfo_vaegt_kg BETWEEN $MinVaegt AND $MaxVaegt "; $clause = " OR "; } /////////////////////////// HƘJDE /////////////////////////// if( $MinHojde>0 && $MaxHojde<1 ) { $reg_hoejde_max="999"; } if( $MaxHojde>0 && $MinHojde<1 ) { $reg_hoejde_min="1"; } if( $MinHojde>0 || $MinHojde>0 ) { // nĆ„r jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause."usersinfo_hojde_cm BETWEEN $MinHojde AND $MaxHojde "; $clause = " OR "; } /////////////////////////// KEYWORDS /////////////////////////// //if keyword set, goes here if( !$SearchKeywords=="" ) { echo clauseCHECK_AND(); // Initial clause //echo "<p>".clauseCHECK_AND()."</p>"; // Initial clause // search query $c = " users_id LIKE '%$SearchKeywords%' OR users_fornavn LIKE '%$SearchKeywords%' OR users_mellemnavn LIKE '%$SearchKeywords%' OR users_efternavn LIKE '%$SearchKeywords%' "; $query .= $clause." $c"; } Now, i have a little trouble with the latest version of MySQL installed, i always keep getting the error: Expression #12 of SELECT list is not in GROUP BY clause and contains nonaggregated column (...) which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by So i had to change my main SQL a little, which is why i added "any_value()" to my main sql as a temporary solution, and seems to work, only whenever i get an output, i cannot actually row out any output Oo? Whenever i try to output say "users_fornavn", which is Danish for first name... i get index undefined error... any ideas? I can only assume it it the sql that has the error? Hope you guys can help out a little. PS: Note that the "any_value()" part, was only supposed to be a temporary solution for a customer that want's the website up and running somewhere by next week, so i thought to add the any_value() sql function for now and at a later point be more specific about the code. I just need the rough ways for now so i am able to change that at a later point. Thanks in advance! Really hope you peepz can help me out!
  6. Hello W3S! So i have some problems again, hoping you can help me clear it out. I am currently trying to make a search page where a user can search for profiles with different profiles information such as tattoos, height, etc. And i have some difficulties making it work, hoping you can spot some sort of errors that i cannot. Please note that it's been a while since i've been making a fully working searcher with php and sql, so sorry for the messed up code, if so hehe Okay. So i have 6 files, follows as such: 1. index.php (being the main file) - (LOCATION: ROOT/FILE_HERE.php), 2. PAGE_searchprofiles.php (being where the search coding begins AND output is coming) - (LOCATION: ROOT/include/files/www-files/FILE_HERE.php), 3. functions.pagination.class.php (being my pagination class, used on file PAGE_searchprofiles.php) - (LOCATION: ROOT/FILE_HERE.php), 4. functions.php (my php functions into 1 file) - location is root 5. index.search_patterns_setup.php (being used on file PAGE_searchprofiles.php, being where i use if/else statements to compile a proper sql) - location root 6. index.no_search_show_cards_profiles.php (being used on file PAGE_searchprofiles.php, showing ALL profiles if no search has been done so far.) - location root ------------------------------------------- okay, those are file names and locations. the idea is that when there is a search, the searched profiles should be shown, else, show all files. I got that part working perfectly, but now comes the actual search query where i get a little lost (i think). And please take note that this is a search query from a past coder, doing this for a company and this coder has done some terrible coding... i think... i have a hard time seeing what he has done and not. At some places he has done a quite good job, but the search part, not so much. So, i will share the code below here for ALL files, and after that coding, i will write about the problem at hand again. -------------------------------------- index.php <?php ob_start(); session_start(); define("DEFINED_FILE:DEFINES_1", TRUE); require_once("include/files/www-files/random_uncategorized_useful_files/defines.php"); // Defines require_once("include/files/www-files/random_uncategorized_useful_files/report_methods.php"); // Reportings require_once("database/connection.php"); DB_open_main_connection(); // $dblink ?> <!DOCTYPE html> <html lang="da"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Release 1 - Version 1</title> <!-- Bootstrap V.4.0.0 CSS files --> <link rel="stylesheet" href="include/css/bootstrap.min.css" /> <!-- My Custom CSS Files --> <link rel="stylesheet" href="include/css/global_custom_css_design.css" /> <link rel="stylesheet" href="include/css/5.css" /> <link rel="stylesheet" href="include/css/navigation_menu_5.css" /> <!-- other css files --> <link rel="stylesheet" href="include/css/fontawesome-all.min.css"> <!-- Jquery (necessary for Bootstrap's JavaScript plugins) and Bootstrap V.4.0.0 JS Script files --> <script src="include/js/jquery-3.2.1.js"></script> <script src="include/js/bootstrap.min.js"></script> <script src="include/js/bootstrap.bundle.js"></script> <script src="include/js/5.js"></script> </head> <body> <?php # Require Navigation Menu require_once("include/files/www-files/nav-menu.php"); # Including PAGE_signup1.php include_once("include/files/www-files/PAGE_searchprofiles.php"); ?> <div class="mt-3"></div> <?php # Require Footer require_once("include/files/www-files/footer.php"); // close connection $dblink->close(); // MAIN Connection ?> </body> </html> PAGE_searchprofiles.php <?php require_once("functions.php"); //////////////////////////////////////////////////////////////////////////////////////////////////// // Notes //////////////////////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------------------ // comma separeret DB output for ALLE checkboxes (Tatovering & Kategori - vi bruger explode!) //------------------------------------------------------------------------------------------------ /* I DB (users_info) laver jeg en "text" for bĆ„de kategori og tatovering checkboxes da jeg skal bruge string til comma (sĆ„dan forstĆ„r jeg det!). Jeg indsƦtter komma sepereret tal, og bruger php funktionen explode til at sepererer tallene. Jeg bruger senere tallene til at "selecte" ud fra ID hos diverse tabeller, senere hen vise diverse som er blevet vist/valgt/osv. */ //////////////////////////////////////////////////////////////////////////////////////////////////// // Lists //////////////////////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------------------ // FORM - names //------------------------------------------------------------------------------------------------ // my notes: maybe add "multiple" to the select? Style it to be a normale dropdown... look into alternatives! // FORMNAME_SogProfilBar_Keywords (SĆøg Profil Bar) // FORMNAME_MinAlder (Alder :: Minimum) // FORMNAME_MaxAlder (Alder :: Maximum) // FORMNAME_Landsdel (Landsdel "SelectOption") // FORMNAME_Kon (KĆøn "SelectOption") // FORMNAME_MinHojde (HĆøjde :: Minimum) // FORMNAME_MaxHojde (HĆøjde :: Maximum) // FORMNAME_Etnicitet (Etnicitet "SelectOption") // FORMNAME_Sprog (Sprog "SelectOption") // FORMNAME_MinVaegt (VƦgt :: Minimum) // FORMNAME_MaxVaegt (VƦgt :: Maximum) // FORMNAME_Tatoveringer (Tatoveringer "SelectOption") // FORMNAME_Kategorier (Kategorier "SelectOption") // FORMNAME_submit_search (SĆøg "Submit Button") //------------------------------------------------------------------------------------------------ // Queries - already being used //------------------------------------------------------------------------------------------------ // $query_1 (selecting all data from DB-Table users_info) // $query_2 (Landsdel -> SelectOption) // $query_3 (KĆøn -> SelectOption) // $query_4 (Etnicitet -> SelectOption) // $query_5 (Sprog -> SelectOption) // $query_6 (Tatoveringer -> SelectOption) // $query_7 (Kategori -> SelectOption) // $query_100 (outputting all cards/profiles to the "profiles" area) //------------------------------------------------------------------------------------------------ // Queries //------------------------------------------------------------------------------------------------ $query_1 = "SELECT * FROM users_info"; $result_1 = mysqli_query($dblink, $query_1) or die ( mysqli_error($dblink) ); $row_1 = mysqli_fetch_array($result_1); ?> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <br /> <h1 class="text-muted text-center">SĆøg Profiler</h1> </div> </div> </div> <div class="container"> <form method="post" action="index.php"> <div class="row mb-3"> <!-- SĆøg Profil Bar --> <div class="input-group"> <input type="text" class="form-control" placeholder="SĆøg Profil" name="FORMNAME_SogProfilBar_Keywords"> <div class="input-group-append"> <button type="submit" class="btn btn-outline-secondary" name="FORMNAME_submit_search">SĆøg</button> <button type="button" class="btn btn-outline-secondary JQUERY_ACTION_expand_search">Udvid SĆøgning</button> </div> </div> </div><!-- //.row --> <div class="row"> <div class="container"> <div class="row"> <!-- Min.Alder --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">Min.Alder</span> <span class="input-group-text">ƅR</span> </div> <input type="number" class="form-control" placeholder="Min.Alder" min="0" name="FORMNAME_MinAlder"> </div> </div> <!-- Max.Alder --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">Max.Alder</span> <span class="input-group-text">ƅR</span> </div> <input type="number" class="form-control" placeholder="Max.Alder" min="0" name="FORMNAME_MaxAlder"> </div> </div> <!-- Landsdel --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <label class="input-group-text" for="inputGroupSelect_LANDSDEL">Landsdel</label> </div> <select class="custom-select" id="inputGroupSelect_LANDSDEL" name="FORMNAME_Landsdel"> <option selected disabled hidden>Landsdel</option> <?php $query_2 = "SELECT * FROM users_info_landsdel"; $result_2 = mysqli_query($dblink, $query_2) or die ( mysqli_error($dblink) ); while( $row_2 = mysqli_fetch_array($result_2) ) { $selected = ($row_2['usersinfoLandsdel_id'] == $row_1['usersinfo_FK_usersinfoLandsdel_id']) ? 'selected="selected"' : ''; echo '<option value="'.$row_2['usersinfoLandsdel_id'].'" '.$selected.'>'.$row_2['usersinfoLandsdel_name'].'</option>'; } ?> </select> </div> </div> <!-- KĆøn --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <label class="input-group-text" for="inputGroupSelect_KƘN">KĆøn</label> </div> <select class="custom-select" id="inputGroupSelect_KƘN" name="FORMNAME_Kon"> <option selected disabled hidden>KĆøn</option> <?php $query_3 = "SELECT * FROM users_gender"; $result_3 = mysqli_query($dblink, $query_3) or die ( mysqli_error($dblink) ); while( $row_3 = mysqli_fetch_array($result_3) ) { $selected = ($row_3['usersGender_id'] == $row_1['users_FK_usersGender_id']) ? 'selected="selected"' : ''; echo '<option value="'.$row_3['usersGender_id'].'" '.$selected.'>'.$row_3['usersGender_name'].'</option>'; } ?> </select> </div> </div> </div><!-- //.row --> </div><!-- //.container --> </div><!-- //.row --> <div class="row" style="display: none;"> <div class="container mt-3 mb-3"> <div class="row mb-3"> <div class="col-md-3"> &nbsp; </div> <div class="col-md-3"> &nbsp; </div> <div class="col-md-3"> &nbsp; </div> <div class="col-md-3"> <button type="button" class="btn JQUERY_ACTION_minimize_search">Minimer SĆøgning</button> </div> </div><!-- //.row --> <div class="row mb-3"> <!-- Min.HĆøjde --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">Min.HĆøjde</span> <span class="input-group-text">CM</span> </div> <input type="number" class="form-control" placeholder="Min.HĆøjde" min="0" name="FORMNAME_MinHojde"> </div> </div> <!-- Max.HĆøjde --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">Max.HĆøjde</span> <span class="input-group-text">CM</span> </div> <input type="number" class="form-control" placeholder="Max.HĆøjde" min="0" name="FORMNAME_MaxHojde"> </div> </div> <!-- Etnicitet --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <label class="input-group-text" for="inputGroupSelect_ETNICITET">Etnicitet</label> </div> <select class="custom-select" id="inputGroupSelect_ETNICITET" name="FORMNAME_Etnicitet"> <option selected disabled hidden>Etnicitet</option> <?php $query_4 = "SELECT * FROM users_gender"; $result_4 = mysqli_query($dblink, $query_4) or die ( mysqli_error($dblink) ); while( $row_4 = mysqli_fetch_array($result_4) ) { $selected = ($row_4['usersinfoEtnicitet_id'] == $row_1['usersinfo_FK_usersinfoEtnicitet_id']) ? 'selected="selected"' : ''; echo '<option value="'.$row_4['usersinfoEtnicitet_id'].'" '.$selected.'>'.$row_4['usersinfoEtnicitet_name'].'</option>'; } ?> </select> </div> </div> <!-- Sprog --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <label class="input-group-text" for="inputGroupSelect_SPROG">Sprog</label> </div> <select class="custom-select" id="inputGroupSelect_SPROG" name="FORMNAME_Sprog"> <option selected disabled hidden>Sprog</option> <?php $query_5 = "SELECT * FROM users_info_sprog"; $result_5 = mysqli_query($dblink, $query_5) or die ( mysqli_error($dblink) ); while( $row_5 = mysqli_fetch_array($result_5) ) { $selected = ($row_5['usersinfoSprog_id'] == $row_1['usersinfo_FK_usersinfoSprog_id']) ? 'selected="selected"' : ''; echo '<option value="'.$row_5['usersinfoSprog_id'].'" '.$selected.'>'.$row_5['usersinfoSprog_name'].'</option>'; } ?> </select> </div> </div> </div><!-- //.row --> <div class="row"> <!-- Min.VƦgt --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">Min.VƦgt</span> <span class="input-group-text">KG</span> </div> <input type="number" class="form-control" placeholder="Min.VƦgt" min="0" name="FORMNAME_MinVaegt"> </div> </div> <!-- Max.VƦgt --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">Max.VƦgt</span> <span class="input-group-text">KG</span> </div> <input type="number" class="form-control" placeholder="Max.VƦgt" min="0" name="FORMNAME_MaxVaegt"> </div> </div> <!-- Tatoveringer --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <label class="input-group-text" for="inputGroupSelect_TATOVERINGER">Tatoveringer</label> </div> <select class="custom-select" id="inputGroupSelect_TATOVERINGER" name="FORMNAME_Tatoveringer"> <option selected disabled hidden>Tatoveringer</option> <?php $query_6 = "SELECT * FROM users_info_tatoveringer"; $result_6 = mysqli_query($dblink, $query_6) or die ( mysqli_error($dblink) ); while( $row_6 = mysqli_fetch_array($result_6) ) { $selected = ($row_6['usersinfoTatoveringer_id'] == $row_1['usersinfo_FK_usersinfoTatoveringer_id']) ? 'selected="selected"' : ''; echo '<option value="'.$row_6['usersinfoTatoveringer_id'].'" '.$selected.'>'.$row_6['usersinfoTatoveringer_name'].'</option>'; } ?> </select> </div> </div> <!-- Kategorier --> <div class="col-md-3"> <?php //include_once("include/files/www-files/form_parts/searchprofiles_multiselect/multiselect_kategori.php"); ?> <div class="input-group"> <div class="input-group-prepend"> <label class="input-group-text" for="inputGroupSelect_KATEGORI">Kategorier</label> </div> <select class="custom-select" id="inputGroupSelect_KATEGORI" name="FORMNAME_Kategorier"> <option selected disabled hidden>Kategorier</option> <?php $query_7 = "SELECT * FROM users_info_kategorier"; $result_7 = mysqli_query($dblink, $query_7) or die ( mysqli_error($dblink) ); while( $row_7 = mysqli_fetch_array($result_7) ) { $selected = ($row_7['usersinfoKategorier_id'] == $row_1['usersinfo_FK_usersinfoKategorier_id']) ? 'selected="selected"' : ''; echo '<option value="'.$row_7['usersinfoKategorier_id'].'" '.$selected.'>'.$row_7['usersinfoKategorier_name'].'</option>'; } ?> </select> </div> </div> </div><!-- //.row --> </div><!-- //.container --> </div><!-- //.row (udvidet sĆøgning) --> </form> </div> <div class="mt-3"></div> <div class="container"> <?php if( isset($_POST['FORMNAME_submit_search']) ) { //include_once("functions.pagination.class.php"); // include pagination $qur = ""; @$SearchKeywords = mysqli_real_escape_string($dblink, $_POST['FORMNAME_SogProfilBar_Keywords']); // Search Bar Profil Keywords @$MinAlder = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MinAlder']); // Minimum Alder @$MaxAlder = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MaxAlder']); // Maximum Alder @$Landsdel = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Landsdel']); // Landsdel @$Kon = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Kon']); // KĆøn @$MinHojde = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MinHojde']); // Minimum HĆøjde @$MaxHojde = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MaxHojde']); // Maximum HĆøjde @$Etnicitet = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Etnicitet']); // Etnicitet @$Sprog = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Sprog']); // Sprog @$MinVaegt = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MinVaegt']); // Minimum VƦgt @$MaxVaegt = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MaxVaegt']); // Maximum VƦgt @$Tatoveringer = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Tatoveringer']); // Tatoveringer @$Kategorier = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Kategorier']); // Kategorier // SĆøgning af ALT starter her. $query = "SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION'"; $result = mysqli_query($dblink, $query) or die(mysqli_error($dblink)); $query = htmlentities(" SELECT DISTINCT users_id, users_fornavn, users_mellemnavn, users_efternavn, users_email, users_city, users_zipcode, users_birthday_date, users_address, users_tlf_telefon, users_tlf_mobil, usersinfo_profilesearch_viewable, usersinfo_hojde_cm, usersinfo_vaegt_kg, usersinfo_ErfaringKvalifikationer, usersinfo_beskaeftigelse, usersinfo_FK_usersinfoHairColor_id, usersinfo_FK_usersinfoEyeColor_id, usersinfo_FK_usersinfoBukseBredde_id, usersinfo_FK_usersinfoBukseLaengde_id, usersinfo_FK_usersinfoBluseStorrelse_id, usersinfo_FK_usersinfoSkoStorrelse_id, usersinfo_FK_usersinfoLandsdel_id, usersinfo_FK_usersinfoEtnicitet_id, usersinfo_FK_usersinfoTatoveringer_id, usersinfo_FK_usersinfoKategorier_id, usersinfo_FK_usersinfoSprog_id, usersGender_id, usersGender_name, usersinfoLandsdel_id, usersinfoLandsdel_name, usersinfoEtnicitet_id, usersinfoEtnicitet_name, usersinfoTatoveringer_id, usersinfoTatoveringer_name, usersinfoSprog_id, usersinfoSprog_name, usersinfoKategorier_id, usersinfoKategorier_name FROM users INNER JOIN users_info ON users.users_id = users_info.usersinfo_FK_users_id INNER JOIN users_gender ON users.users_FK_usersGender_id = users_gender.usersGender_id INNER JOIN users_info_landsdel ON users_info.usersinfo_FK_usersinfoLandsdel_id = users_info_landsdel.usersinfoLandsdel_id INNER JOIN users_info_etnicitet ON users_info.usersinfo_FK_usersinfoEtnicitet_id = users_info_etnicitet.usersinfoEtnicitet_id INNER JOIN users_info_tatoveringer ON users_info.usersinfo_FK_usersinfoTatoveringer_id = users_info_tatoveringer.usersinfoTatoveringer_id INNER JOIN users_info_sprog ON users_info.usersinfo_FK_usersinfoSprog_id = users_info_sprog.usersinfoSprog_id INNER JOIN users_info_kategorier ON users_info.usersinfo_FK_usersinfoKategorier_id = users_info_kategorier.usersinfoKategorier_id "); // Search patterns - needs editing! from old-original to my version so it fits! include_once("index.search_patterns_setup.php"); // fortsƦtter herunder $query .= " GROUP BY users_id, usersinfo_FK_users_id"; $result = mysqli_query($dblink, $query) or die(mysqli_error($dblink)); // hvis der ikke er EN rƦkke i udtrƦkket, vises en fejlbesked (??? pĆ„ search eller ???) //$searchCount=mysqli_num_rows($result); // BehĆøver jeg denne del (???) // OG START Pƅ "<?PHP ?\>" - HTML KOMMER HER IFƘLGE TIDLIGERE KODE! (tror jeg skipper den del!) if( mysqli_num_rows($result) > 0 ) { while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<p>her er jeg!</p>'; // indsƦt sĆøge resultater her! } } else { $row = '<p>Der var desvƦrre ingen resultater pĆ„ din sĆøgning. PrĆøv igen.</p>'; echo '<h3>'.$row.'</h3>'; die(); } } else { //include_once("functions.pagination.class.php"); // include pagination include_once("index.no_search_show_cards_profiles.php"); } ?> </div> <script> $('.JQUERY_ACTION_expand_search').on('click', function () { $(this).parent().parent().parent().next().next().show(1000); }); $('.JQUERY_ACTION_minimize_search').on('click', function () { $(this).parent().parent().parent().parent().hide(1000); }); </script> functions.pagination.class.php <?php class pagination { /* Properties array @var array @access private */ private $_properties = array(); /* Default configurations @var array @access public */ public $_defaults = array( 'page' => 1, 'perPage' => 10 ); /* Constructor @param array $array Array of results to be paginated @param int $curPage The current page interger that should used @param int $perPage The amount of items that should be show per page @return void @access public */ public function __construct($array, $curPage = null, $perPage = null) { $this->array = $array; $this->curPage = ($curPage == null ? $this->defaults['page'] : $curPage); $this->perPage = ($perPage == null ? $this->defaults['perPage'] : $perPage); } /* Global setter Utilises the properties array @param string $name The name of the property to set @param string $value The value that the property is assigned @return void @access public */ public function __set($name, $value) { $this->_properties[$name] = $value; } /* Global getter Takes a param from the properties array if it exists @param string $name The name of the property to get @return mixed Either the property from the internal properties array or false if isn't set @access public */ public function __get($name) { if (array_key_exists($name, $this->_properties)) { return $this->_properties[$name]; } return false; } /* Set the show first and last configuration This will enable the "<< first" and "last >>" style links @param boolean $showFirstAndLast True to show, false to hide. @return void @access public */ public function setShowFirstAndLast($showFirstAndLast) { $this->_showFirstAndLast = $showFirstAndLast; } /* Set the main seperator character By default this will implode an empty string @param string $mainSeperator The seperator between the page numbers @return void @access public */ public function setMainSeperator($mainSeperator) { $this->mainSeperator = $mainSeperator; } /* Get the result portion from the provided array @return array Reduced array with correct calculated offset @access public */ public function getResults() { // Assign the page variable if (empty($this->curPage) !== false) { $this->page = $this->curPage; // using the get method } else { $this->page = 1; // if we don't have a page number then assume we are on the first page } // Take the length of the array $this->length = count($this->array); // Get the number of pages $this->pages = ceil($this->length / $this->perPage); // Calculate the starting point $this->start = ceil(($this->page - 1) * $this->perPage); // return the portion of results return array_slice($this->array, $this->start, $this->perPage); } /* Get the html links for the generated page offset @param array $params A list of parameters (probably get/post) to pass around with each request @return mixed Return description (if any)... @access public */ public function getLinks($params = array()) { // Initiate the links array $plinks = array(); $links = array(); $slinks = array(); // Concatenate the get variables to add to the page numbering string $queryUrl = ''; if (!empty($params) === true ) { unset($params['page']); $queryUrl = '&amp;'.http_build_query($params); } // If we have more then one pages if (($this->pages) > 1) { // Assign the 'previous page' link into the array if we are not on the first page if ($this->page != 1) { if ($this->_showFirstAndLast) { $plinks[] = ' <a href="?page=1'.$queryUrl.'">&laquo;&laquo; First </a> '; } $plinks[] = ' <a href="?page='.($this->page - 1).$queryUrl.'">&laquo; Prev</a> '; } // Assign all the page numbers & links to the array for ($j = 1; $j < ($this->pages + 1); $j++) { if ($this->page == $j) { $links[] = ' <a class="selected">'.$j.'</a> '; // If we are on the same page as the current item } else { $links[] = ' <a href="?page='.$j.$queryUrl.'">'.$j.'</a> '; // add the link to the array } } // Assign the 'next page' if we are not on the last page if ($this->page < $this->pages) { $slinks[] = ' <a href="?page='.($this->page + 1).$queryUrl.'"> Next &raquo; </a> '; if ($this->_showFirstAndLast) { $slinks[] = ' <a href="?page='.($this->pages).$queryUrl.'"> Last &raquo;&raquo; </a> '; } } // Push the array into a string using any some glue return implode(' ', $plinks).implode($this->mainSeperator, $links).implode(' ', $slinks); } return; } } functions.php <?php // clause CHECK AND function // function clauseCHECK_AND () { global $clause; if( isset($clause) ) { $clause = " AND "; //echo "CLAUSE ER WHERE:"; } else { $clause = " WHERE "; } } // clause CHECK OR function // function clauseCHECK_OR () { global $clause; if( isset($clause) ) { $clause = " OR "; //echo "CLAUSE ER WHERE:"; } else { $clause = " WHERE "; } } ?> index.no_search_show_cards_profiles.php <div class="container"> <div class="card-columns"> <?php $query_100 = "SELECT * FROM users ORDER BY users_id DESC"; $result_100 = mysqli_query($dblink, $query_100) or die(mysqli_error($dblink)); if( mysqli_num_rows($result_100) > 0 ) { if( mysqli_num_rows($result_100) > 0 ) { while( $row_100 = mysqli_fetch_array($result_100) ) { $user_id = $row_100['users_id']; $user_fornavn = $row_100['users_fornavn']; $dateOfBirth = $row_100['users_birthday_date']; // output: Y-m-d (Year-Month-Day) $today = date("Y-m-d"); // current date today $diff = date_diff(date_create($dateOfBirth), date_create($today)); // difference between the two dates ?> <div class="card"> <a href="#" title="Profil"> <img class="card-img-top img-responsive img-rounded" src="https://dummyimage.com/250x330/000/fff.jpg" alt="Billede"> </a> <div class="card-body"> <h5 class="card-title"><b><?php echo $user_fornavn.',&nbsp;'.$diff->format('%y'); ?></b></h5> <p class="card-text">#<?php echo $user_id; ?></p> </div><!-- //.card-body --> </div><!-- //.card --> <?php } } } else { echo 'Intet at vise lige nu.'; } ?> </div> </div> index.search_patterns_setup.php <?php /////////////////////////// ALDER /////////////////////////// // ORIGINAL /* if( $minAlder > 0 ) { $time = new DateTime('now'); $newtime = $time->modify('-'.$minAlder.' year')->format('Y-m-d'); //echo $newtime; echo clauseCHECK(); $query .= $clause." user_dob <= '$newtime' "; //$clause .= " OR ";//Change to OR after 1st WHERE } if( $maxAlder > 0 ) { echo clauseCHECK(); $time = new DateTime('now'); $newtime = $time->modify('-'.$maxAlder.' year')->format('Y-m-d'); //echo $newtime; $query .= $clause." user_dob >= '$newtime' "; //$clause .= " OR ";//Change to OR after 1st WHERE } */ // MY VERSION if( $MinAlder > 0 ) { //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; // dob = Date Of Birth $time = new DateTime('now'); $newtime = $time->modify('-'.$MinAlder.' year')->format('Y-m-d'); $query .= $clause." users_birthday_date <= '$newtime' "; } if( $MaxAlder > 0 ) { //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; // dob = Date Of Birth $time = new DateTime('now'); $newtime = $time->modify('-'.$MaxAlder.' year')->format('Y-m-d'); $query .= $clause." users_birthday_date >= '$newtime' "; } /////////////////////////// KƘN /////////////////////////// // ORIGINAL /* if( !empty($reg_koen) ) { echo clauseCHECK(); $query .= $clause." user_koen = '$reg_koen' "; //$clause .= " OR ";//Change to OR after 1st WHERE } */ // MY VERSION if( !empty($Kon) ) { //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersGender_id = '$Kon' "; } /////////////////////////// LANDSDEL /////////////////////////// // ORIGINAL /* if( !empty($reg_Landsdel) ) { echo clauseCHECK(); $query .= $clause." user_landsdel = '$reg_Landsdel' "; //$clause .= " OR ";//Change to OR after 1st WHERE } */ // MY VERSION if( !empty($Landsdel) ) { //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoLandsdel_id = '$Landsdel' "; } /////////////////////////// ETNICITET /////////////////////////// // ORIGINAL /* if( !empty($reg_etnic) ) { echo clauseCHECK(); $query .= $clause." user_etnicitet = '$reg_etnic' "; //$clause .= " OR ";//Change to OR after 1st WHERE } */ // MY VERSION if( !empty($Etnicitet) ) { //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoEtnicitet_id = '$Etnicitet' "; } /////////////////////////// TATOVERINGER /////////////////////////// // ORIGINAL /* if( !empty($_POST['check_listTat']) ) { // Loop to store and display values of individual checked checkbox. foreach($_POST['check_listTat'] as $c) { if( !empty($c) ) { echo clauseCHECKor(); $qur = "userPers_fk_tat_id"; $query .= $clause."".$qur." LIKE '%{$c}%'"; //$clause = " OR ";//Change to OR after 1st WHERE } } } */ // MY VERSION if( !empty($Tatoveringer) ) { // nĆ„r jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoTatoveringer_id = '$Tatoveringer' "; } /////////////////////////// SPROG /////////////////////////// // ORIGINAL /* if( !empty($_POST['check_listSprog']) ) { // Loop to store and display values of individual checked checkbox. foreach($_POST['check_listSprog'] as $c) { if( !empty($c) ) { echo clauseCHECKor(); $qur = "userPers_fk_sprog_id"; $query .= $clause."".$qur." LIKE '%{$c}%'"; $clause = " OR "; //Change to OR after 1st WHERE } } //echo $query;//Remove after testing } */ // MY VERSION if( !empty($Sprog) ) { // nĆ„r jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoSprog_id = '$Sprog' "; } /////////////////////////// KATEGORIER /////////////////////////// // ORIGINAL /* if( !empty($_POST['check_listKat']) ) { // Loop to store and display values of individual checked checkbox. // Loop to store and display values of individual checked checkbox. foreach($_POST['check_listKat'] as $c) { if( !empty($c) ) { echo clauseCHECKor(); $qur = "userPers_fk_kat_id"; $query .= $clause."".$qur." LIKE '%{$c}%'"; $clause = " OR ";//Change to OR after 1st WHERE } } } */ // MY VERSION if( !empty($Kategorier) ) { // nĆ„r jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoKategorier_id = '$Kategorier' "; } /////////////////////////// VƆGT /////////////////////////// // ORIGINAL /* if( $reg_vaegt_min>0 && $reg_vaegt_max<1 ) { $reg_vaegt_max="999"; } if( $reg_vaegt_max>0 && $reg_vaegt_min<1 ) { $reg_vaegt_min="1"; } if( $reg_vaegt_min>0 || $reg_vaegt_min>0 ) { echo clauseCHECK(); //echo "<br><hr><br>HER er vƦgt.<br><br>"; $query .= $clause."user_vaegt BETWEEN $reg_vaegt_min AND $reg_vaegt_max "; $clause = " OR "; } */ // MY VERSION if( $MinVaegt>0 && $MaxVaegt<1 ) { $reg_vaegt_max="999"; } if( $MaxVaegt>0 && $MinVaegt<1 ) { $reg_vaegt_min="1"; } if( $MinVaegt>0 || $MinVaegt>0 ) { // nĆ„r jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause."userinfo_vaegt_kg BETWEEN $MinVaegt AND $MaxVaegt "; $clause = " OR "; } /////////////////////////// HƘJDE /////////////////////////// // ORIGINAL /* if( $reg_hoejde_min>0 && $reg_hoejde_max<1 ) { $reg_hoejde_max="999"; } if( $reg_hoejde_max>0 && $reg_hoejde_min<1 ) { $reg_hoejde_min="1"; } if( $reg_hoejde_min>0 || $reg_hoejde_min>0 ) { echo clauseCHECK(); //echo "<br><hr><br>HER er vƦgt.<br><br>"; $query .= $clause."user_hoejde BETWEEN $reg_hoejde_min AND $reg_hoejde_max "; $clause = " OR "; } */ // MY VERSION if( $MinHojde>0 && $MaxHojde<1 ) { $reg_hoejde_max="999"; } if( $MaxHojde>0 && $MinHojde<1 ) { $reg_hoejde_min="1"; } if( $MinHojde>0 || $MinHojde>0 ) { // nĆ„r jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause."usersinfo_hojde_cm BETWEEN $MinHojde AND $MaxHojde "; $clause = " OR "; } /////////////////////////// KEYWORDS /////////////////////////// // ORIGINAL /* //if keyword set, goes here if( !$keyword=="" ) { echo clauseCHECK();//Initial clause $c=" user_unikID LIKE '%$keyword%' OR user_fornavn LIKE '%$keyword%' OR user_efternavn LIKE '%$keyword%' OR user_faerdigheder LIKE '%$keyword%' OR user_etnicitet LIKE '%$keyword%' OR user_haarfarve LIKE '%$keyword%' OR user_haartype LIKE '%$keyword%' OR user_ojenfarve LIKE '%$keyword%' "; $query .= $clause." $c"; } */ // MY VERSION //if keyword set, goes here if( !$SearchKeywords=="" ) { //echo clauseCHECK_AND(); // Initial clause echo "<p>".clauseCHECK_AND()."</p>"; // Initial clause // unikID = old wwww-files :: ROOT/call/reg_sessioncall.php :: line ~290+ (cirka) // search query /* $c = " user_unikID LIKE '%$SearchKeywords%' OR users_fornavn LIKE '%$SearchKeywords%' OR users_mellemnavn LIKE '%$SearchKeywords%' OR users_efternavn LIKE '%$SearchKeywords%' OR users_faerdigheder LIKE '%$SearchKeywords%' OR user_etnicitet LIKE '%$SearchKeywords%' OR user_haarfarve LIKE '%$SearchKeywords%' OR user_haartype LIKE '%$SearchKeywords%' OR user_ojenfarve LIKE '%$SearchKeywords%' "; */ $c = " user_unikID LIKE '%$SearchKeywords%' OR users_fornavn LIKE '%$SearchKeywords%' OR users_mellemnavn LIKE '%$SearchKeywords%' OR users_efternavn LIKE '%$SearchKeywords%' "; $query .= $clause." $c"; } ?> ----------------------------------------------------------------- Okay, as you might have guessed, the code is a little long. (yay). Okay, so i have "tried" to clean up the past coding the best i could, BUT, here is where i get lost a bit. In the main query on PAGE_searchprofiles.php - am i supposed to make a lot of inner joins? I did that one myself, but wonna make sure BECAUSE! I have a LOT of tables and rows in the DB. I have a main table, users, where basic info is like firstname, etc. Then i have another called users_info, having a lot of integers with 1ns and zeros... those numbers are supposed to go to another table, for each table with Foreign Keys (FK), containing names, etc of forms and so on. I thought it would be better this way for the select at the time, and it was, but also worse for the search query because i have no idea if i am doing that part correct. Also with the file (index.search_patterns_setup.php) - not sure if i do the if/else's correct, since i just reused the old coders parameters and just changed the variables and queries to my database and variable names so they would look perfectly, and they do, only not sure if it's working or not :/ Mostly because whenever i make a search, nothing comes out, no errors either, just no rows. Not sure if i pinpoint the whole thing at different ways with id's etc with inner joins at the main query and the parameters if/else's statements. This is my current DB (query a little bit, but if you can check it out, go for it, just remember, it is in Danish some of it and some in English... combined the 2 languages for some text hehe): -- phpMyAdmin SQL Dump -- version 4.7.0 -- https://www.phpmyadmin.net/ -- -- Host: localhost -- Generation Time: Mar 10, 2018 at 10:35 AM -- Server version: 5.7.18 -- PHP Version: 7.1.5 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `u1d4zzx` -- -- -------------------------------------------------------- -- -- Table structure for table `carousel1` -- CREATE TABLE `carousel1` ( `carousel1_id` int(11) NOT NULL, `carousel1_img_url` text NOT NULL, `carousel1_title` text NOT NULL, `carousel1_description` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `carousel1` -- INSERT INTO `carousel1` (`carousel1_id`, `carousel1_img_url`, `carousel1_title`, `carousel1_description`) VALUES (1, '1.PNG', 'No Title 1', 'No Description 1'), (2, '2.jpg', 'No Title 2', 'No Description 2'), (3, '3.jpg', 'No Title 3', 'No Description 3'), (4, '4.jpeg', 'No Title 4', 'No Description 4'); -- -------------------------------------------------------- -- -- Table structure for table `page_work1_videos` -- CREATE TABLE `page_work1_videos` ( `pw1videos_id` int(11) NOT NULL, `pw1videos_link` text NOT NULL, `pw1videos_director` text NOT NULL, `pw1videos_title` text NOT NULL, `pw1videos_text` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `page_work1_videos` -- INSERT INTO `page_work1_videos` (`pw1videos_id`, `pw1videos_link`, `pw1videos_director`, `pw1videos_title`, `pw1videos_text`) VALUES (6, 'DxiOVmuZyw4', 'Simon Bonde', 'Tuborg Classic', 'All Cast'), (7, 'BDhC7DU0yYE', ' ', 'Hi-Fi Klubben', 'Extras'), (8, 'nN1GLigSw40', 'Jannik Vestmar', 'Krifa', 'All Cast'), (9, 'wBC1WWO9AUc', 'Stevan Treshow', 'Oddset', 'All Cast'), (10, 'FH5cw-n00T8', 'Stevan Treshow', 'Oddset', 'All Cast'), (11, 'L7D1G8vgkEQ', 'Stevan Treshow', 'Oddset', 'All Cast'), (12, '_kASjW_aPbQ', 'Nadia Marquard', 'Emelie SandƃĀ© Wonder', 'Cast & Extras'), (14, '0rbA2qBDn8A', ' ', 'Ikano Bank', 'Cast '), (15, 'NYndyqp1gDU', ' ', 'Just Eat', 'All Cast'), (16, 't9diF_GKImA', ' ', 'Just Eat', 'All Cast'), (17, 'zvK8WL43kdY', 'Jonas Elmer', 'Betsafe', 'Cast '), (18, '0bPWGoTRFc0', 'Michael Langhoff', 'Ƙresundsbroen', 'Extras'), (19, 'MBcU7VCh_MM', 'Michael Langhoff', 'Ƙresundsbroen', 'Extras'), (20, '_m_KUK6QFS0', 'Michael Langhoff', 'Ƙresundsbroen', 'Extras'), (21, 'p7QrsVAEwIU', 'Michael Langhoff', 'Ƙresundsbroen', 'Extras'), (23, 'hmdlCmLrD8A', 'Simon Bonde & Michael Spooner', 'Ladbrokes', 'Cast & Extras'), (29, 'TjHSXd0CcNI', 'Fredrik Callinggard', 'Ofir', 'All Cast'), (30, 'CfAyPqhbeCM', 'Mats Stenberg', 'Casino.dk', 'Ekstra'), (31, 'Aml0d-e6czg', 'Michael Langhoff', 'DayDose', 'Extras'), (32, '5AdMpkKrlDE', '', 'Unibet ', 'Extras'), (33, 'jY-PZ4tMwXU', '', 'Unibet', 'Extras'), (38, '7Cd3UbueGzM', 'Fredrik Callinggard', 'Ofir', 'All Cast'), (42, 'R3JqzsNuer8', 'Gaute Hesthagen ', 'Telenor', 'All Cast'), (46, 'mmHpWlTZEk4', 'Gaute Hesthagen ', 'Telenor', 'All Cast'), (47, 'W3p0yzLc_js', 'Gaute Hesthagen ', 'Telenor', 'All Cast'), (49, '8IIGUBV-jqo', ' ', 'Mobilepay', 'All Cast'), (50, 'MQ_uMGxRvH8', '', 'Bygma', 'Extras'); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `users_id` int(11) NOT NULL, `users_ActiveState` int(11) NOT NULL DEFAULT '0', `users_fornavn` varchar(255) NOT NULL, `users_mellemnavn` varchar(255) NOT NULL, `users_efternavn` varchar(255) NOT NULL, `users_email` text NOT NULL, `users_password` text NOT NULL, `users_FK_usersGender_id` int(11) NOT NULL DEFAULT '0', `users_city` varchar(255) NOT NULL, `users_zipcode` int(11) NOT NULL, `users_birthday_date` date DEFAULT NULL, `users_address` text NOT NULL, `users_tlf_telefon` int(11) NOT NULL DEFAULT '0', `users_tlf_mobil` int(11) NOT NULL DEFAULT '0', `users_FK_usersSubscription_id` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users` -- INSERT INTO `users` (`users_id`, `users_ActiveState`, `users_fornavn`, `users_mellemnavn`, `users_efternavn`, `users_email`, `users_password`, `users_FK_usersGender_id`, `users_city`, `users_zipcode`, `users_birthday_date`, `users_address`, `users_tlf_telefon`, `users_tlf_mobil`, `users_FK_usersSubscription_id`) VALUES (2, 1, 'd', 'd', 'd', 'd@yahoo.co.uk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 2, 'FREDERIKSBERG C', 1851, '1992-11-08', 'Nyvej 16, 2TV', 44444444, 44444444, 3), (3, 0, 'dwjioj', 'odj', 'woidjo', 'derp@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 2, 'd C', 1851, '1992-11-08', 'diwjdo, 2TV', 44444444, 44444444, 2), (4, 0, 'Danie', ' ', 'Pedersen', 'd@yahoo.com', '4c65f054573c27e35eefcdd5d6b31091516827fa', 2, 'd C', 1851, '1992-11-08', ' ', 44444444, 44444444, 1), (5, 0, 'Uglen', ' ', 'Elsker', 'demo1@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 1, 'd C', 6666, '1992-11-08', ' ', 44444444, 44444444, 1), (6, 0, 'Ugleerne', ' ', 'Elskerne', 'demo2@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 1, 'd C', 6666, '1992-11-08', ' ', 44444444, 44444444, 1), (7, 0, 'derpy', ' ', 'derp', 'demo3@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 1, 'd C', 2000, '1992-11-08', ' ', 44444444, 51444379, 3), (8, 0, 'wdwe', '', 'dwad', 'demo4@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 1, 'd C', 5151, '2018-12-31', '', 51444379, 44444444, 1), (9, 0, 'wdwe', '', 'dwad', 'demo5@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 1, 'd C', 5151, '2018-12-31', '', 44444444, 51444379, 1), (10, 0, 'Karsten', '', 'Larsen', 'demo7@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 2, 'd C', 1851, '1992-11-08', '', 51444379, 44444444, 1); -- -------------------------------------------------------- -- -- Table structure for table `users_files` -- CREATE TABLE `users_files` ( `usersFiles_id` int(11) NOT NULL, `usersFiles_FK_users_id` int(11) NOT NULL DEFAULT '0', `usersFiles_avatar_1` text NOT NULL, `usersFiles_image_1` text NOT NULL, `usersFiles_image_2` text NOT NULL, `usersFiles_image_3` text NOT NULL, `usersFiles_image_4` text NOT NULL, `usersFiles_image_5` text NOT NULL, `usersFiles_image_6` text NOT NULL, `usersFiles_image_7` text NOT NULL, `usersFiles_image_8` text NOT NULL, `usersFiles_image_9` text NOT NULL, `usersFiles_image_10` text NOT NULL, `usersFiles_video_1` text NOT NULL, `usersFiles_video_2` text NOT NULL, `usersFiles_video_3` text NOT NULL, `usersFiles_video_4` text NOT NULL, `usersFiles_video_5` text NOT NULL, `usersFiles_video_6` text NOT NULL, `usersFiles_video_7` text NOT NULL, `usersFiles_video_8` text NOT NULL, `usersFiles_video_9` text NOT NULL, `usersFiles_video_10` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_files` -- INSERT INTO `users_files` (`usersFiles_id`, `usersFiles_FK_users_id`, `usersFiles_avatar_1`, `usersFiles_image_1`, `usersFiles_image_2`, `usersFiles_image_3`, `usersFiles_image_4`, `usersFiles_image_5`, `usersFiles_image_6`, `usersFiles_image_7`, `usersFiles_image_8`, `usersFiles_image_9`, `usersFiles_image_10`, `usersFiles_video_1`, `usersFiles_video_2`, `usersFiles_video_3`, `usersFiles_video_4`, `usersFiles_video_5`, `usersFiles_video_6`, `usersFiles_video_7`, `usersFiles_video_8`, `usersFiles_video_9`, `usersFiles_video_10`) VALUES (1, 2, '9e711fd22a826bf711a2f748692cf781.jpg', '', '', '', '', '', '', '', '', '', '16b72540e572da3f3ab5753e6034ab2d--rubber-catsuit-fetish-fashion.jpg', '', '', '', '', '', '', '', 'C3322_B_1.jpg', '', ''), (2, 10, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); -- -------------------------------------------------------- -- -- Table structure for table `users_gender` -- CREATE TABLE `users_gender` ( `usersGender_id` int(11) NOT NULL, `usersGender_name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_gender` -- INSERT INTO `users_gender` (`usersGender_id`, `usersGender_name`) VALUES (1, 'Andet'), (2, 'Mand'), (3, 'Kvinde'); -- -------------------------------------------------------- -- -- Table structure for table `users_info` -- CREATE TABLE `users_info` ( `usersinfo_id` int(11) NOT NULL, `usersinfo_FK_users_id` int(11) NOT NULL DEFAULT '0', `usersinfo_hojde_cm` int(11) NOT NULL DEFAULT '0', `usersinfo_vaegt_kg` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoHairColor_id` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoEyeColor_id` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoBukseBredde_id` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoBukseLaengde_id` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoBluseStorrelse_id` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoSkoStorrelse_id` int(11) NOT NULL DEFAULT '0', `usersinfo_ErfaringKvalifikationer` text NOT NULL, `usersinfo_beskaeftigelse` text NOT NULL, `usersinfo_profilesearch_viewable` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoTatoveringer_id` varchar(255) NOT NULL, `usersinfo_FK_usersinfoKategorier_id` varchar(255) NOT NULL, `usersinfo_FK_usersinfoSprog_id` varchar(255) NOT NULL, `usersinfo_FK_usersinfoLandsdel_id` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoEtnicitet_id` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info` -- INSERT INTO `users_info` (`usersinfo_id`, `usersinfo_FK_users_id`, `usersinfo_hojde_cm`, `usersinfo_vaegt_kg`, `usersinfo_FK_usersinfoHairColor_id`, `usersinfo_FK_usersinfoEyeColor_id`, `usersinfo_FK_usersinfoBukseBredde_id`, `usersinfo_FK_usersinfoBukseLaengde_id`, `usersinfo_FK_usersinfoBluseStorrelse_id`, `usersinfo_FK_usersinfoSkoStorrelse_id`, `usersinfo_ErfaringKvalifikationer`, `usersinfo_beskaeftigelse`, `usersinfo_profilesearch_viewable`, `usersinfo_FK_usersinfoTatoveringer_id`, `usersinfo_FK_usersinfoKategorier_id`, `usersinfo_FK_usersinfoSprog_id`, `usersinfo_FK_usersinfoLandsdel_id`, `usersinfo_FK_usersinfoEtnicitet_id`) VALUES (1, 2, 176, 130, 4, 1, 14, 21, 6, 29, ' Info tekst mangler. ', ' Info tekst mangler. ', 0, '', '', '', 0, 0); -- -------------------------------------------------------- -- -- Table structure for table `users_info_bluse_storrelse` -- CREATE TABLE `users_info_bluse_storrelse` ( `usersinfoBluseStorrelse_id` int(11) NOT NULL, `usersinfoBluseStorrelse_storrelse` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_bluse_storrelse` -- INSERT INTO `users_info_bluse_storrelse` (`usersinfoBluseStorrelse_id`, `usersinfoBluseStorrelse_storrelse`) VALUES (1, 'X-Small'), (2, 'Small'), (3, 'Medium'), (4, 'Large'), (5, 'X-Large'), (6, 'XX-Large'), (7, 'XXX-Large'); -- -------------------------------------------------------- -- -- Table structure for table `users_info_bukse_bredde` -- CREATE TABLE `users_info_bukse_bredde` ( `usersinfoBukseBredde_id` int(11) NOT NULL, `usersinfoBukseBredde_bredde` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_bukse_bredde` -- INSERT INTO `users_info_bukse_bredde` (`usersinfoBukseBredde_id`, `usersinfoBukseBredde_bredde`) VALUES (1, 24), (2, 25), (3, 26), (4, 27), (5, 28), (6, 29), (7, 30), (8, 31), (9, 32), (10, 33), (11, 34), (12, 35), (13, 36), (14, 37), (15, 38), (16, 39), (17, 40), (18, 41), (19, 42), (20, 43), (21, 44), (22, 45); -- -------------------------------------------------------- -- -- Table structure for table `users_info_bukse_laengde` -- CREATE TABLE `users_info_bukse_laengde` ( `usersinfoBukseLaengde_id` int(11) NOT NULL, `usersinfoBukseLaengde_laengde` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_bukse_laengde` -- INSERT INTO `users_info_bukse_laengde` (`usersinfoBukseLaengde_id`, `usersinfoBukseLaengde_laengde`) VALUES (1, 24), (2, 25), (3, 26), (4, 27), (5, 28), (6, 29), (7, 30), (8, 31), (9, 32), (10, 33), (11, 34), (12, 35), (13, 36), (14, 37), (15, 38), (16, 39), (17, 40), (18, 41), (19, 42), (20, 43), (21, 44), (22, 45), (23, 46), (24, 47), (25, 48); -- -------------------------------------------------------- -- -- Table structure for table `users_info_etnicitet` -- CREATE TABLE `users_info_etnicitet` ( `usersinfoEtnicitet_id` int(11) NOT NULL, `usersinfoEtnicitet_name` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Table structure for table `users_info_eye_color` -- CREATE TABLE `users_info_eye_color` ( `usersinfoEyeColor_id` int(11) NOT NULL, `usersinfoEyeColor_name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_eye_color` -- INSERT INTO `users_info_eye_color` (`usersinfoEyeColor_id`, `usersinfoEyeColor_name`) VALUES (1, 'BlĆ„'), (2, 'GrĆønne'), (3, 'Brune'), (4, 'GrĆ„'); -- -------------------------------------------------------- -- -- Table structure for table `users_info_hair_color` -- CREATE TABLE `users_info_hair_color` ( `usersinfoHairColor_id` int(11) NOT NULL, `usersinfoHairColor_color` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_hair_color` -- INSERT INTO `users_info_hair_color` (`usersinfoHairColor_id`, `usersinfoHairColor_color`) VALUES (1, 'Hvidt'), (2, 'Platinblond'), (3, 'Lysblond'), (4, 'Mellemblond'), (5, 'MĆørkeblond'), (6, 'RĆødblond'), (7, 'RĆød'), (8, 'Lysebrunt'), (9, 'Brunt'), (10, 'MĆørkebrunt'), (11, 'Sort'), (12, 'GrĆ„t'), (13, 'GrĆ„ stƦnk'), (14, 'Anden'); -- -------------------------------------------------------- -- -- Table structure for table `users_info_kategorier` -- CREATE TABLE `users_info_kategorier` ( `usersinfoKategorier_id` int(11) NOT NULL, `usersinfoKategorier_name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_kategorier` -- INSERT INTO `users_info_kategorier` (`usersinfoKategorier_id`, `usersinfoKategorier_name`) VALUES (1, 'Uddannet skuespiller'), (2, 'Autodidakt skuespiller'), (3, 'Ingen erfaring (indenfor film, reklamer, TV)'), (4, 'Statist'), (5, 'Sanger'), (6, 'Danser'), (7, 'Tvilling'), (8, 'Mor til bĆørn'), (9, 'Far til bĆørn'); -- -------------------------------------------------------- -- -- Table structure for table `users_info_landsdel` -- CREATE TABLE `users_info_landsdel` ( `usersinfoLandsdel_id` int(11) NOT NULL, `usersinfoLandsdel_name` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_landsdel` -- INSERT INTO `users_info_landsdel` (`usersinfoLandsdel_id`, `usersinfoLandsdel_name`) VALUES (1, 'SjƦlland'), (2, 'Jylland'), (3, 'Odense'), (4, 'Bornholm'); -- -------------------------------------------------------- -- -- Table structure for table `users_info_sko_storrelse` -- CREATE TABLE `users_info_sko_storrelse` ( `usersinfoSkoStorrelse_id` int(11) NOT NULL, `usersinfoSkoStorrelse_storrelse` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_sko_storrelse` -- INSERT INTO `users_info_sko_storrelse` (`usersinfoSkoStorrelse_id`, `usersinfoSkoStorrelse_storrelse`) VALUES (1, 17), (2, 18), (3, 19), (4, 20), (5, 21), (6, 22), (7, 23), (8, 24), (9, 25), (10, 26), (11, 27), (12, 28), (13, 29), (14, 30), (15, 31), (16, 32), (17, 33), (18, 34), (19, 35), (20, 36), (21, 37), (22, 38), (23, 39), (24, 40), (25, 41), (26, 42), (27, 43), (28, 44), (29, 45), (30, 46), (31, 47), (32, 48), (33, 49), (34, 50); -- -------------------------------------------------------- -- -- Table structure for table `users_info_sprog` -- CREATE TABLE `users_info_sprog` ( `usersinfoSprog_id` int(11) NOT NULL, `usersinfoSprog_name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_sprog` -- INSERT INTO `users_info_sprog` (`usersinfoSprog_id`, `usersinfoSprog_name`) VALUES (1, 'Dansk'), (2, 'Engelsk (US)'), (3, 'Engelsk (UK)'), (4, 'Norsk'), (5, 'Svensk'), (6, 'Tysk'), (7, 'Fransk'); -- -------------------------------------------------------- -- -- Table structure for table `users_info_tatoveringer` -- CREATE TABLE `users_info_tatoveringer` ( `usersinfoTatoveringer_id` int(11) NOT NULL, `usersinfoTatoveringer_name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Table structure for table `users_subscription` -- CREATE TABLE `users_subscription` ( `usersSubscription_id` int(11) NOT NULL, `usersSubscription_name` varchar(255) NOT NULL, `usersSubscription_months` int(11) NOT NULL DEFAULT '0', `usersSubscription_price` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_subscription` -- INSERT INTO `users_subscription` (`usersSubscription_id`, `usersSubscription_name`, `usersSubscription_months`, `usersSubscription_price`) VALUES (1, '1 MDR 35,-', 1, 35), (2, '6 MDR 198,-', 6, 198), (3, '12 MDR 349,-', 12, 349); -- -- Indexes for dumped tables -- -- -- Indexes for table `carousel1` -- ALTER TABLE `carousel1` ADD PRIMARY KEY (`carousel1_id`); -- -- Indexes for table `page_work1_videos` -- ALTER TABLE `page_work1_videos` ADD PRIMARY KEY (`pw1videos_id`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`users_id`); -- -- Indexes for table `users_files` -- ALTER TABLE `users_files` ADD PRIMARY KEY (`usersFiles_id`); -- -- Indexes for table `users_gender` -- ALTER TABLE `users_gender` ADD PRIMARY KEY (`usersGender_id`); -- -- Indexes for table `users_info` -- ALTER TABLE `users_info` ADD PRIMARY KEY (`usersinfo_id`); -- -- Indexes for table `users_info_bluse_storrelse` -- ALTER TABLE `users_info_bluse_storrelse` ADD PRIMARY KEY (`usersinfoBluseStorrelse_id`); -- -- Indexes for table `users_info_bukse_bredde` -- ALTER TABLE `users_info_bukse_bredde` ADD PRIMARY KEY (`usersinfoBukseBredde_id`); -- -- Indexes for table `users_info_bukse_laengde` -- ALTER TABLE `users_info_bukse_laengde` ADD PRIMARY KEY (`usersinfoBukseLaengde_id`); -- -- Indexes for table `users_info_etnicitet` -- ALTER TABLE `users_info_etnicitet` ADD PRIMARY KEY (`usersinfoEtnicitet_id`); -- -- Indexes for table `users_info_eye_color` -- ALTER TABLE `users_info_eye_color` ADD PRIMARY KEY (`usersinfoEyeColor_id`); -- -- Indexes for table `users_info_hair_color` -- ALTER TABLE `users_info_hair_color` ADD PRIMARY KEY (`usersinfoHairColor_id`); -- -- Indexes for table `users_info_kategorier` -- ALTER TABLE `users_info_kategorier` ADD PRIMARY KEY (`usersinfoKategorier_id`); -- -- Indexes for table `users_info_landsdel` -- ALTER TABLE `users_info_landsdel` ADD PRIMARY KEY (`usersinfoLandsdel_id`); -- -- Indexes for table `users_info_sko_storrelse` -- ALTER TABLE `users_info_sko_storrelse` ADD PRIMARY KEY (`usersinfoSkoStorrelse_id`); -- -- Indexes for table `users_info_sprog` -- ALTER TABLE `users_info_sprog` ADD PRIMARY KEY (`usersinfoSprog_id`); -- -- Indexes for table `users_info_tatoveringer` -- ALTER TABLE `users_info_tatoveringer` ADD PRIMARY KEY (`usersinfoTatoveringer_id`); -- -- Indexes for table `users_subscription` -- ALTER TABLE `users_subscription` ADD PRIMARY KEY (`usersSubscription_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `carousel1` -- ALTER TABLE `carousel1` MODIFY `carousel1_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `page_work1_videos` -- ALTER TABLE `page_work1_videos` MODIFY `pw1videos_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=51; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `users_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; -- -- AUTO_INCREMENT for table `users_files` -- ALTER TABLE `users_files` MODIFY `usersFiles_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `users_gender` -- ALTER TABLE `users_gender` MODIFY `usersGender_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `users_info` -- ALTER TABLE `users_info` MODIFY `usersinfo_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `users_info_bluse_storrelse` -- ALTER TABLE `users_info_bluse_storrelse` MODIFY `usersinfoBluseStorrelse_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT for table `users_info_bukse_bredde` -- ALTER TABLE `users_info_bukse_bredde` MODIFY `usersinfoBukseBredde_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23; -- -- AUTO_INCREMENT for table `users_info_bukse_laengde` -- ALTER TABLE `users_info_bukse_laengde` MODIFY `usersinfoBukseLaengde_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26; -- -- AUTO_INCREMENT for table `users_info_etnicitet` -- ALTER TABLE `users_info_etnicitet` MODIFY `usersinfoEtnicitet_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `users_info_eye_color` -- ALTER TABLE `users_info_eye_color` MODIFY `usersinfoEyeColor_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `users_info_hair_color` -- ALTER TABLE `users_info_hair_color` MODIFY `usersinfoHairColor_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15; -- -- AUTO_INCREMENT for table `users_info_kategorier` -- ALTER TABLE `users_info_kategorier` MODIFY `usersinfoKategorier_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; -- -- AUTO_INCREMENT for table `users_info_landsdel` -- ALTER TABLE `users_info_landsdel` MODIFY `usersinfoLandsdel_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `users_info_sko_storrelse` -- ALTER TABLE `users_info_sko_storrelse` MODIFY `usersinfoSkoStorrelse_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35; -- -- AUTO_INCREMENT for table `users_info_sprog` -- ALTER TABLE `users_info_sprog` MODIFY `usersinfoSprog_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT for table `users_info_tatoveringer` -- ALTER TABLE `users_info_tatoveringer` MODIFY `usersinfoTatoveringer_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `users_subscription` -- ALTER TABLE `users_subscription` MODIFY `usersSubscription_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; please note with this SQL, i have removed some names pre-made But that is my SQL never the less. Hoping you can help. And it is to my believes that it is with the queries my problems are, mainly, unsure about the if/else's statements, they look good to my eye, it is mostly the SQL i am not the best at making when it comes to searchers. Hope you can help, as always, thanks, and sorry if i left any info out. Please ask if you need more information! Thanks again!
  7. So my question is: how can I insert variables into my mysql queries in php? This is my code now, I would like to use the $me and the $friend variables to work in the sql query: function newChat($me, $friend) { global $conn; $sql = "SELECT id FROM chats WHERE (person1 = $me AND person2 = $friend) OR (person1 = $friend AND person2 = $me);"; mysqli_query($conn, $sql) or die('Error querying database.'); echo "check <br />"; $result = mysqli_query($conn, $sql); $row = mysqli_fetch_array($result); while ($row = mysqli_fetch_array($result)) { echo $row['id'] . ' - ' . $row['person1'] . ' - ' . $row['person2'] . ' - ' . $row['date'] .'<br />'; } } newChat('John', 'Marie'); Also if I set $sql to "SELECT * FROM chats" it only gives me one row of my two test rowes in my database. (it only gives the second row, and just ignores the first one? --> a screenshot of the database is at the end of this post) Can anyone please help me with this? Thanks already!
  8. MySQL queries are not working only inside this block: ... if (isset($_POST['send'])) { } ... The variable itself is set and transferred from the form. What could be the reasons of this and how is better to check?
  9. Hi all, I'm trying to execute a query which uses the value from my session which is set when the user logs in. When I try to view the query, it displays nothing. SQL statement // get value of session $username = $_SESSION['username']; // executeable query $sql = ("SELECT * FROM custstock WHERE username = '$username'"); // query $row = mysqli_query($custdb, $sql) or die(mysqli_error($custdb)); The code for my table; <table width="100%" border="1" cellpadding="1" cellspacing="1" class="carInfo"> <tr> <th>ID</th> <th>Vehicle ID</th> <?php while($custveh = mysqli_fetch_assoc($row)){ echo "<tr>"; echo "<td>".$custveh['id']."</td>"; echo "<td>".$custveh['vehID']."</td>"; echo "</tr>"; } ?> </table> Any suggestions would be great, thanks! Jack
  10. Hi all, <?php require 'db/connect.php'; $result = $db->query("SELECT * FROM people"); ?> I obtained a blank page running the above script, which indicates that everything is fine (path and table name are correct). I then removed the * from the query to see if it would report an error, but it did not. I added print_r($result); and run it. Nothing has changed. I included the * and run, it reported the number of rows and columns in the table. Why there has a been a lack of error reporting in this instance, noting that the ini file is configured to report all sorts of errors, even the warnings and notices (and it is reporting all that in other scripts)?
  11. How to find a record in a table? I now use : $sql = "SELECT col1 FROM table WHERE col1 = '$var' " ; if ($stmt = $conn->prepare($sql)) { $stmt->execute(); $stmt->bind_result($var); while ($stmt->fetch()) { echo $var; echo ' : this variable exists <br>'; } $stmt->close(); } to fetch $var. But this actually results in an echo of the input. The goal is not necessarily echoing it, but determining whether it exists or not and report that its not existing So is it possible with other query to determine if $var exists and then use that as TRUE ?
  12. I have a table which is either empty or has 1 record If the table is empty i cant retrieve info from the database and get an error message. my code: $sql = "SELECT id FROM users WHERE id = (SELECT MAX(id)FROM users)"; $result = $conn->query($sql); foreach ( $conn->query($sql) as $row ) { $id = $row['id']; the for each line gives an error message: how to solve this?
  13. This is my situation If variable $conn has all variables (with a value) $conn = new mysqli($servername, $username, $password, $dbname); and then you use var_dump($conn); and the output would be null of all the values of $conn. What would it mean? Am I right the connection then needs to be re-established? I'm doing 2 queries on a database. First query is SHOW TABLES then make the user choose a table value. From this value a new query is done. So first connection is done. But can I use this connection or should I make a new one?
  14. I am wondering why this is not working. I have a table of order line items. each order can have multiple line items with the same transaction ID just different item codes. I am trying to find single transaction ID's with a specific item code. I also tried doing a count (transactionnumber)<2 but could not figure out how to add a where for the item number. So an order for just this item select distinct(transactionnumber) from Orders (I thought this would select any unique transaction number IE only one occurance)where Code='9987' When I run the above and check the transaction numbers it is any transaction with that code not transactions with only that code? I also tried this select * from OrdersWhere (select COUNT(transactionnumber)from Device_Orders) <2 and ItemCode='9987' This returns no records when I know there are single transaction numbers with that item code? Any suggestions would be appreciated
  15. hello there!!i m building an app for the elections..in this app i ve build a rest service that takes data(votes,etc) from a .js file of another website,and presents them to some fields.the problem is that.on that js file,the creators provide only "party_id" and not "party_name" which is contained in another .js file.i copied the id's and the names to my database.and now i want that:when the first js file gives the "Party_id",to search the database and provide me the "party_name"..what i want to do is to compare the values given from the rest service and the database collection and to return the correct name. i tried this code: var objectId = value; //Debug information that you can see in browser console.console.log("objectId = " + objectId);var whereObject = {"kwdikos": objectId};return JSON.stringify(whereObject); as shown here,it returns all the database array!! http://imageshack.com/a/img673/9877/EkpHcb.png but as it seems,it returns it without comparing..i mean,i want it when the id sent is 2,to return ND,and when id_sent is 1,to return PASOK.it just displays all the database array without criteria match!i tried to do it by using IF statement,but it didnt let me do it!! the correct results should be these:http://imagizer.imageshack.us/a/img537/7291/d2mTx9.png thanks for your time guys!!!
  16. pbac83

    Xpath query

    Hello, I've the following example xml structure: <news> <new> <newid>3443</newid> <title>Title1</title> <body>Body1 hello everyone</body> <url>/news/tech-3443</url> </new> <new> <newid>3753</newid> <title>Title2</title> <body>Body2 hello everyone</body> <url>/news/social-3753</url> </new> <new> <newid>3113</newid> <title>Title3</title> <body>Body3 hello everyone</body> <url>/news/tech-3113</url> </new> </news> How can write a Xpath query to fetch only nodes with the prefix "/news/tech-" in the "url" field? Many thanks! Piero
  17. I am a beginner / intermediate MySQL user, but I need what I believe is a fairly advanced sql query, and I haven't been able to figure it out on my own. If someone could please help, I would really appreciate it. Here is my current query, and it IS returning valid data: $result = mysqli_query($con, "SELECT r.asset_title, r.alt_code, r.studio, r.type, r.start_win, r.end_win, r.rcv_date, r.pub_date, r.date_r4qc, r.qc_status, r.qc_notes, r.re_qc_date, r.promo_date, from_unixtime(ft.in_time) AS in_time, f.description AS description, left(ft.file_name, 20) FROM calendars r, tracker ft, folder f WHERE (r.alt_code = left(ft.file_name, 20) and ft.folder_id = f.id) limit 100"); Here's what I'm trying to accomplish: Most of the data that I need is in a single table, but there is one single field in each of two different tables, that I need to incorporate into my web output. The problem is, that the current status, and the date associated with that current status, are not sorted in any specific order. For each asset in the "calendars" table, I need to list all of the statuses, to include the "latest" status from the tracker table... In other words, for each asset in the "calendars" table, I need to look at the latest entries in the "tracker" table, then sort the "tracker" table output, returning the latest entry from that table. The above query IS returning valid data, but the data being returned from the tracker table is not always the latest data... How can I modify the above query to get just the latest entry from the tracker table? Again, any help would be greatly appreciated. Thanks in advance, and Merry Christmas to all... JCF
  18. Anyone have any suggestions.?? I have Table <customers> I need to query the data points in Column ID ( data type_ Int ) and Column Lot (data type_Int) FROM customers but what my query is doing is adding this two data points up. and I don't want a SUM result. ex. if ID = 100 and Lot = 543 my query result = 643 what I am looking for is IF ID=100 and Lot = 543 my query result should be= 100543 SELECT customers.ID + ' ' +customesr.Lot AS combined FROM customers ANY SUGGESTIONS PLEASE!!!
  19. Hello.I have this code $get_cart_info = mysql_query("select c.*,g.*,m.* from cart as c left join games as g on c.tid = g.id left join movies as m on c.tid=m.id where c.user = {$CURUSER['id']} GROUP BY c.tid") or die(mysql_error()); But what I need is when c.type is movie its only takes info from movies tabel, but still have to take everything out, because I both have movies and games in cart..Can it be done, or do I have to trying something else?
  20. I want to order my query by one of my custom field values. That custom field value is a repeater field inside a regular custom field. However, the problem is that my query is set to only show pages from a certain template, wich is done by the meta_key and meta_value attributes. As far as I get it the meta_key and meta_value should also be used to order my query. How can I do both? My query looks like this: query_posts(array( 'meta_key' => '_wp_page_template', 'meta_value' => 'template-kursny.php', 'showposts' => -1, 'post_type' => 'page', )); I've tried to google this for a while now and I've found similar cases but haven't found a working solution yet.
  21. When I try to run this update query in ms access 2007 I get an error box message that says "Data type mismatch in criteria expression". I know the problem is at the end around replace(property.[park city]," ","")=replace(locations2011.city," ",""). But I checked the data types for all the related columns, which is text, and they all match for both tables. If I put quotes around property.[park city] or remove the replace function from it, the query will run but obviously not how I want it to. I've tested this code with a smaller table and it works so what's the problem? UPDATE property, locations2011 SET property.county = locations2011.countyWHERE property.county Is Null And property.[park state]=locations2011.state And replace(property.[park city]," ","")=replace(locations2011.city," ",""); I know I can just remove all the spaces from the property table with ctrl+h replace all but I'd rather leave the data that's already there alone if possible.
  22. So far i know that columns with 1-5 character should be marked as "Char" instead of "Varchar" because of less memory usage. Does this run SQL-database faster if i just choose certain values like SELECT name, password FROM account instead of SELECT * FROM account? Does it actually mater do i choose char or varchar?
  23. I'm trying to have a website where i take a set of people [ (a) & ( ] and match them automatically, after matched--- person ( gets an email with all of the info of person (a). I would like each to have a seperate sign-on member pageā€¦ I have no idea where to start so any guidance is appreciated.
  24. Hello, New at this DELETE thing. I wish to write a DELETE query that will remove records from the 'REPAIRS" table. The conditions that must be met is that the "active" field = false in the "REPAIRS" table and that the "tradeID" field in the "REPAIRTRADE" table = cet. I'm confused about the statement needed and the syntax. Any help is truly appreciated.
  25. i checked the main site and it has been a whole heap of help so far. However im not sure how to accomplish a specific task and im now stuck on this. I have the following query: SELECT * FROM chjadb_vehicles WHERE v_make ='$make' AND v_year= '$year' The following statement works fine. However what i want is to add more query criterias such as body type, transmission and thing like that. How do i set something like that. I tried doing it like this: SELECT * FROM chjadb_vehicles WHERE v_make ='$make', v_year= '$year', v_transmission = '$trans' Doesn't work however any help would be appreciated!
×
×
  • Create New...