 |
ช่วยผมด้วยครับคิดมา3วันล่ะลองยังไงก็ไม่ถูก การเก็บค่าจาก textfild แบบวนลูป ครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
/*
* PHP QR Code encoder
*
* Exemplatory usage
*
* PHP QR Code is distributed under LGPL 3
* Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//set it to writable location, a place for temp generated PNG files
$PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR;
//html PNG location prefix
$PNG_WEB_DIR = 'temp/';
include "qrlib.php";
//ofcourse we need rights to create temp dir
if (!file_exists($PNG_TEMP_DIR))
mkdir($PNG_TEMP_DIR);
$filename = $PNG_TEMP_DIR.'point.png';
//processing form input
//remember to sanitize user input in real-life solution !!!
$errorCorrectionLevel = 'L';
if (isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L','M','Q','H')))
$errorCorrectionLevel = $_REQUEST['level'];
$matrixPointSize = 4;
if (isset($_REQUEST['size']))
$matrixPointSize = min(max((int)$_REQUEST['size'], 1), 10);
if (isset($_REQUEST['data'])) {
//it's very important!
if (trim($_REQUEST['data']) == '')
die('data cannot be empty! <a href="?">back</a>');
// user data
$filename = $PNG_TEMP_DIR.'point'.md5($_REQUEST['data'].'|'.$errorCorrectionLevel.'|'.$matrixPointSize).'.png';
QRcode::png($_REQUEST['data'], $filename, $errorCorrectionLevel, $matrixPointSize, 2);
} else {
//default data
QRcode::png('PHP QR Code :)', $filename, $errorCorrectionLevel, $matrixPointSize, 2);
}
//display generated file
echo '';
?>
<form action="qr.php" method="post">
<table width="302" height="291" border="1" align="center" bgcolor="#9933FF">
<tr>
<td colspan="3">สร้าง QR Code</td>
</tr>
<tr>
<td width="125">เลือกสินค้า</td>
<td width="161" colspan="2"><select name="select2" id="select2">
</select></td>
</tr>
<tr>
<td>ระบุคะแนน</td>
<td colspan="2"><select name="select3" id="select3">
</select>
แต้ม </td>
</tr>
<tr>
<td>ระบุจำนวน</td>
<td colspan="2"><label>
<input name="textfield3" type="text" id="textfield3" size="15" />
ชิ้น</label></td>
</tr>
<tr>
<td>Parth</td>
<td colspan="2">
<?
$qr_loop="http://www.google.com?test=";
//config form
for($a=0;$a<=5;$a++){
$qrtest=$qr_loop.$a;
?>
<input name="data" value="<? echo $qrtest;?>" width="100px"/> //ตรงนี้เลยครับเวลาsubmitมันเก็บแต่ตัวสุดท้ายครับคือ http://www.google.com?test=5 ส่วน 01234 ทำไมไม่เก็บ ผมต้องการให้เก็บหมดเลยครับ เป็นการสร้างภาพQR code
ผมอยากให้มันออกมา 5 ภาพ แต่ละภาพก็มี url http://www.google.com?test=1 ถึง http://www.google.com?test=5
ช่วยผมทีตันจิงๆๆแนะก็ได้ตัวอย่างยิ่งดีครับ
<?
}
?>
</td>
</tr>
<tr>
<td>เลือกขนาด</td>
<td colspan="2">
<select name="size">
<?
for($i=1;$i<=10;$i++)
echo '
<option value="'.$i.'"'.(($matrixPointSize==$i)?' selected="selected"':'').'>'.$i.'</option>
';
echo '
</select> เซนติเมตร </td>
</tr>
<tr>
<td>เลือกความละเอียด</td>
<td colspan="2"><select name="level">
<option value="L"'.(($errorCorrectionLevel=='L')?' selected="selected"':'').'>L - smallest</option>
<option value="M"'.(($errorCorrectionLevel=='M')?' selected="selected"':'').'>M</option>
<option value="Q"'.(($errorCorrectionLevel=='Q')?' selected="selected"':'').'>Q</option>
<option value="H"'.(($errorCorrectionLevel=='H')?' selected="selected"':'').'>H - best</option>
</select> พิกเซล</td>
</tr>
<tr>
<td height="51" colspan="3" align="center"><label>
<input type="image" name="imageField" id="imageField" src="phpqrcode/image/save_button.png" />
</label></td>
</tr>
</table>
<p> </p>
<p> </p>
</form>';
?>

เวลาคลิกบันทึกแล้วอยากให้ได้QR code เท่ากับจนวนtexfildเลยครับ ขอบคุณที่ช่วยเหลือผม
Tag : PHP, HTML/CSS
|
ประวัติการแก้ไข 2012-01-08 23:15:46
|
 |
 |
 |
 |
Date :
2012-01-08 23:14:16 |
By :
gmgo |
View :
931 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ในบทความก็มีครับ
Code (PHP)
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
for($i=1;$i<=$_POST["hdnLine"];$i++)
{
if($_POST["txtCustomerID$i"] != "")
{
$strSQL = "INSERT INTO customer ";
$strSQL .="(CustomerID,Name,Email,CountryCode,Budget,Used) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtCustomerID$i"]."','".$_POST["txtName$i"]."', ";
$strSQL .="'".$_POST["txtEmail$i"]."' ";
$strSQL .=",'".$_POST["txtCountryCode$i"]."','".$_POST["txtBudget$i"]."', ";
$strSQL .="'".$_POST["txtUsed$i"]."') ";
$objQuery = mysql_query($strSQL);
}
}
echo "Save Done. Click <a href='phpMySQLListRecord.php'>here</a> to view.";
mysql_close($objConnect);
?>
Go to : PHP MySQL Add/Insert Multiple Record
|
 |
 |
 |
 |
Date :
2012-01-09 06:52:48 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ครับพี่วินขอบคุณมากผมลองเสริทดูในเว็บแล้วครับแต่ไม่เจอบังเอิญว่าไม่รู้หัวข้อด้วยครับเลยไม่รู้จะค้นคำว่าอะไรต้องขอบคุณมากที่ช่วยนะครับ
|
 |
 |
 |
 |
Date :
2012-01-09 09:45:40 |
By :
gmgo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|