Hi, the following code generates a table with 4 columns displaying the counties in England from an array. i was using a mysql_num check against my database to display any records against that given county.
I wish to display a random number between brackets so that the display looks populated. I am using a random number generator to produce a 4 digit number which displays the same number in all counties(till refresh)
<?php
function generate_id($length = 4)
{
$range = '1234567890';
$max = strlen($range) - 1;
// Generates random id of length $length.
$id = '';
for ($count = 0; $count < $length; $count++)
{
$id .= $range[rand(0, $max)];
}
return $id;
}
$randpass = generate_id();
$numr = $randpass;
$counties="Bedfordshire,Berkshire,Bristol,Buckinghamshire,Cambridgeshire,Cheshire,Cleveland,Cornwall,County Durham,Cumbria,Derbyshire,Devon,Dorset,East Yorkshire,East Sussex,Essex,Gloucestershire,Greater London,Greater Manchester,Hampshire,Herefordshire,Hertfordshire,kent,Lancashire,Leicestershire,Lincolnshire,Merseyside,Norfolk,North Yorkshire,Northamptonshire,Northumberland,Nottinghamshire,Oxfordshire,Rutland,Shropshire,Somerset,South Yorkshire,Staffordshire,Suffolk,Surrey,Tyne and Wear,Warwickshire,West Midlands,West Sussex,West Yorkshire,Wiltshire,Worcestershire";
$countiesArray= explode(",", $counties);
$countiesArray = array_diff($countiesArray, array(""));
for($item=0;$item<count($countiesArray);$item++){
if($counter != 0 and $counter % 4 == 0)
{
echo "</tr>\n<tr>";
}
$counter++;
echo "<td width='25%'><img src='images/freelisting_arrow2.gif'> <a href='' class='menu' title='No Link On the Demo page'><font size='1' face='Verdana'>". $countiesArray[$item] . " ( <font size='1' face='Verdana' style='color: $color'>" .$numr . " </font>)</a></font></td>";
}
echo "<tr><td height='7'></td></tr>";
echo "</tr>\n</table>\n";
?>
I just cannot think how to get the results separated,
any advice will be greatly appreciated
roscor