On my old website, built in php i had a link on a page, wich picked an ID based on what line it was.
<td width=124><a href="tp/package.php?ID=<?php echo $row[0];?>">Package</a></td>
When the link was pressed, it brought that ID with it, and helped populate the next page (package.php) with values from mysql based on that ID.
Like:
$query = "SELECT * FROM `TABLE_NAME` WHERE `ID`='" . $id . "'";
Now i am trying to do the same in Joomla. I have the link ready
echo '<td class="first"><a href="index.php/package?ID='. $row->ID .'">
But i cannot figure out how to write the code on that page, so it can populate the table based on that.
My current code i am experimenting with on the package-page:
$option = array();
$option['driver'] = 'mysql';
$option['host'] = 'HOST';
$option['user'] = 'USER';
$option['password'] = 'PASSWORD';
$option['database'] = 'DATABASE';
$option['prefix'] = '';
$db = JDatabaseDriver::getInstance($option);
$query = $db->getQuery(true);
$query->select($db->quoteName(array('ID', 'DESCRIPTION', 'MGRS')));
$query->from($db->quoteName('redsands_strike'));
$query = "SELECT * FROM `redsands_strike` WHERE `ID`='" . $id . "'";
$db->setQuery($query);$results = $db->loadObjectList();
while($row = mysqli_fetch_array($result)){
echo "<table id='customers' >";
echo "<tr>";
echo "<th>T/ID#:</th>";
echo "<th>" . $row['ID'] . "</th>";
echo "</tr>";
echo "<tr>";
echo "<th>Description:</th>";
echo "<td>" . $row['DESCRIPTION'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>MGRS:</th>";
echo "<td>" . $row['MGRS'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>LL DDM:</th>";
echo "<td>" . $row['DDM'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>LL DMS:</th>";
echo "<td>" . $row['DMS'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Altitude:</th>";
echo "<td>" . $row['ALT'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Recon images:</th>";
echo '<td><img src="/tp/'. $row['ID'] .'_a.jpg"/><br><br><img src="/tp/'. $row['ID'] .'_b.jpg"/></td>';
echo "</tr>";
}
echo "</table>";
But this doesnt seem to be working.
My first question here, so i hope i got it clear and easy to understand.
My goal is to have one "article template" page called package, wich will pull the proper information based on the ID given from URL that is brought by pressing the link from the page before
$query = "SELECT * FROM `redsands_strike` WHERE `ID`='" . $id . "'";
will be overwriting the three previous lines (rendering them useless). What are you getting fromJFactory::getApplication()->enqueueMessage('id = ' . $id, 'notice');
? Telling us that something doesnt seem to be working is not terribly articulate information. Please better describe how your code is not working. You see no page output? Missing output, errors in your error log? White screen of death? You need to be iterating$results
not callingmysqli_fetch_array()
– mickmackusa♦ Nov 30 at 11:03redsands_strike
WHEREID
='" . $id . "'"; That last part: WHEREID
='" . $id . " selected the information to load based on ID that was in the URL: package.php?ID=114917376 – Frosties82 Nov 30 at 15:20