Forum Moderators: coopster
I have been sitting on this problem or some time. I have Autoboss v1.0 which is for the Autotrade.
The problem I have is that the globals.php include file currently has two arrays() defined ($cset and $mset)
These are for Catogorys and Models.
I have created additional tables in the database to hold an updatable list for both, and created additional admin pages to do this, and everything works fine.
My problem is that no matter how many different ways I try I cannot seem to create the array from a MySQL result.
It would be greatly appreciated if someone could take a look at the $cset() array example I have put into the globals.php include and see where I am going wrong.
The globals.php file is then called by index.php to do the maths and ideally should create a dynamic dropdown but doesnt...
(N.B. i commented out the original $cset array so you can see how it's put together...)
<?
// make elements for make drop down menu
mysql_select_db($database_cnx, $cnx);
$qcat = "SELECT Type FROM cat ORDER BY Type ASC";
$cat=mysql_query($qcat, $cnx);
while($cat = mysql_fetch_assoc($qcat)) //take all results
{
$cset[] = array($dbres['Type']);//No ' around variable.
}
$mset = array('Acura','Aston Martin','Audi','BMW','Citroen','Chrysler','Daewoo',
'Ford','Honda','Hummer','Hyundai','Isuzu','Jaguar','Jeep','Kia','LandRover','Lexus',
'Mazda','Mercedes-Benz','Mini','Mitsubishi','Nissan','Porsche','Saab','Subaru',
'Suzuki','Toyota','Volkswagen','Volvo');
// category elements for category drop down menu
// $cset = array('Small Hatchback','Hatchback','Saloon','Estate','Sports Performance','Commercial','MPVs','Motorbikes');
// number of vehicle to show per page
$perpage = 5;
// number of page links to show at a time
$numlinks = 10;
// thumbnail dimensions
$maxx = 80;
$maxy = 70;
?>
<?php
mysql_free_result($cat);
?>
[edited by: dreamcatcher at 5:06 pm (utc) on May 22, 2007]
[edit reason] no urls as per T.O.S [webmasterworld.com].Thanks [/edit]
$cat=mysql_query($qcat, $cnx);while($cat = mysql_fetch_assoc($qcat)) //take all results
{
$cset[] = array($dbres['Type']);//No ' around variable.
}
while($dbres = mysql_fetch_assoc($cat)) //take all results
{
$cset[] = $dbres['Type'];//No ' around variable.
}
Ive rewritten the code as follows (hopefully a little easier to follow) in an attempt to overcome the problem, I have the correct number of results in the dropdows but no text just empty options...
and thanks for the help and prompt reply...
------------------------------------------------
mysql_select_db($database_cnx, $cnx);
$qcat = "SELECT * FROM cat ORDER BY Type ASC";
$cat = mysql_query($qcat, $cnx) or die(mysql_error());
while($row_cat = mysql_fetch_assoc($cat))
{
$cset[] = $row_cat['type'];
}