I hope someone can help me with this?
I have a Joomla installation running and the website looks and works great.
Here’s the problem, the website is for a car dealership, which means they need to display a list of their stock on the floor.
They are using a custom system to manage their stock and this system saves the data to a MS Access database.
I got it to work to a point where I can display a table from the database. (http://www.autodeal.co.za/newsite/used-car-sales-south-africa).
Now when someone clicks on the model, which is a link that will take them to another page which displays only the information relevant to the selected model.
That’s what I can’t figure out. The link works fine and it takes me to the page that I want, but it doesn’t display the data like it’s supposed to.
Please see the code below for connecting to the database and displaying the results:
<?php $dbName = "F:/Domains/autodeal/autodeal.co.za/wwwroot/newsite/db/savvyautoweb.mdb"; // Throws an error if the database cannot be found if (!file_exists($dbName)) { die("Could not find database file."); } // Connects to the database // Assumes there is no username or password $conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$dbName", '', ''); // This is the query // You have to have each column you select in the format tableName.[ColumnName] $sql = "SELECT Make, Model, Year, Price, SpecialPrice, Branch, StockNO FROM Vehicle ORDER BY Make"; // Runs the query above in the table $rs = odbc_exec($conn, $sql); echo "\t" . "Please see the code below to display a specific vehicle information from the table based on a selection made from the above script.
<?php $dbName = "F:/Domains/autodeal/autodeal.co.za/wwwroot/newsite/db/savvyautoweb.mdb"; // Throws an error if the database cannot be found if (!file_exists($dbName)) { die("Could not find database file."); } // Connects to the database // Assumes there is no username or password $conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$dbName", '', ''); // This is the query // You have to have each column you select in the format tableName.[ColumnName] $selected_id = intval($_GET['Id']); $sql = "SELECT Id, Make, Model, Year, Price, SpecialPrice, Branch, StockNO, MainPic FROM Vehicle WHERE Id = Id"; // Runs the query above in the table $rs = odbc_exec($conn, $sql); $id = odbc_result($rs, Id); $make = odbc_result($rs, Make); $model = odbc_result($rs, Model); echo $make; echo $model; $image_path_main = "EDIT So I’ve updated the above code based an answer received, but the individual records aren’t displayed. I printed a test line and that works fine, so that tells me that there’s an issue with the query? The thing is, the query works fine to display all the records in a table, but I need to display a single record when that record has been clicked.
Furthermore, the $mainPic variable above is referencing the image name from the database. The actual image isn’t saved in the database; it’s in a different location. I assume I need to create a variable with the actual path of the image and use the reference variables above to display the image, but it’s not working.
So to recap, I need some help displaying all information from the database based on a selection.
For example: in the table, I select 323i. On a new page, I need to display all the information that’s in the database about the 323i on a new page.
Is that doable and if so, could anyone please assist me in this matter.
Thank you very much in advance.