Skip to content

Tag: mysql

Return One Row from MySQL

Amateur question, but something I’ve been wondering about. What is the PHP for selecting one row from a MySQL query? AKA you’re picking something by unique ID (you know there’s only one row that matches your request) and want to get only that value. Do you still have to use a while loop and …

How to Check if value exists in a MySQL database

Suppose I have this table: I want to check if the value c7 exists under the variable city or not. If it does, I will do something. If it doesn’t, I will do something else. Answer preferred way, using MySQLi extension (supported from PHP 5 onwards): deprecated and not supported in PHP 7 or newer:

show only limited categories with a MySQL queries

I have a mysql database in which there is about hundreds of category for photo album. When i display the album using so it will display the last 10 categories but if i want to display only 15 categories in between from that hundreds of category what the query should be? i have try this. here its displaying th…

MySQL: Group by two columns and sum

Building an inventory system. I have lots of products and each product has three different variables. So for stock totals I want to group by the two columns (product & size) and sum quantity to …

Website Scraping with PHP,Curl and MySQL Database

sorry am having bit of trouble here storing scraped content into MYSQL database. So what am trying to do is save the Module Code and Module Title from this site [http://www.ucc.ie/modules/descriptions/page014.html][1] into MYSQL database. Am able to get content from the site alright but I just cant seems to b…

Select on empty table but still get column names

I want to do a SELECT on an empty table, but i still want to get a single record back with all the column names. I know there are other ways to get the column names from a table, but i want to know if it’s possible with some sort of SELECT query. I know this one works when i

Multiple Uniques MYSQL

I have some code im trying to get working. What im looking for is to have it so that i query a site, then display results and upload to database. I want it to ignore duplicates which i have working by checking the date. issue im having is when a user searches for another stock ticker it does not insert

PDO get the last ID inserted

I have a query, and I want to get the last ID inserted. The field ID is the primary key and auto incrementing. I know that I have to use this statement: That statement works with a query like this: But if I want to get the ID using this statement: I get this error: What am I doing wrong?