Add PDF to database - mysql

I hope you can help me. In my database (supermarket) I have a table for orders and other for order_details and I would like to add the PDF of each invoice (associated to the order_number) to the database. Is this possible in mySQL? How can I do it?

You could store the PDF in an orders directory and insert the link into the db so when it is sent to the customer it would provide the link to the invoice

There are three possible ways I can think of to go about this.
Method 1.
Have a directory in which all the pdfs are stored. Give each PDF a name that is the order number found in the database.
Method 2.
Store the PDFs in a directory like method 1, but in your database store a file path to the PDF as a varchar. eg: /orderPdfs/124.pdf
Method 3.
Create a BLOB column in your order table and store the PDFs in this field.
Information on how to do this with PHP can be found in the answer to this post: How to store .pdf files into MySQL as BLOBs using PHP?

Related

Database with CSV's

Hi guys I'm currently trying to create a database for a business which works with unit sensor data. A company has multiple monitoring units which has multiple sensors, each sensor spits out CSV files every hour or so.
Im trying to relate this data to a company, so clients can view their sensors when they enter the site. Im currently just importing csv scripts into custom tables (by custom i mean just custom headers), obviously the table can only be as big as the CSV table (needs to be the same amount of rows). But the issue i am having is trying to link the csv data to the company? The CSV's don't have id numbers so i cant use keys to link tables.
Here is my Schema: https://puu.sh/wRnPs/eff7a60b5b.png
Here is a CSV example: https://puu.sh/wRoPA/09b3146d40.png
Any ideas would be greatly appreciated i have done a lot of research and can't seem to find a solution!

How to reference a document in MySQL?

My database has a table within it, let's call it 'doclist'. I want the table to display a document name, the date associated with it, and a link to download this file. After researching it seems that the file (looking to include a PDF or Word doc) needs to be stored somewhere within htdocs, and I will need to reference the file location within one of the table fields. What type of field would that need to be: varchar, blob, or text? The only other tutorials I have seen including files are just dumping data, where I want to reference a file and allow its download. Any direction would be very helpful at this point.

Access VBA to find & move recurring value

Good Morning,
I'm fairly new to Access VBA and I've been trying to find a solution to a problem:
I've created a form from which users upload an excel file to a database. File open prompt appears, user selects the file, temp table gets created and data gets pulled to this table. From there a set of macros populate the required fields and push the complete set to a perm table and then temp table gets deleted. Now I would like to take it a step further and try and count how many times a value has been uploaded to the table...
Lets say that the value appears in the table twice already, then if user tries to upload the same value for the third time it will be uploaded to a different table. Bear in mind that the file which users will upload may contain values that will be uploaded for the first, second, third, etc. time.
Do you have any suggestions or solutions to my problem? Is it even possible? If yes then how can I make Access to distinguish which records are being uploaded for the first, second, third, etc. time and follow appropriate paths?
I've been scouting the internet for several days now, but no one seems to have such issue.
Thank you in advance for replies.
I'm not sure I follow. You are essentially trying to prevent inserting duplicate data to a production table and if a duplicate is encountered at the record to a different table?

best way store large text in a table, XML or JSON?

I have a form with 4 fields which each one will be filled with a lot of text +/- 300 words.
this form will be filled once in a week for every user of the system, the system have like 1300 users and growing. Actually im using a mySQL database. The question is, what would be the best solution to store this data?
storing in a table in mySQL with 'TEXT' data type columns for then do a 'select * from mytable where id=myuserID'
store it in a JSON or XML file for each user and save it in the server?
What would be better
I would recommend you to save this data on your server as a xml-file and only save the path in the mySQL database.
This is how I do it.
for large text, I usually save in a plain text file (for example: chat history, map coordinate) and the table just for storing the path of the file.

How to scan for and export all email addresses from a MySQL database

I use Joomla 2.5 to run my website. I have the standard user accounts, but I also use 2 components SobiPro and Jevents that hold their own user data in their own tables in the MySQL database.
My client has asked me to add all the website users to their MailChimp list. I can do this by doing a csv import.
I can only find a way to export the sobipro_feild_data in its whole as a CSV file. This contains too much information, i'm having to manually search for email addresses using search & find and copy/paste them to a new csv file. This is taking me ages.
Surely there is a simple command I can use in PHPMyAdmin to scan the MySQL database for anything that looks like an email address and export them as a single list.
Is this possible? Can anyone tell me how to get all email addresses out of my MySQL database as a list with no other data?
_Ash.
You can use a regular expresion to identify the emails, like:
SELECT *
FROM users
WHERE email REGEXP '^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]#[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]\.[a-zA-Z]{2,4}$'
After that, you can export the values and organize them.
Update: you can look for better regular expresions to match emails on google.