On my old website built in PHP, I had a link on a page which picked an ID based on what line was clicked.
<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 .'">
I just cannot figure out how to write the code on that page, so it can populate the table based on that id.
The current code that 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 doesn't seem to be working.
This is my first question here, so I hope I get clear and easy to understand support.
My goal is to have one "article template" page called "package" which 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()
redsands_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