Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i set up 2 or 3 column display? 2

Status
Not open for further replies.

deecee

Technical User
Joined
Aug 25, 2001
Messages
1,678
Location
US
I have a site where users click on a brand and it brings up products associated with said brand. I am having trouble tweaking a script to have it show on multiple colums and repeat region. It works fine as one column with a repeating table but i need it expanded.

here is the page and its code......All the php is part of extensions for Dreamweaver

The part in bold is the repeated protion....

<?php require_once('Connections/connCorelist.php'); ?>
<?php
// *** Restrict Access To Page: Grant or deny access to this page
$FF_authorizedUsers=&quot; &quot;;
$FF_authFailedURL=&quot;enter.php&quot;;
$FF_grantAccess=0;
session_start();
if (isset($HTTP_SESSION_VARS[&quot;MM_Username&quot;])) {
if (true || !(isset($HTTP_SESSION_VARS[&quot;MM_UserAuthorization&quot;])) || $HTTP_SESSION_VARS[&quot;MM_UserAuthorization&quot;]==&quot;&quot; || strpos($FF_authorizedUsers, $HTTP_SESSION_VARS[&quot;MM_UserAuthorization&quot;])) {
$FF_grantAccess = 1;
}
}
if (!$FF_grantAccess) {
$FF_qsChar = &quot;?&quot;;
if (strpos($FF_authFailedURL, &quot;?&quot;)) $FF_qsChar = &quot;&&quot;;
$FF_referrer = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING']) && strlen($HTTP_SERVER_VARS['QUERY_STRING']) > 0) $FF_referrer .= &quot;?&quot; . $HTTP_SERVER_VARS['QUERY_STRING'];
$FF_authFailedURL = $FF_authFailedURL . $FF_qsChar . &quot;accessdenied=&quot; . urlencode($FF_referrer);
header(&quot;Location: $FF_authFailedURL&quot;);
exit;
}

$maxRows_corelist = 10;
$pageNum_corelist = 0;
if (isset($HTTP_GET_VARS['pageNum_corelist'])) {
$pageNum_corelist = $HTTP_GET_VARS['pageNum_corelist'];
}
$startRow_corelist = $pageNum_corelist * $maxRows_corelist;

$colname_corelist = &quot;1&quot;;
if (isset($HTTP_GET_VARS['brandid'])) {
$colname_corelist = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['brandid'] : addslashes($HTTP_GET_VARS['brandid']);
}
mysql_select_db($database_connCorelist, $connCorelist);
$query_corelist = sprintf(&quot;SELECT * FROM products WHERE brandid = %s ORDER BY productid ASC&quot;, $colname_corelist);
$query_limit_corelist = sprintf(&quot;%s LIMIT %d, %d&quot;, $query_corelist, $startRow_corelist, $maxRows_corelist);
$corelist = mysql_query($query_limit_corelist, $connCorelist) or die(mysql_error());
$row_corelist = mysql_fetch_assoc($corelist);

