I'm stuck on a code to insert an image in php/html

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
pasbonte
Veteran Member
Posts: 162
Joined: 2013-02-06 09:49

I'm stuck on a code to insert an image in php/html

Post by pasbonte » 2023-01-19 09:00

Hello

I'm stuck on a code to insert an image in php/html

This image is stored in my application of course.


<td style="width: 23.7235%; height: 18px; text-align: left;" colspan="3"><?php echo sqlValue("select NUM_NAT from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
??????????? echo '<img src="images/globe.gif" border="0" /></div> ';

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: I'm stuck on a code to insert an image in php/html

Post by jsetzer » 2023-01-19 10:08

Code: Select all

<td style="width: 23.7235%; height: 18px; text-align: left;" colspan="3">

    <!-- PHP code starts here -->
    <?= sqlValue("select NUM_NAT from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?>
    <!-- PHP code ends here -->

    <img src="images/globe.gif" border="0" />
</td>
PS: In your code there is a closing <div/> without a start-tag. I have removed it.

PPS: for better readability, please use [code]...[/code] in your forum posts.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

pasbonte
Veteran Member
Posts: 162
Joined: 2013-02-06 09:49

Re: I'm stuck on a code to insert an image in php/html

Post by pasbonte » 2023-01-19 15:16

Not easy with the language barrier.. I want to display my image saved in my APPGINI database, it's a downloaded image, I can't find how to associate the image with the link in PHP, I attach a copy file of screen to be clearer.
I send a message by email as soon as a recording is modified, but I want it to be the photo of the student and not the name of the photo file...
Capture d’écran 2023-01-19 161407.png
Capture d’écran 2023-01-19 161407.png (23.77 KiB) Viewed 2038 times

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: I'm stuck on a code to insert an image in php/html

Post by jsetzer » 2023-01-19 15:24

On media tab, did you configure the field as image field?

See paragraph "The Image option" in the docs:
https://bigprof.com/appgini/help/workin ... /media-tab

If so, display of uploaded images should work out of the box.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

pasbonte
Veteran Member
Posts: 162
Joined: 2013-02-06 09:49

Re: I'm stuck on a code to insert an image in php/html

Post by pasbonte » 2023-01-19 15:32

the screenshot that I attached is the copy of an EMAIL that I send, so it is in my EMAIL code that it is wrong.

voici mon code en entier :

Code: Select all

function GES_VOEUX_after_update($data, $memberInfo, &$args) {

/////// DEBUT ENVOI
		ob_start(); ?>
<h3>IMPORTANT -----> MODIFICATION FICHE DE VOEUX :</h3>
<hr>
		<BR>
		<BR>
		
<table style="border-collapse: collapse; width: 99.6457%; height: 530px;" border="1">
	<tbody>
		<tr style="height: 18px;">
			<td style="width: 27.4765%; height: 18px;">Num&eacute;ro ID</td>
			<td style="width: 73.0949%; height: 18px; text-align: left;" colspan="3"><?php echo $data['id']; ?></td>
		</tr>
		<tr style="height: 18px;">
			<td style="width: 27.4765%; height: 18px;">EMAIL</td>
			<td style="width: 73.0949%; height: 18px; text-align: left;" colspan="3"><?php echo sqlValue("select EMAIL_RESP from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
		</tr>
		<tr style="height: 18px;">
			<td style="width: 27.4765%; height: 18px;">NOM ELEVE</td>
			<td style="width: 23.7235%; height: 18px; text-align: left;" colspan="3"><?php echo sqlValue("select NOM_ELEVE from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
		</tr>
		<tr style="height: 18px;">
			<td style="width: 27.4765%; height: 18px;">PRENOM ELEVE</td>
			<td style="width: 23.7235%; height: 18px; text-align: left;" colspan="3"><?php echo sqlValue("select PRENOM_ELEVE from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
		</tr>
		<tr style="height: 18px;">
			<td style="width: 27.4765%; height: 18px;">PHOTO</td>
			<td style="width: 23.7235%; height: 18px; text-align: left;" colspan="3"><?php echo sqlValue("select NUM_NAT  from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
			echo '<img src="images/globe.gif" border="0" /></div> ';
	
	-------------> HERE !!!!!!!		
			
</td>
		</tr>
		<tr style="height: 18px;">
			<td style="width: 27.4765%; height: 18px;">CLASSE</td>
			<td style="width: 23.7235%; height: 18px; text-align: left;" colspan="3"><?php echo sqlValue("select CLASSE_ELEVE from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
		</tr>
		<tr style="height: 48px; background-color: #fff333;">
			<td style="width: 27.4765%; height: 48px;">PREMIER VOEU PROVISOIRE JANVIER</td>
			<td style="width: 23.7235%; height: 48px;"><?php echo sqlValue("select VOEU1_PRO1 from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
			<td style="width: 13.7143%; height: 48px;"><strong>AVIS DU CONSEIL</strong></td>
			<td style="width: 35.6571%; height: 48px;"><?php echo sqlValue("select AVIS1_PRO1 from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
		</tr>
		<tr style="height: 60px;">
			<td style="width: 27.4765%; height: 60px;">DEUXIEME VOEU PROVISOIRE JANVIER</td>
			<td style="width: 23.7235%; height: 60px;"><?php echo sqlValue("select VOEU2_PRO1 from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
			<td style="width: 13.7143%; height: 60px;"><strong>AVIS DU CONSEIL</strong></td>
			<td style="width: 35.6571%; height: 60px;"><?php echo sqlValue("select AVIS2_PRO1 from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
		</tr>
		<tr style="height: 51px; background-color: #fff333;">
			<td style="width: 27.4765%; height: 51px;">TROISIEME VOEU PROVISOIRE JANVIER</td>
			<td style="width: 23.7235%; height: 51px;"><?php echo sqlValue("select VOEU3_PRO1 from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
			<td style="width: 13.7143%; height: 51px;"><strong>AVIS DU CONSEIL</strong></td>
			<td style="width: 35.6571%; height: 51px;"><?php echo sqlValue("select AVIS3_PRO1 from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
		</tr>
		<tr style="height: 61px;">
			<td style="width: 27.4765%; height: 61px;">QUATRIEME VOEU PROVISOIRE JANVIER</td>
			<td style="width: 23.7235%; height: 61px;"><?php echo sqlValue("select VOEU4_PRO1 from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
			<td style="width: 13.7143%; height: 61px;"><strong>AVIS DU CONSEIL</strong></td>
			<td style="width: 35.6571%; height: 61px;"><?php echo sqlValue("select AVIS4_PRO1 from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
		</tr>		
		<tr style="height: 91px;">
			<td style="width: 27.4765%; height: 91px;">REMARQUES DU CONSEIL DE CLASSE en janvier SUR LES VOEUX</td>
			<td style="width: 73.0949%; height: 91px; text-align: justify;" colspan="3"><?php echo sqlValue("select AVIS_PP1 from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
		</tr>
		<tr style="height: 91px;">
			<td style="width: 27.4765%; height: 91px;">COMPTE-RENDU r&eacute;union d'orientation PP PSY PARENTS</td>
			<td style="width: 73.0949%; height: 91px; text-align: justify;" colspan="3"><?php echo sqlValue("select CR_CONCERTATION from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
		</tr>
		<tr style="height: 129px;">
			<td style="width: 27.4765%; height: 129px;">VOS REMARQUES, notre r&eacute;ponse</td>
			<td style="width: 23.7235%; height: 129px; text-align: justify;" colspan="3"><?php echo sqlValue("select REMARQUE_PARENTS from GES_VOEUX where id='" . makeSafe($data['id']) . "'"); ?></td>
		</tr>
	</tbody>
</table>
<p>&nbsp;</p>
</table>




User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: I'm stuck on a code to insert an image in php/html

Post by jsetzer » 2023-01-23 14:16

I have the feeling there is a general misunderstanding of how AppGini handles views and uses hook functions:

On save, after_update function is executed, then the detail view is (re-)loaded.

I don't think the HTML you are echoing in after_update hook has any effect on the (freshly) loaded detail view. Also, the function looks incomplete, as there are brackets missing after your table and ob_get_clean() etc.. This code should raise errors in IDE and on execution.

If you could describe your aim, maybe someone can help with a different but working approach.

PS:
the screenshot that I attached
maybe I have missed it: I cannot see any screenshot in you previous post.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

pasbonte
Veteran Member
Posts: 162
Joined: 2013-02-06 09:49

Re: I'm stuck on a code to insert an image in php/html

Post by pasbonte » 2023-01-31 14:52

bonjour

Je bloque vraiment sur ce code.

J'ai :

Code: Select all

<?php echo "...";
echo $student; ?>
<img src="data:image/jpeg;base64,<?= base64_encode(file_get_contents("/home/clients/xxxxxxxxxxxxxxxxx/web/PARENTS3/images/{$student}.jpg")) ?>" alt="...">
</td>
ma variable $student me donne bien le nom de la photo

Mon chemin absolu est bien /home/clients/XXXXXXXXXXXXXX/ dixit INFOMANIAK

et pourtant j'ai toujours des vignettes sans la photo
Capture.PNG
Capture.PNG (13.67 KiB) Viewed 1757 times

Post Reply