I am trying to post pictures in a joomla page. I am completely new in php and joomla.
This is what I have in a joomla page:
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
<p>Some more text.</p>
<p><img src="images/test.php?id=8" alt="powered by" />
</p>
<p>Done!</p>
this is test.php:
<?php
$link=...... //connection to database
if(isset($_GET['id']))
{
$id = mysql_real_escape_string($_GET['id']);
$query=...
$result=mysqli_query($link,$query);
while($row=mysqli_fetch_array($result)) {
$imageData = $row['photo'];
}
header("content-type: image/png");
echo $imageData;
}
?>
This is just for a simple 1 photo print, I eventually want to print multiple photos, and have like a slideshow.
Is this possible using joomla?
I also tried several other ways, but I had no luck. Is it possible to have ?
I just need a way through loop through images that are in a database, and print them out. Is there a good approach to this than what I am taking? Do I have to install plugins?
This is a completely wrong approach.
You have to develop a custom module to handle your slideshow task. You could start here.
As for your current code you have to convert it to:
<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__helloworld'))
->where('id = '. $db->Quote($params));
$db->setQuery($query);
$results = $db->loadObjectList();
print_r($results);
?>
Please check the full list of joomla database functions.
This part will help you how you could display your results.
Good Luck!