PDA

View Full Version : Logic Help


m1a2x3x7
01-05-2008, 07:10 PM
So I know how to display output from a database but the help I need is logic behind what I'm wanting to do.

I have a list of counties I want to keep in alphabetical order so when I display it, it looks like this.

A C
A C
A C
A C
B D
B D
B D
B D

Now I can get it to display like this:

A A A A B B B B C C C C

or like this:

A
A
A
A
B
B
B
B
C
C
C
C

But I cant think of the logic behind the way I need it.

Here is the page that has the list of counties in the A A A A B B B C C C order way.

http://69.89.25.187/~tdstoutp/indiana.php (http://69.89.25.187/%7Etdstoutp/indiana.php)

Here is the code.

<?php

ob_start();

//CONNECT TO DATABASE//
require_once("connection.php");

//PULL INFORMATION FROM THE DATABASE//

//INDIANA ZIP CODES//
$queryZipCodeIndiana="SELECT * FROM zip_codes WHERE state = 'Indiana' AND active = '0'";
$resultZipCodeIndiana=mysql_query($queryZipCodeInd iana);
//INDIANA COUNTIES//
$queryCountiesIndiana="SELECT * FROM counties WHERE state = 'Indiana' AND active = '0'";
$resultCountiesIndiana=mysql_query($queryCountiesI ndiana);



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>T.D. Stout Preservation - Property Preservation Specialists, Indiana, Illinois, Kentucky &amp; Ohio</title>


<!-- saved from url=(0014)about:internet -->
<!-- The script to prevent blocking in IE and for other menu maintenance -->
<script src='http://f-source.com/scripts/ActiveContentVertical.js' type='text/javascript'></script>
<!-- Don't rely on our server, download the script, -->
<!-- save it and change the script source path -->
<!-- saved from url=(0014)about:internet -->
<!-- The script to prevent blocking in IE and for other menu maintenance -->
<script src='http://f-source.com/scripts/ActiveContentDropDown.js' type='text/javascript'></script>
<!-- Don't rely on our server, download the script, -->
<!-- save it and change the script source path -->
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//-->
</script>

<script type="text/javascript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>

<link href="css/tdStout.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-color: #e4fae9;
margin-top: 0px;
}
-->
</style>
</head>
<body onload="MM_preloadImages('images/buttonHome2.jpg')">
<table width="840" border="0" align="center" cellpadding="0">

<tr>
<td scope="row"><div align="center">
<table width="840" border="0" align="center" cellpadding="0">
<tr>
<td width="840" valign="top"><div align="center">
<script language="JavaScript">
<!--

/*
Random Image Script- By JavaScript Kit (http://www.javascriptkit.com)
Over 400+ free JavaScripts here!
Keep this notice intact please
*/

function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="/images/TDheader1.jpg"
myimages[2]="/images/TDheader2.jpg"
myimages[3]="/images/TDheader3.jpg"
myimages[4]="/images/TDheader4.jpg"


var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<img src="'+myimages[ry]+'" border=0>')
}
random_imglink()
//-->
</script>
<!-- f-source menu navigation settings (search engine friendly) -->
<!-- Change these links and press F12 to test -->
<div id='menu' style='position:absolute; visibility:hidden;'>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>&lt;b&gt;About US&lt;/b&gt;</a></div>

<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>&lt;b&gt;Home Security&lt;/b&gt;</a></div>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>&lt;b&gt;Heating/AC Services&lt;/b&gt;</a></div>
<div class='submenu'>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>Remove/Install</a></div>
<div><a href='url to pass to JSF' target='callJSF'>Repair</a></div>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>Seasonal Change</a></div>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>Needs Assessed</a></div>
</div>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>&lt;b&gt;Plumbing Services&lt;/b&gt;</a></div>
<div class='submenu'>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>Repairs</a></div>
<div class='submenu'>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>Fix Leak</a></div>

<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>Replace Faucets</a></div>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>Replace Tub/Shower</a></div>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>Fix Sewer Clog</a></div>
</div>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>Install New Faucets</a></div>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>Install Water Softener</a></div>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>Install new Sinks</a></div>
</div>
<div><a href='http://69.89.25.187/~tdstoutp/index.htm'>&lt;b&gt;Yard Care&lt;/b&gt;</a></div>
<div ><a href='http://www.google.com/search?q=' target='_blank'>&lt;b&gt;Contact US&lt;/b&gt;</a></div>
</div>



