QR Codes generation from MySQL rows

2019-03-04 15:45发布

I have a serious problem, maybe to some it's not so serious, but as I am not good with programming, for me it's a really tough problem. I will try to explain all clearly:

I am using WAMP (MySQL and PHP), I have database called ''store'', which includes table with fields:

1.) ID (with Auto Increment)

2.) Name (Varchar)

3.) Description (Varchar)

4.) Image (Blob) - where to store QR code

Basically, I am creating small online store. I have inserted some rows, like Name - Chair, Description - Small chair 2x2 for kitchen

Now, what I want to do is to have a script, as I understand, I need some kind of loop script or etc., which goes through my MySQL database every record and creates of it a QR Code to every row. I would like to include in QR code fields "Name", "Description" and also link to webpage, which my item has got description about current item (say item ''Chair''). I wanted to know, is it possible to do that?

For creating QR codes, I tried to use PHP QR Code Library (http://phpqrcode.sourceforge.net/)

I think it's easy to use, I opened it in my localhost index.php page of Library and it opens webpage, where you can enter what you want to put in QR code and then it generates it for you and automatically saves QR code picture in Folder.

So, my question is, guys, how to make script/loop, which goes through every row what I have in MySQL database and creates out of it QR Code? As I understand, I need script which goes through every row of database, then script which creates QR code automatically (including in script that PHP QR Code Library, with who it can create QR codes) and script, which inserts QR codes in Image (Blob) field? Also then I will need another script to display QR code in webpage? Damn, that's a lot..

Before I asked this question, I tried to manually create QR code with PHP QR Code Library and insert it in my Database and then display. I used this tutorial how to do that and it worked: http://installationquery.blogspot.com/2012/05/inserting-and-displaying-images-from.html

Maybe that will help somebody. So, really looking forward for some help here and huge thanks in advance.

1条回答
何必那么认真
2楼-- · 2019-03-04 16:24

Okej, you can try do something like this:

$result = mysql_query("SELECT * FROM test_image WHERE image = ''") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
    echo 'Working with id '.$row['id'].' and name '.$row['name'].'<br />';
    // DO YOUR CODE FOR THIS ROW IN YOUR TABLE
}
查看更多
登录 后发表回答