if (isset($HTTP_GET_VARS['totalRows_corelist'])) {
$totalRows_corelist = $HTTP_GET_VARS['totalRows_corelist'];
} else {
$all_corelist = mysql_query($query_corelist);
$totalRows_corelist = mysql_num_rows($all_corelist);
}
$totalPages_corelist = ceil($totalRows_corelist/$maxRows_corelist)-1;
?>
<html>
<head>
<title>Casino Marketing Solutions that Get Results</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<link href=&quot;main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>
<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
<!--
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.indexOf(&quot;#&quot;)!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf(&quot;?&quot;))>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[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.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))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>

<body leftmargin=&quot;0&quot; topmargin=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot;>
<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; height=&quot;100%&quot;>
<tr>
<td width=&quot;280&quot; height=&quot;20&quot; align=&quot;left&quot; valign=&quot;bottom&quot; bgcolor=&quot;3C117C&quot;><img src=&quot;images/logo_top.jpg&quot; width=&quot;280&quot; height=&quot;26&quot;></td>
<td height=&quot;20&quot; align=&quot;RIGHT&quot; valign=&quot;TOP&quot; bgcolor=&quot;3C117C&quot;>
<table height=&quot;20&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;2&quot;>
<tr>
<td width=&quot;202&quot; align=&quot;right&quot; valign=&quot;top&quot;><? include (&quot;topright.php&quot;); ?></td>
</tr>
</table>
</td>
</tr>
<tr align=&quot;CENTER&quot; valign=&quot;BOTTOM&quot;>
<td bgcolor=&quot;#EEEEEE&quot; height=&quot;50&quot; colspan=&quot;2&quot; class=&quot;topbar&quot;><table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; height=&quot;50&quot;>
<tr>
<td width=&quot;280&quot; align=&quot;left&quot; valign=&quot;top&quot; background=&quot;images/logo_bottom.jpg&quot;>&nbsp;</td>
<td align=&quot;CENTER&quot; valign=&quot;BOTTOM&quot;>&nbsp;</td>
<td width=&quot;100&quot; align=&quot;CENTER&quot; valign=&quot;BOTTOM&quot; class=&quot;date&quot;>Today's
Date is:
<?php
setlocale(&quot;LC_TIME&quot;,&quot;fr_BE&quot;);
print strftime(&quot;%e %B %Y&quot;);
?>
</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan=&quot;2&quot;><table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; height=&quot;100%&quot;>
<tr>
<td class=&quot;leftcell&quot; width=&quot;200&quot; bgcolor=&quot;eeeeee&quot; align=&quot;LEFT&quot; valign=&quot;TOP&quot; height=&quot;378&quot;>
<? include (&quot;leftbar.php&quot;); ?>
</td>
<td valign=&quot;TOP&quot;><div align=&quot;center&quot;>
<table width=&quot;95%&quot; border=&quot;0&quot; cellspacing=&quot;1&quot;>
<tr align=&quot;center&quot; valign=&quot;top&quot;>
<td>
<?php do { ?>
<table width=&quot;80%&quot; border=&quot;0&quot; cellspacing=&quot;1&quot;>
<tr>
<td><div align=&quot;center&quot;><img src=&quot;<?php echo $row_corelist['thumb']; ?>&quot;></div>
</td>
</tr>
<tr>
<td><div align=&quot;center&quot;><?php echo $row_corelist['itemnumber']; ?></div>
</td>
</tr>
<tr>
<td><div align=&quot;center&quot;><?php echo $row_corelist['title']; ?></div>
</td>
</tr>
<tr>
<td><a href=&quot;prod_detail.php?productid=<?php echo $row_corelist['productid']; ?>&quot;>details</a></td>
</tr>
</table>
<?php } while ($row_corelist = mysql_fetch_assoc($corelist)); ?></td>
<td>&nbsp;</td>
</tr>
</table>

</div></td>
<td width=&quot;100&quot; bgcolor=&quot;#eeeeee&quot; align=&quot;LEFT&quot; valign=&quot;TOP&quot; class=&quot;rightcell&quot;><table width=&quot;100&quot; border=&quot;0&quot; cellspacing=&quot;2&quot; cellpadding=&quot;0&quot; height=&quot;100%&quot;>
<tr>
<td align=&quot;CENTER&quot; valign=&quot;TOP&quot;><p><a href=&quot;javascript:;&quot;><img src=&quot;images/rep_awards.jpg&quot; width=&quot;100&quot; height=&quot;100&quot; border=&quot;0&quot;></a></p>
<p><a href=&quot;javascript:;&quot;><img src=&quot;images/aim_reward.jpg&quot; width=&quot;100&quot; height=&quot;55&quot; border=&quot;0&quot;></a></p>
<p> <a href=&quot;javascript:;&quot;><img src=&quot;images/incentive_award.jpg&quot; width=&quot;100&quot; height=&quot;19&quot; border=&quot;0&quot;></a></p>
<p><a href=&quot;javascript:;&quot;><img src=&quot;images/imra_award.jpg&quot; width=&quot;100&quot; height=&quot;39&quot; border=&quot;0&quot;></a>
</p></td>
</tr>
</table></td>
</tr>

</table></td>
</tr>
<tr bgcolor=&quot;779ED5&quot; align=&quot;CENTER&quot; valign=&quot;TOP&quot;>
<td height=&quot;20&quot; colspan=&quot;2&quot; class=&quot;bottombar&quot;>
<? include (&quot;footer.php&quot;); ?>
</td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($corelist);
?>
[Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
deecee,

are you saying that you want to have the results returned in a two-column format? that is to say, if there are 47 results returned, you want the first 24 in one column, and the second 23 in the second column?

(have to admit i was a little overwhelmed by all that code you posted, so i thought i would just ask the question.) :)

inger
 
deecee:

It would also help, when posting code, if you used the
Code:
...[/code ] TGML tags around the code.  That way, when you are using i and b as array element keys, they don't confuse the TGML parser.

[i]Want the best answers?  Ask the best questions:[/i] [URL unfurl="true"]http://www.catb.org/~esr/faqs/smart-questions.html[/URL]
TANSTAAFL!
 
ingernet -- yes that is what i want, or maybe even 3 columns but i would rather it go like

1 2 3
4 5 6
etc...

my bad bout the shotty code

[Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
hallo?

[Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
It's a matter of keeping a counter for every time you write a table data element:

Code:
<?php

$theinfo = array ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm');

print '<html><body><table border=1>';

$table_width = 4;
$table_counter = 0;
foreach ($theinfo as $theelement)
{
	if ($table_counter == 0)
	{
		print '<tr>';
	}
	
	print '<td>' . $theelement . '</td>';
	
	$table_counter++;
	
	if ($table_counter == $table_width)
	{
		print '</tr>';
		$table_counter = 0;
	}
}

for ($counter = 0; $counter < $table_width - $table_counter; $counter++)
{
	print '<td> </td>';
}

print '</table></body></html>';
?>

Want the best answers? Ask the best questions: TANSTAAFL!
 
much thanks ...

[Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
I noticed the code I posted does not produce well-formed HTML code. Here's the corrected version:

Code:
<?php

$theinfo = array ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm');

print '<html><body>';

$table_counter = 0;
$table_width = 4;

print '<table border=1>';
foreach ($theinfo as $theelement)
{
	if ($table_counter == 0)
	{
		print '<tr>';
	}
	
	print '<td>' . $theelement . '</td>';
	
	$table_counter++;
	
	if ($table_counter == $table_width)
	{
		print '</tr>';
		$table_counter = 0;
	}
}

if ($table_counter != 0)
{
	for ($counter = 0; $counter < $table_width - $table_counter; $counter++)
	{
		print '<td> </td>';
	}
	
	print '</tr>';
}
print '</table>';
	
print '</body></html>';
?>

Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top