<div id="f-source-menu" style="position:relative;">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="851" height="38" >
<param name="flash_component" value="BusinessDDMenuFull.swc" />
<param name="movie" value="flash/tdStoutBizMenu.swf" />
<param name="quality" value="high" />
<param name="FlashVars" value="flashlet={_subButtonTextColor:#FFFFFF,_subMenuColo r:#014711,_removeSubDelay:500,_mainButtonHeight:22 ,showSearchField:false,searchFieldWidth:80,_subHig hlightColor:#BBD3B8,_TransparencyShadow:100,search TextColor:#000000,mainSoundURL:'None',_subFont:'Ar ial',_subButtonHeight:20,_menuColor:#344D31,clickS oundURL:'None',_TransparencyMain:100,_removeDivide rs:false,_mainButtonTextColor:#FFFFFF,stretch_widt h_to:'0px',_mainFontSize:10,subSoundURL:'None',bg_ Pic_URL:'None',_minSubWidth:60,_mainFont:'Verdana' ,_mainButWidthExt:28.75,_TransparencySub:95,_mainH ighlightColor:#014711,xml_Path:'None',_subFontSize :10,searchFieldColor:#FFFFFF}" />
<param name="wmode" value="transparent" />
</object>
<noscript>
<object>
<a href="http://69.89.25.187/~tdstoutp/index.htm">TD Stout</a>
</object>
</noscript>
<script type="text/javascript">var connected; if (connected){ Run_f_source_menu() }else{ alert("The page is not connected with script file ActiveContentDropDown.js") };function JSF(url){alert("javascript: "+url);}</script>
</div>
<!-- End of f-source menu code --></div></td>
</tr>

<tr>
<td valign="top"><div align="center">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" scope="row"><div align="center">
<table width="840" border="0" align="left" cellpadding="0">
<tr>
<td colspan="2" valign="top" scope="row"><div align="left"><a href="index.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/buttonHome2.jpg',1)"><img src="images/buttonHome1.jpg" alt="Home" name="Home" width="60" height="13" border="0" id="Home" /></a></div></td>
</tr>
<tr>
<td width="350" valign="top" scope="row"><div align="center">
<table width="350" border="0" align="center" cellpadding="0">
<tr>
<td height="65" scope="row"><div align="center"><img src="images/1Ttrans.gif" alt="" width="1" height="65" /></div></td>
</tr>
<tr>
<td scope="row"><div align="center"><img src="images/indianaCo.gif" alt="Indiana State Map" width="350" height="514" /></div></td>
</tr>
</table>
</div></td>
<td width="490" valign="top"><div align="center">
<table width="490" border="0" cellpadding="0">
<tr>
<td scope="row"><div align="right">
<form name="form" class="Helvetica8pt" id="form">
<span class="helv10ptGreen">View coverage in other states: </span>
<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
<option>-- Select State --</option>
<option value="illinois.php">Illinois</option>
<option value="indiana.php">Indiana</option>
<option value="kentucky.php">Kentucky</option>
<option value="ohio.htm">Ohio</option>
</select>
</form>
</div></td>
</tr>
<tr>
<td height="15" scope="row"><div align="center"><img src="images/1Ttrans.gif" alt="spacer" width="1" height="15" /></div></td>
</tr>
<tr>
<td scope="row"><div align="center"><span class="states">INDIANA</span><br />
<span class="helvBlack16pt">Service area by counties and zip codes</span></div></td>
</tr>
<tr>
<th scope="row"><img src="images/1Tk.gif" alt="spacer" width="365" height="1" /></th>
</tr>
<tr>
<td height="3" scope="row"><div align="center"><img src="images/1Ttrans.gif" alt="spacer" width="1" height="25" /></div></td>
</tr>
<tr>
<td valign="top" scope="row"><div align="center" class="data_iFrame">
<table width="470" border="0" align="center" cellpadding="0">
<tr>
<td scope="row"><div align="left" class="countyHead24ptGreen">
<div align="center">Counties</div>
</div></td>
</tr>
<tr>
<td valign="middle" scope="row"><div align="right"><span class="helv10ptBlack"><a href="INCexcel.php">Export Counties to Excel </a></span><a href="INCexcel.php"><img src="images/excelIcon.jpg" alt="excel" width="20" height="19" border="0" /></a></div></td>
</tr>
<tr>
<td height="6" scope="row"><div align="center"><img src="images/1Ttrans.gif" alt="spacer" width="1" height="6" /></div></td>
</tr>
<tr>
<td scope="row"><?php while($rowINC=mysql_fetch_array($resultCountiesInd iana)){ ?>
<div class="countiesHolder"><?php echo $rowINC['county'];?></div><?php }?>
</td>
</tr>
<tr>
<td height="25" scope="row"><div align="center"><img src="images/1Ttrans.gif" alt="spacer" width="1" height="25" /></div></td>
</tr>
<tr>
<th scope="row"><div align="center"><span class="countyHead24ptGreen">zip codes</span></div></th>
</tr>
<tr>
<td valign="middle" scope="row"><div align="right"><span class="helv10ptBlack"><a href="INZexcel.php">Export Zip Codes to Excel </a></span><a href="illinois.htm"><img src="images/excelIcon.jpg" alt="excel" width="20" height="19" border="0" /></a></div></td>
</tr>
<tr>
<td height="6" scope="row"><div align="center"><img src="images/1Ttrans.gif" alt="spacer" width="1" height="6" /></div></td>
</tr>
<tr>
<th scope="row"><?php while($rowINZ=mysql_fetch_array($resultZipCodeIndi ana)){ ?>
<div class="zipCodeHolder"><?php echo $rowINZ['zip_code'];?></div><?php }?></th>
</tr>
</table>
</div>
<div align="center"></div></td>
</tr>
</table>
</div>
<div align="center"></div></td>
</tr>
</table>
</div></td>
</tr>
</table>
</div></td>
</tr>

