Show Mysql Database image with different 2ids but common PHP field

Asked

Viewed 34 times

0

I have a registration page.php

On this page I have INPUTS to insert Name, CPF, Phone Contact, plus an INPUT File type for the person to put photo of documents and photo of proof of residence.

When Click to send it inserts the information in the database but generates an Id for each image that the person entered is

If CPF 111.111.111-85 entered the Name, CPF, Phone and 2 Images in the BD Mysql inserted this way:

ID: 1 / Photo: Foto1 / Name: ALEX / CPF: 111.111.111-85 / Telephone: xx xxxxxxxxx

ID: 2 / Photo: Foto2 / Name: ALEX / CPF: 111.111.111-85 / Telephone: xx xxxxxxxxx

This inserting correctly in the BD

I have another Page that analyzes the submitted documents called parse_card.php

Where under a query in the Database brings the data grouped by CPF

That is, the presentation on the page does not show the images but shows the data grouped by CPF and stays this way

Name: ALEX / CPF: 111.111.111-85 / Telephone: xx xxxxxxxxxxxx

In this page parse_card.php I have a link <a href='ver-cad-cartao.php?cpf=$res_sql[cpf]' title='Ver'><img src='imagem/bg-view.fw.png'></a> where I step by parameter in the link Cpf to see the complete registration:

My question is : How to make the page view-Cad-cartao.php load the linked images in this Cpf, because the code I made only shows the id 1 image, and not the two id1 and id2 that I want.

Page code see-Cad-card.php

<?php
require_once("../funcoes/conexao.php"); 
$cpf = $_GET['cpf'];

$sql = mysql_query("SELECT * FROM faca_cartao where cpf='$cpf'") or die (mysql_error());  
$res_sql = mysql_fetch_array($sql);{
echo '  
<div>       
<img  src="../cartao/'.$res_sql["document_name"].'" width="300px">
</div>  ';
}
?>

1 answer

0

Você pode fazer assim
$sql = mysql_query("SELECT * FROM faca_cartao where cpf='$cpf'") or die (mysql_error());  

$rowsfound = mysql_num_rows($sql);
if($rowsfound > 0)
{
  $count = 0;
  while($row = mysql_fetch_array($result))
{
echo '  
<div>       
  <img  src="../cartao/'.$row[$count]["document_name"].'" width="300px">
</div>  ';
$count++;
}
}
  • I tried but now the first image doesn’t even appear

Browser other questions tagged

You are not signed in. Login or sign up in order to post.