Home>

Please lend me your help.

Assumptions

I create a circle member management site using PHP, JAVAScript, and MySQL.
On the circle member list page
I wanted to display a part of my personal information (ID, name, place of birth, etc.) with a QR code

of the method you asked and taught the other day <img src ="http: //chart.apis.google.com/chart? cht = qr&chs = 150x150&chl =<? = $value ['personal_id']?>,< ;? = $value ['name']?>,<? = $value ['last_name'], $value ['first_name']?>">
Created a QR code that acquired information from the database.

When there is one person's data on the page
I was able to get personal information from the database in QR code,
If there are multiple people, trying to get the ID and name in the QR code
Only the data of the person with the largest ID has been stored in the QR code.

Name ID
A-san 001

QR code

At this time, when reading with a QR code reader
"Mr. A, 001"

Name ID
A-san 001
B-san 002

QR code

If there are multiple people such as

, the QR code is
"Bsan, 002"
As shown, only the information of Mr. B with a large ID has been stored in the QR code.

Name ID QR
A-san001
B-san 002
C-san 003

is displayed as a table, and the QR code stores the name and ID of each individual from the database
I want to be able to see my name and ID when I read it with a QR code reader.

Applicable source code

Currently, the name and ID are obtained from the database using the following code.

Get data
$QR_body = '';
foreach ($members as $key =&gt;$value) {
    $assignment_id = getAssignmentId ($value ['personal_id'], $corp_id);
    $QR_body. = '&lt;td&gt;'. H ($value ['personal_id']). '&lt;/td&gt;';
    $QR_body. = '&lt;td&gt;'. H ($value ['last_name']). ''. H ($value ['first_name']). '&lt;/td&gt;';
    $QR_body. = '&lt;/tr&gt;';
}


Here is displayed as a table on the screen.

Data display
&lt;div&gt;
    &lt;table cellspacing = "0" width = "100%"&gt;
        &lt;thead&gt;
            &lt;tr&gt;
                &lt;th&gt;ID&lt;/th&gt;
                &lt;th&gt;Name&lt;/th&gt;
                &lt;th&gt;QR code&lt;/th&gt;
            &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
            &lt;? php echo $QR_body;?&gt;
        &lt;/tbody&gt;
    &lt;/table&gt;
&lt;/div&gt;
Tried
$QR_body = '';
foreach ($members as $key =&gt;$value) {
    $assignment_id = getAssignmentId ($value ['personal_id'], $corp_id);
    $QR_body. = '&lt;td&gt;'. H ($value ['personal_id']). '&lt;/td&gt;';
    $QR_body. = '&lt;td&gt;'. H ($value ['last_name']). ''. H ($value ['first_name']). '&lt;/td&gt;';
    $QR_body. = '&lt;/tr&gt;';
}
$QR_body. = '&lt;td&gt;'.&lt;img src = "http://chart.apis.google.com/chart?cht=qr&amp;chs= 150x150&amp;chl =&lt;? = $Value ['personal_id']?&gt;,&lt;? = $Value ['name']?&gt;,&lt;? = $Value ['last_name'], $value [' first_name ']?&gt;"&gt;


The following error message was displayed.

Error message
Parse error: syntax error, unexpected '&lt;' in C: \ xampp \ htdocs \ one-japan \ view \ users \ users_list_content.php on line 58


A parsing error has occurred.
What should I do to improve it?

Isn't it possible to get the ID and name from the database in the table and display the QR code?
Thanks for your consideration.

  • Answer # 1

    Is it like this?
    I don't need to use implode, but I thought it was easy to see.
    </td>is missing.

    $QR_body. = '<td><img src = "http://chart.apis.google.com/chart?cht=qr&chs=150x150&chl = '. implode (array ($value [' personal_id '], $value [' name '], $value [' last_name '], $value [' first_name ']),', ').' "></td>';

  • Answer # 2

    // $QR_body. ='<td>'.<img src = "http: //chart.apis.google.com/chart?cht=qr&chs=150x150&chl=<?=$value['personal_id']?>,<?=$value['name']?> ;,<? = $value ['last_name'], $value ['first_name']?>">
    // ↓ ↓
       $QR_body. = '<td>'. '<img src = "http://chart.apis.google.com/chart?cht=qr&chs=150x150&chl='.$value['personal_id' ]. ','. $value ['name']. ','. $value ['last_name']. ','. $value ['first_name']. '">';

Related articles