<tr>
<td width="840" height="26" valign="top"><div align="center">
<table width="840" border="0" cellpadding="0">

<tr>
<td height="15" scope="row"><div align="center"><img src="images/1Ttrans.gif" alt="spacer" width="1" height="15" /></div></td>
</tr>
<tr>
<td scope="row"><div align="center"><img src="images/bottomBar.jpg" width="840" height="8" /></div></td>
</tr>
<tr>
<td scope="row"><div align="left">
<SCRIPT LANGUAGE="JavaScript">
<!--

//Script created by Ronny Drappier, http://sipreal.com
//Visit http://javascriptkit.com for this script

today=new Date();
y0=today.getFullYear();

// end hiding --->
</SCRIPT>

<span class="copyright">Copyright
<SCRIPT LANGUAGE="JavaScript">
<!--- Hide from old browsers
document.write(y0);
// end hiding --->
</SCRIPT>
T.D. Stout Preservation</span></div></td>
</tr>
</table>
</div></td>
</tr>
</table>
</div></td>
</tr>
</table>
<!-- Start of StatCounter Code -->
<script type="text/javascript">
var sc_project=3245120;
var sc_invisible=0;
var sc_partition=35;
var sc_security="b36a9128";
</script>

<script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a class="statcounter" href="http://www.statcounter.com/"><img class="statcounter" src="http://c36.statcounter.com/3245120/0/b36a9128/0/" alt="screen resolution stats" /></a></div></noscript>
<!-- End of StatCounter Code -->
</body>
</html>

I applicate the help.

davidj
01-05-2008, 07:49 PM
just to clarify

you want to double up the columns after they reach a certain count on the vertical axis

m1a2x3x7
01-05-2008, 07:58 PM
I would like it to go up to 3 columns

davidj
01-05-2008, 08:08 PM
is the count fixed or dynamic

m1a2x3x7
01-05-2008, 09:04 PM
I'm not 100% sure what you mean by that but I want to say dynamic.

davidj
01-05-2008, 09:55 PM
because the way tables work its easier to produce the following results

aaaabbbb
cccccddd
eeeeeeee
eefffffffff
ggg

is this acceptable

if not it can be done the way you want it but its going to be tricky

you will have to produce a div around each result then assign each div an incrementing numerical id or class. You can then create a CSS style sheet with say more styles then there will ever be results say 100 which will position each div matrix style

does this make sense

feel free to skype me if you need a better explanation

m1a2x3x7
01-05-2008, 10:27 PM
yeah i have a way in my head to do it with css but i was wanting a second opion on it to see if there might be a different/easier way.

Thanks for the help.