Hello to all again.
I asked the same question again in the past but i did not manage to find any solutions yet.
I will post the file with the variables i am using now and what i need is to loop from 1 to 15 for fields make, typeof vehicle and fetures and load them in a variable name "$make_category number here" , "$typeofvehicle_category number here" and "$features_category number here". Please take a look and advice but please don't mention to use arrays. I can't.
Thank you.
<?php
include 'settings.php';
$con = mysql_connect($localhost,$username,$password);
mysql_select_db($database, $con);
// <!-- ==================================================================================================== -->
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM make where catid = 1");
while($r = mysql_fetch_assoc($results))
{
$make_car.= "<option value='$r[id]'>$r[name]</option>";
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM make where catid = 2");
while($r = mysql_fetch_assoc($results))
{
$make_bike.= "<option value='$r[id]'>$r[name]</option>";
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM make where catid = 3");
while($r = mysql_fetch_assoc($results))
{
$make_van.= "<option value='$r[id]'>$r[name]</option>";
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM make where catid = 4");
while($r = mysql_fetch_assoc($results))
{
$make_truck.= "<option value='$r[id]'>$r[name]</option>";
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
// <!-- ==================================================================================================== -->
$results = mysql_query("SELECT * FROM typeofvehicle where catid = 1");
while($r = mysql_fetch_assoc($results))
{
$typeofvehicle_car.= "<option value='$r[id]'>$r[name]</option>";
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM typeofvehicle where catid = 2");
while($r = mysql_fetch_assoc($results))
{
$typeofvehicle_bike.= "<option value='$r[id]'>$r[name]</option>";
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM typeofvehicle where catid = 3");
while($r = mysql_fetch_assoc($results))
{
$typeofvehicle_van.= "<option value='$r[id]'>$r[name]</option>";
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM typeofvehicle where catid = 4");
while($r = mysql_fetch_assoc($results))
{
$typeofvehicle_truck.= "<option value='$r[id]'>$r[name]</option>";
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
// <!-- ==================================================================================================== -->
$results = mysql_query("SELECT * FROM doors");
while($r = mysql_fetch_assoc($results))
{
$doors.= "<option value='$r[id]'>$r[name]</option>";
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM gearbox");
while($r = mysql_fetch_assoc($results))
{
$gearbox.= "<option value='$r[id]'>$r[name]</option>";
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$fueltype.= "<option>Πετρέλαιο</option>";
$fueltype.= "<option>Βενζίνη</option>";
$fueltype.= "<option>Αέριο</option>";
$fueltype.= "<option>Ηλεκτρικό</option>";
$fueltype.= "<option>Υδρογόνο</option>";
$fueltype.= "<option>Υβριδικό</option>";
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM extcolor");
while($r = mysql_fetch_assoc($results))
{
$extcolor.= "<option value='$r[id]'>$r[name]</option>";
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM climaticcontrol");
while($r = mysql_fetch_assoc($results))
{
$climaticcontrol.= "<option value='$r[id]'>$r[name]</option>";
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$i=0;
while($i <= 5000)
{
$liter.= "<option value='$i'>$i</option>";
$i = $i+100;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$i=2012;
while($i >= 1990)
{
$year.= "<option value='$i'>$i</option>";
$i = $i-1;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$i=0;
while($i <= 1000000)
{
$miles.= "<option value='$i'>$i</option>";
$i = $i+500;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$i=0;
while($i <= 200000)
{
$price.= "<option value='$i'>$i</option>";
$i = $i+500;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$i=0;
while($i <= 500)
{
$power.= "<option value='$i'>$i</option>";
$i = $i+10;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 1");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_car_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_car_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_car_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 2");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_bike_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_bike_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_bike_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 3");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_van_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_van_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_van_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 4");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_truck_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_truck_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_truck_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 5");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_bus_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_bus_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_bus_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 6");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_6_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_6_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_6_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 7");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_7_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_7_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_7_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 8");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_8_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_8_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_8_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 9");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_9_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_9_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_9_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 10");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_10_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_10_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_10_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 11");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_11_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_11_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_11_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 12");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_12_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_12_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_12_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 13");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_13_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_13_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_13_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 14");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_14_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_14_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_14_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
// <!-- ---------------------------------------------------------------------------------------------------- -->
$results = mysql_query("SELECT * FROM features where catid = 15");
$num_rows = mysql_num_rows($results);
$ii = $num_rows/3;
$ii = round($ii, 0, PHP_ROUND_HALF_UP);
$i = 1;
while($r = mysql_fetch_assoc($results))
{
if ($i > 00 && $i <= $ii){$features_15_1.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii && $i <= $ii*2){$features_15_2.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
if ($i > $ii*2 && $i <= $ii*3){$features_15_3.= "<input type='checkbox' name='features($r[id])' value='1' />$r[name] </br>";}
$i++;
}
mysql_close();
?>