Hi
If any mysql gurus out there could please give me some suggestions on this, it would make my week.
I have a results list of church locations (cities) from 1 region (country) that prints in 1 long column and I need to explode it into 2 or more columns...
The 2 tables I am using are "region_master" and "location_master"
here is the current working code that prints the list of cities in 1 column
<?
session_start();
$regionid=$HTTP_SESSION_VARS["regionid"];
$categoryname = $_GET["categoryid"];
$categoryheadname = $_GET["categoryhead"];
$regionname = $_GET["regionid"];
$regsel="select * from region_master where region_name='$regionname'";
$regres=mysql_query($regsel);
$regrow=mysql_fetch_array($regres);
$regid=$regrow['region_id'];
require 'connect.inc';
?>
<table border=0 cellpadding=4 cellspacing=0>
<?
$sql = "select * from location_master where region_id = $regid";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo "<tr><td><a href=churchcity.php?categoryhead=".urlencode($categoryheadname)."&categoryid=".urlencode($categoryname)."®ionid=".urlencode($regionname)."&locationid=".urlencode($row["location_name"]).">".$row["location_name"]."</a></td></tr>";
}
?>
</table>
a friend suggested this explode below but it didn't work
$resultset = select * from location_master
$recordcount = count($resultset);
// output for the left column of the table here
for($i=0;$i<=$recordcount/2;$i++)
{
print $resultset[$j]['city'];
}
// output for the right column of the table here
// then here continues the listing
// (because $j continues where $i left off
for($j=$i;$j<=$recordcount;$J++)
{
print $resultset[$j]['city'];
}
Here is the page with 2 columns... currently showing the same query in both columns...
<?
session_start();
$regionid=$HTTP_SESSION_VARS["regionid"];
$categoryname = $_GET["categoryid"];
$categoryheadname = $_GET["categoryhead"];
$regionname = $_GET["regionid"];
$regsel="select * from region_master where region_name='$regionname'";
$regres=mysql_query($regsel);
$regrow=mysql_fetch_array($regres);
$regid=$regrow['region_id'];
require 'connect.inc';
?>
<table border=0 cellpadding=4 cellspacing=0>
</table>
<table width="60%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="ebe9e9">
<tr>
<td width="50%"> <div align="center">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="ebe9e9">
<tr>
<td> <div align="center">
<?
$sql = "select * from location_master where region_id = $regid";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo "<tr><td><a href=churchcity.php?categoryhead=".urlencode($categoryheadname)."&categoryid=".urlencode($categoryname)."®ionid=".urlencode($regionname)."&locationid=".urlencode($row["location_name"]).">".$row["location_name"]."</a></td></tr>";
}
?>
</div>
<div align="center"> </div></td>
</tr>
</table>
</div></td>
<td width="50%"> <div align="right"></div>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="ebe9e9">
<tr>
<td> <div align="center">
<?
$sql = "select * from location_master where region_id = $regid";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo "<tr><td><a href=churchcity.php?categoryhead=".urlencode($categoryheadname)."&categoryid=".urlencode($categoryname)."®ionid=".urlencode($regionname)."&locationid=".urlencode($row["location_name"]).">".$row["location_name"]."</a></td></tr>";
}
?>
</div>
<div align="center"> </div></td>
</tr>
</table>
<div align="right"></div></td>
</tr>
</table>
Thanks for your suggestions anybody can offer.
Jolanta