从MySQL行生成QR代码 [英] QR Codes generation from MySQL rows

查看:84
本文介绍了从MySQL行生成QR代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个严重的问题,也许在某些情况下没有那么严重,但是由于我对编程不擅长,对我来说这是一个非常棘手的问题.我会尽力清楚地解释所有问题:

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:

我正在使用 WAMP(MySQL和PHP),我有一个名为"store"的数据库,其中包括带有字段的表:

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

1.)ID(具有自动递增功能)

1.) ID (with Auto Increment)

2.)名称(Varchar)

2.) Name (Varchar)

3.)说明(Varchar)

3.) Description (Varchar)

4.)图片(斑点)-二维码的存储位置

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

基本上,我正在创建小型在线商店.我插入了一些行,例如名称-椅子",描述"-厨房用小椅子2x2

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

现在,我想做的是拥有一个脚本,据我了解,我需要某种循环脚本等,该脚本会遍历我的MySQL数据库的每条记录,并为每行创建一个QR代码.我想在QR码字段中添加名称",描述",并链接到网页,该网页上有我当前商品的描述(例如椅子"商品).我想知道,有可能这样做吗?

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?

在创建QR码时,我尝试使用 PHP QR代码库( http://phpqrcode.sourceforge.net/)

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

我认为它很容易使用,我在Library的localhost index.php 页中将其打开,然后打开了网页,您可以在其中输入要放入QR码的内容,然后它会生成并自动将QR码图片保存在Folder中.

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.

所以,我的问题是,伙计们,如何制作脚本/循环,遍历我在MySQL数据库中的所有行并根据其中创建QR代码?据我了解,我需要遍历数据库每一行的脚本,然后是可以自动创建QR码的脚本(包括在PHP QR Code Library中可以创建QR代码的脚本中)和可以在Image中插入QR码的脚本( Blob)字段?另外,我还需要另一个脚本来在网页中显示QR码吗?该死的,好多..

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..

在我问这个问题之前,我尝试过使用PHP QR Code Library手动创建QR Code并将其插入到我的数据库中,然后显示.我使用了本教程来做到这一点,并且有效: http ://installationquery.blogspot.com/2012/05/inserting-and-displaying-images-from.html

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.

推荐答案

Okej,您可以尝试执行以下操作:

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
}

这篇关于从MySQL行生成QR代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