Jump to content

Search the Community

Showing results for tags 'MySQL'.

  • 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

Calendars

  • Community Calendar

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. Hey guys, I need your help with a problem I’ve been able to walk around so far. Namely, I want to make a mysql query in a node.js web socket: connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results, fields) { if (error) throw error; // Code here... }) In the variable results I can now use the data in the form of a JSON object. That’s not a problem. So far, I have done this so that when I wanted to make several queries, I have nested into each other. Like this: connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results, fields) { if (error) throw error; connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results, fields) { if (error) throw error; // Code here... }) }) But now I need that some queries are only carried out if certain conditions are met. As a result, the queries can no longer be logically nested. That’s why I need something like this: if(a == b) { connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results1, fields) { if (error) throw error; // Code here... }) } if(c == b) { connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results2, fields) { if (error) throw error; // Code here... }) } And after both if loops I can logically no longer access the values results1 and results2. How can I do that? Do you need more information. I hope for some answers. Yours, Ben
  3. I would like to connect to a mysql database that is a localhost connection and not on a internet service provider. How do i connect? Do you use "localhost or your ip"? I tried it and it does not work. Also, how do i open a port for access? Is the port connections blocking me from succeeding regarding this?
  4. Hello everyone I want Show Some Recorded according financial year For Example from 01-04-2016 to 31-3-2017 01-04-2017 to 31-03-2018 my Code $pst = date('Y'); $pt = date('Y', strtotime('+1 year')); $sql="SELECT *FROM mytable where date BETWEEN CAST('$pst-04-01' AS DATE) AND CAST('$pt-03-31' AS DATE)"; Anyone Can explain how i done this
  5. i'm trying to write some line for stock valuation with FIFO method. in the internet somewhere i found with STACK &/or QUEUE method it might be done. but i couldn't understand how it might be done. can anyone please suggest me if STACK &/or QUEUE are the real solution. if no suggest me something better and if yes help me understand these functions.. tahnks in advance.....
  6. Hi all, l'm a Newbie here I would like to create a page, which after user logged in, they was able to update number of chanting daily with number input. User may insert number and click submit button to update its. After updated, below the submit button, to show up the total number of their total chanting number, and total of all users chanting numbers. Lastly is the history of users update in table view which showing username, date of update, number of updates. Can I have the solution or any related article or site which i can referring to... Thanks all.
  7. I try to learn Node.js. I have used Mamp and PHP till now. With Mamp I can access to MySql. Is that useful for Node? Probably I am confusing concepts and Mamp does not work with Node. Right? .
  8. Hello everyone, i have created a html form and a button. Javascript reacts to the button click sends the html values to functions.php and there i have a function to insert into the wordpress database. Every field is working and is being inserted into the database but i have some problems to upload and save a image file with these steps. Iam not using a html form i wanted to go the javascript way. Is there any option/solution to insert an image file as blob into mysql using php without form submit just via javascript ajax ? Thanks and best regards, Atilla
  9. Hi I have a query that returns the count of entries based on CURDATE(), it works for any dat in this month (April) but does not work for next month (May). I think it is something to do with CURDATE()+3 returns 2018-04-31 which should be 2018-05-01 This Works as Date is in April SELECT COUNT(Machine) FROM production WHERE Status = 'Confirmed' AND DATE(FROM_UNIXTIME(production.Required)) = CURDATE() This does not work as in May SELECT COUNT(Machine) FROM production WHERE Status = 'Confirmed' AND DATE(FROM_UNIXTIME(production.Required)) = CURDATE()+3
  10. Hello All, I'm trying to create a table of images in which each image would be a different link to a product on our website. I'm just learning how to code so I appreciate any help you can give! Attached is pdf showing the general layout of what I'm trying to do. Thanks! Line Card 10-16-18.pdf
  11. Hi everyone, i am using mysql for database and when i am trying to run the query SELECT * FROM carshopdatabase i got the following error message: SELECT * FROM carshopdatabase LIMIT 0, 25 So, why is this happening and how do i fix it? Thanks!
  12. I am Learner and I was building one app for learning purpose I have been stuck at one place from several days I have already write this question to other forums but did not get any working answer of this I am building one app where I need to insert some value to one table and need to update this last inserted Id to other table this all goes in single click in my app for this I am using Mysql database for which I wrote query insert into table name (field1, field2......) values (val1, val2.......); update table_name SET column_name where table_name.column_name IN(val1,val2,val3) when I am using this query in PHPmyadmin I am getting okay result but when I am doing same thing with nodejs app I am getting reserve word error from MySQL maybe because of using two queries in one statement I have also tried stored procedure but when I am using stored Procedure I am facing problem in passing array value to mysql variable If any one required any other details please contact me I will share code also
  13. I have 3 fields that are the same name as corresponding column in MySQL database. First field is a dynamic dropdown list called "eventname". Second field called "eventdate" is an input field that gets populated via choice made from "eventname" dropdown list / First field. Third field called "venuename" is an input field that gets populated via choice made from "eventname" dropdown list / First field. What this dynamic dropdown list does is select the eventname from database then there is an onchange function that pulls out corresponding data from same line for the eventdate and venuename and sets them in the corresponding input field. All works as they should and data gets entered to the MySQL database. Only one issue: "eventname" choice from dropdown list should be submitted as "eventname" the displayed choice, what happens is my code enters data in MySQL as "eventdate | venuename" and my desired result should only be "eventname" The PHP <select id="eventname" onchange="eventFunction(eventname)"> <option selected="selected"></option> <?php foreach ($event as $event) { ?> <option value="<?php echo $event['eventdate'] .'|'. $event['venuename']?>"><?php echo $event['eventname'] ?></option> <?php } ?> </select> Date: <input id="eventdate"> Venue: <input id="venuename"> and the JavaScript <script> function eventFunction(eventname){ var eventDetails = eventname.options[eventname.selectedIndex].value.split("|"); document.getElementById("eventdate").value=eventDetails[0]; document.getElementById("venuename").value=eventDetails[1]; } </script> NOTE: If I touch the value attribute ie value="<?php echo $event['eventdate'] .'|'. $event['venuename']?>" the javascript wont work. I am a begginer with coding using JavaScript, can someone help me solve this please with examples. Thanx.
  14. Hello w3schools community ! I would like to know .. - What is exactly the difference between SQL ( Structured query language ) and MySQL ?, ( with examples if possible ) - Does learning SQL suffice ? Or should I use a RDBMS such as MySQL, Oracle .. etc ? Thank you .
  15. BACKGROUND: Many moons ago it was suggested that I create a CRON job that would read into a MySQL table the results of a method call to a Matomo API call and thereby speed up the rendering of data for visitors to the Grammar Captive website. I have since come to learn that this technique is called data translation. The following code creates a class object that when inserted into a foreach loop is suppose to fill the properties of the object for further manipulation. Unfortunately it does perform the intended task. THE CLASS class TranslateMatomoAction { public $mysqli_obj; public $visitID; public $type; public $serverTimePretty; public $timestamp; public $url; public $generationTime; public $pageTitle; public $pageID; public $pageView_ID; public $pageID_Action; public $timeSpent; public $eventCategory; public $eventAction; public $eventName; public function __construct($property, $value) { if ($property === 'type') { $this->type = $value; } else if ($property === 'serverTimePretty') { $this->serverTimePretty = $value; } else if ($property === 'timestamp') { $this->timestamp = $value; } else if ($property === 'url') { $this->url = $value; } else if ($property === 'generationTimeMilliseconds') { $this->generationTime = $value; } else if ($property === 'pageTitle') { $this->pageTitle = $value; } else if ($property === 'pageId') { $this->pageID = $value; } else if ($property === 'idpageview') { $this->pageView_ID = $value; } else if ($property === 'pageIdAction') { $this->pageID_Action = $value; } else if ($property === 'timeSpent') { $this->timeSpent = $value; } else if ($property === 'eventCategory') { $this->eventCategory = $value; } else if ($property === 'eventAction') { $this->eventAction = $value; } else if ($property === 'eventName') { $this->eventName = $value; } } public function set_visitID($visitID) { $this->visitID = $visitID; } public function set_mysqli_obj($mysqli_obj) { $this->visitID = $visitID; } } THE INSERTED CLASS AND ASSOCIATED CODE if (is_array($value1) && ($key1 === 'actionDetails')) { foreach($value1 as $key2 => $value2) { //LEVEL 2 - This foreach statement traverses the set of indexed arrays whose elements are a key-value pair of indices and arrays. Each array is a value of the actionDetails element of a visit. if (is_array($value2)) { $matomo_action = new TranslateMatomoAction($key3,$value3); foreach($value2 as $key3 => $value3) { //LEVEL 3 - This foreach statement traverses the elements of the associative array corresponding to the value of $key2. $matomo_action($key3, $value); } } } } DILEMMA: Unfortunately, the above procedure fails to fill the values of the object's property as expected. QUESTION: Where have I gone wrong? Roddy
  16. 0 down vote favorite BACKGROUND: I have built a custom search engine that works fine in English, but fails in Japanese, this despite confirmation from my host server that I have performed the installation of the Japanese mecab parser correctly. My own checks reveal the following: 1) SHOW CREATE TABLE: FULLTEXT KEY search_newsletter (letter_title, letter_abstract, letter_body) /*!50100 WITH PARSER mecab */ ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 2) SHOW PLUGINS: ngram | ACTIVE | FTPARSER | NULL | GPL | mecab | ACTIVE | FTPARSER | libpluginmecab.so | GPL IMPLEMENTATION 1) MYSQL Statement: $sql ="SELECT letter_no, letter_lang, letter_title, letter_abstract, submission_date, revision_date, MATCH (letter_title, letter_abstract, letter_body) AGAINST (? IN NATURAL LANGUAGE MODE) AS letter_score FROM sevengates_letter WHERE MATCH (letter_title, letter_abstract, letter_body) AGAINST (? IN NATURAL LANGUAGE MODE) ORDER BY letter_score DESC"; 2) CUSTOM SEARCH ENGINE: See under Local Search / Newsletters at https://www.grammarcaptive.com/overview.html 3) DOCUMENT SEARCHED: See under Regular Updates / Newsletter / Archives / Japanese at https://www.grammarcaptive.com/overview.html COMMENT: Neither PHP, nor MySQL complains. Simply any Japanese word search that needs to be parsed is not returned. For example, the word 日本語 can be search and found, but does not require any parsing to be retrieved. The search for any other Japanese word in the newsletter fails. REQUEST: Any troubleshooting tips would be greatly appreciated. Roddy
  17. No keywords are highlight. for what reason behind that. please help me Here is my HTML code and at the bottom PHP. HTML CODE: <form id="nbc-searchblue1" method="post" enctype="multipart/form-data" autocomplete="off"> <input type="text" id="wc-searchblueinput1" class="nbc-searchblue1" value="<?php echo $search; ?>" placeholder="Search Iconic..." name="search" type="search" autofocus> <br> <input id='nbc-searchbluesubmit1' value="Search" type="submit" name="button"> </form> PHP CODE: <?php // We need to use sessions, so you should always start sessions using the below code. session_start(); // If the user is not logged in redirect to the login page... if (!isset($_SESSION['loggedin'])) { header('Location: ../index.php'); exit(); } include 'connect.php'; $search = $sql = ''; if (isset($_POST['button'])){ $numRows = 0; if (!empty($_POST['search'])){ $search = mysqli_real_escape_string($conn, $_POST['search']); $sql = "select * from iconic19 where student_id like '%{$search}%' || name_bangla like '%{$search}%' || name like '%{$search}%' || phone like '%{$search}%' || blood like '%{$search}%' || district like '%{$search}%'"; $result = $conn->query($sql); $numRows = (int) mysqli_num_rows($result); } if ($numRows > 0) { echo "<table> <thead> <tr> <th><b>Photo</th> <th><b>Student ID</th> <th style='font-weight: 700;'><b>নাম</th> <th><b>Name</th> <th><b>Mobile No.</th> <th><b>Blood Group</th> <th><b>Email</th> <th style=' font-weight: 700;'><b>ঠিকানা</th></tr></thead>"; while ($row = $result->fetch_assoc()){ $student_id = !empty($search)?highlightWords($row['student_id'], $search):$row['student_id']; $name = !empty($search)?highlightWords($row['name'], $search):$row['name']; $district = !empty($search)?highlightWords($row['district'], $search):$row['district']; echo "<tbody>"; echo "<tr>"; echo "<td>" . "<div class='avatar'><a class='fb_id' target='_blank' href='https://www.facebook.com/" . $row['fb_id'] . "'><img src='" . $row['photo'] . "'><img class='img-top' src='fb.png'></a>" . "</td>"; echo "<td data-label='Student ID'>" . $row['student_id'] . "</td>"; echo "<td data-label='নাম' style=' font-weight: 700;'>" . $row['name_bangla'] . "</td>"; echo "<td data-label='Name' style='font-weight:bold;' >" . $row['name'] . "</td>"; echo "<td data-label='Mobile No'>" . "<a href='tel:" . $row['phone'] . "'>" . $row['phone'] . "</a>" . "</td>"; echo "<td data-label='Blood' style='color:red; font-weight:bold;' >" . $row['blood'] . "</td>"; echo "<td data-label='Email'>" . "<a href='mailto:" . $row['email'] . "'>" . $row['email'] . "</a>" . "</td>"; echo "<td data-label='ঠিকানা' style='font-weight: 700;'>" . $row['address_bangla'] . "</td>"; echo "</tr>"; echo "</tbody>"; } } else { echo "<div class='error-text' style='font-weight: 700;'>No Result</div><br /><br />"; } } $result = $conn->query("SELECT * FROM iconic19 $sql ORDER BY id DESC"); function highlightWords($text, $word){ $text = preg_replace('#'. preg_quote($word) .'#i', '<span style="background-color: #F9F902;">\\0</span>', $text); return $text; } $conn->close(); ?>
  18. Hi, I am having a very hard time debugging & running the following query from a cell on php or pma. $sql = "UPDATE crypto SET crypto_openssl_recommendation = 1 WHERE (\"%ECB%\" OR \"%RC2%\" OR \"%RC4%\" OR \"%DES%\" OR \"%3DES%\" OR \"%MD5%\") LIKE UPPER(crypto_descr);"; The table is meant to keep track of OpenSSL encryption methods, and their availability and recommendation over CryptoJS wether used in Javascript, or JScript. This query is meant to update the recommendation, but the quality of my MySQL querying has wilted a bit in the past four years.
  19. hello all! i am struggling with a problem in mysql. i want to select all rows from a table with an id and its child ids. i tried the following ............... AND projtype IN (SELECT id FROM projcat WHERE under=1 UNION SELECT id FROM projcat WHERE under IN (SELECT id FROM projcat WHERE under=1)) it works. But this selects rows that matched the child ids only. i want to select all the rows which use the parent id also (i.e. '1' on the given example). please help me with some hints. thanks in advance....
  20. 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. }
  21. khan.sikki

    Seating Layout

    Hello Friends, Can anyone help in designing seating layout and linking the rows and columns with Database table Regards, Sikandar
  22. I have been chasing this issue now for a week. I am new to PHP but have been programming in ASP.NET /VB for over 10 years. I have taken the time to document my issue with PHP connecting to a Localhost database and will try to provide a brief explanation of where I am at. First some environment information. OS - Windows 10 - 64bit. DB - Both SQL Server Manager and MySQL Community. Both running on my development machine. PHP - Version 7.2.12 Development Server running Localhost. From my PHP.INI file here are the extensions I am running. extension=mysqli extension=odbc extension=pdo_mysql Under the ;Paths and Directories I made the following changes. Uncommented include_path = ".;c:\php\includes" Uncommented and edited extension_dir = "c:\PHP\EXT" Note: I also had a number of PHP drivers for MSSQL but have abandoned that attempt and moved to MyPHP // MY TEST CODE \\ <?php $link = mysql__construct("localhost", "mikea", "!QAZ2wsx"); mysql_select_db("database", $link); $result = mysql__construct("SELECT * FROM actor", $link); $num_rows = mysql_num_rows($result); echo "$num_rows Rows\n"; ?> // HERE IS THE ERROR \\ Note I got the same error when trying to use PHP and MSSQL. And the same error with a number of different coding attempts. Fatal error: Uncaught Error: Call to undefined function mysql__construct() in C:\PHP\www\site.php:3 Stack trace: #0 {main} thrown in C:\PHP\www\site.php on line 3 From the error syntax, it appears that the PHP is attempting to call a function out of the driver and it is not being found. This could indicate that there is a compatibility issue the driver is not being called. I have conducted a great deal of research and there is a lot about this problem but most are a few years old. I have downloaded and installed the most current versions of PHP and the MySQL drivers. I want to progress with PHP but need to be able to make connections to mySQL or MSSQL database. I would prefer now to use MySQL as it is more popular on hosting sites.
  23. I have a website named Advisorymandi.com - From last 2 days I'm facing unwanted traffic from unknown source. Its Server is not working even website is not open. Can any one help me please to resolve it.
  24. Hi everyone, I am still learning changing PHP by mysqli to PDO. I'm not get used with PDO because it is little complex to understand, but maybe few weeks I will understand how PDO works. Now, I am trying to make redirect with type account in website and database. I am trying to identify type of three - administrator, license, and scorer page. I set up the test to make it work, seem it went dead end, it won't go to admin or license or scorer page. What did I do wrong? maybe something is missing. here my code: <?php /** * Created by PhpStorm. * User: Gary.Taylor * Date: 7/5/2018 * Time: 10:10 PM */ session_start(); require('access.php'); if(isset($_POST['submitted'])) { $username = $_POST['username']; $password = $_POST['password']; if($username && $password) { $login = $GaryDB->prepare("select username, password, Administrator from account Where username = '.$username.' and password = '.$password.' and Administrator = X"); $login->execute(); $count = $login->fetch(); if($count == 1) { $_SESSION['username'] = $username; header('location:admin.php'); } } elseif ($username && $password) { $login = $GaryDB->prepare("select username, password, License from account Where username = '.$username.' and password = '.$password.' and License = X"); $login->execute(); $count = $login->fetch(); if($count == 1) { $_SESSION['username'] = $username; header('location:license.php'); } } elseif ($username && $password) { $login = $GaryDB->prepare("select username, password, Scorer from account Where username = '.$username.' and password = '.$password.' and Scorer = X"); $login->execute(); $count = $login->fetch(); if($count == 1) { $_SESSION['username'] = $username; header('location:scorer.php'); } } else{ header('location:denied.html'); } }
  25. Hello, I am currently in the middle of creating a web comic aggregation website. So far, I have written a PHP-based RSS reader that grabs the image source links and publication dates for various web comics from their RSS feeds, and uses this to update a MySQL database. This RSS reader/database updater is configured to run once every several hours and update the database with any new comics it finds. It seems to be working fine, and now I am starting to work on the front end of the website, which needs to grab this information from the ever-growing database, and display it in a user-friendly and interactive format. I wrote the database updater in a fairly procedural way, because it didn't strike me as something that lent itself very much to object-oriented development. However, the front end of the website does strike me as something that I can save myself a lot of time on by coming up with a decent object oriented design first. Unfortunately, I don't have a lot of experience in this, so I thought I would look online for suggestions. So far, I have decided specifically what I would like the front end to do, and have come up with 2 possible approaches to designing it, but am unsure about both. Here's what I would like it to do: (To clarify, when I say the phrase "comic strip," I'm referring to a whole strip like XKCD, Dilbert, the far side, etc., and when I say the phrase "comic," it refers to an individual comic within a comic strip, i.e. the Dilbert comic for 8/30/2016). I would like my webpage, by default, to display a vertically stacked list of the latest comic images from each comic strip in the database. For customization, I want a comic strip control panel, which allows users to decide which comic strips are enabled/disabled, and in what order they are displayed. I would like each comic image to appear between text denoting the name/author of the strip and an individual set of buttons that allows the user to go forward and backward through the archived comics, and also to adjust the size/scaling of the image. Finally, I would like a similar but generalized set of buttons that allows the user to control all the comic strips in the same fashion, but at once. Based on my basic understanding of object oriented programming, and the design approach suggested in this stack overflow answer: http://stackoverflow.com/questions/1100819/how-do-you-design-object-oriented-projects, I came up with one possible design: Two classes: 1) a comic strip class that contains attributes like the comic strip's name, ID number (from my database), enabled/disabled status, and current comic to display (an object of the next class), in addition to functions to get and set each of these variables, 2) a comic class that contains attributes like the image source link, publication date, and scaling percentage, in addition to functions to get and set each of these variables Then the main webpage would contain a comic strip control panel and general comic control panel as described in the desired functionality. In addition, it would contain an array of individual comic control panels, and an array of div tags (or a similar tag), which would be displayed vertically stacked and alternating along with the comic strip names in plain text. Finally, there would be functions for updating comic and comic strip object information from the database, and functions for updating the div tag content for comic display based on the comic object information. All the functions would be called using JavaScript/Ajax from the appropriate buttons. However, I was unsure about this design, so I asked a friend, who suggested that I use a model-view-controller design pattern, which I guess is popular in web development because its potential for separating all the various languages. After reading about this online, I have come up with a possible alternative design: Model: PHP, an array of comic strips, including name and ID number, active/inactive status, and current comic image URL/publishing date View: PHP generated HTML/CSS, as described before, a comic strip control panel for enabling/disabling and ordering, a vertically stacked list of comic strip names, constituent comic images, and individual control buttons, and a general set of buttons for controlling all enabled comics at once Controller: PHP/MySQL, a function to update order and active/inactive comic strip status, a function to update a given comic strip's current comic information, and a function to update all comic strips' current comic information at once As I understand it, the controller functions would be called upon user input into the view (clicking the buttons), which would then update the information stored in the model, and then somehow that would trigger a refresh of the view based on the new model information. I am worried I may have missed something in each of these designs (especially the first one), and unsure about the potential merits of one versus another. I was also wondering if it might be possible to combine the two somehow. Does anyone have any suggestions? Help would be much appreciated
×
×
  • Create New...