Forums

PHP

This topic is locked

Horizontal Looping Again

Posted 27 Aug 2001 15:45:58
1
has voted
27 Aug 2001 15:45:58 Keith Slater posted:
I still can not get this to work at all, I've tried different scripts, everything I can not get this to work for the life of me. I always have different problems. On one of my scripts it skips every 3rd image it should display on different scripts it doesnt even make it horizontal. Could some one send me a sample script that they have that they know works please?? Thanks for all your help


Keith

Keith Slater

Replies

Replied 27 Aug 2001 18:57:13
27 Aug 2001 18:57:13 Bruno Mairlot replied:
Hi Keith,

Here is a skeleton that will show you how to loop horizontally AND vertically.

<pre id=code><font face=courier size=2 id=code>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;/head&gt;

&lt;body bgcolor="#FFFFFF" text="#000000"&gt;
<font color=red>
&lt;table width="100" border="0"&gt;
&lt;?php
for($i=0;$i&lt;15;$i++){
?&gt;
&lt;?php
if(($i%5)==0){
?&gt;
&lt;tr&gt;
&lt;?php
}
?&gt;
&lt;td&gt;&lt;?php echo $i?&gt;&lt;/td&gt;
&lt;?php
if(($i%5)==4){
?&gt;
&lt;/tr&gt;
&lt;?php
}
?&gt;
&lt;?php
}
?&gt;
</font id=red>
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</font id=code></pre id=code>

I have tested it, and it works.

Don't forget to replace the 5 to the number of horizontal column you want to have (3 for example), and replace the 4 by this number-1 (2 for example).

Try this, and if doesn't work for you, then please post the HTML output.

Bruno

"First they laugh at you, then they fight you, then you Win..." Ghandi
Replied 27 Aug 2001 19:41:22
27 Aug 2001 19:41:22 Keith Slater replied:
Hey cool it displayed the right amount of images that it was supposed to the onyl thing ia it displays the same image... heres the code I have

&lt;?php


// Copyright (c) Interakt Online 2001
// www.interakt.ro/

require("./adodb/adodb.inc.php";
require("./Connections/CaricaturePHP.php";
?&gt;&lt;?php
session_start();

// Copyright (c) Interakt Online 2001
// www.interakt.ro/

require("./adodb/adodb.inc.php";
require("./Connections/CaricaturePHP.php";
?&gt;&lt;?php
$Recordset1__MMColParam = "1";
if (isset($HTTP_SESSION_VARS["KT_Username"]))
{$Recordset1__MMColParam = $HTTP_SESSION_VARS["KT_Username"];}
?&gt;&lt;?php
$Recordset1=$CaricaturePHP-&gt;Execute("SELECT * FROM GALLERY_1 WHERE USER_NAME = '" . ($Recordset1__MMColParam) . "'" or DIE($CaricaturePHP-&gt;ErrorMsg());
$Recordset1_numRows=0;
$Recordset1__totalRows=$Recordset1-&gt;RecordCount();
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;/head&gt;
&lt;body bgcolor="#FFFFFF" text="#000000"&gt;
&lt;table width="600" border="0" cellspacing="0" cellpadding="0" align="center"&gt;
&lt;?php
for($i=0;$i&lt;15;$i++){
?&gt;
&lt;?php
if(($i%2)==0){
?&gt;
&lt;tr&gt;
&lt;?php
}
?&gt;
&lt;td&gt;
&lt;div align="center"&gt;
&lt;p&gt;&lt;img src="images/&lt;?php echo $Recordset1-&gt;Fields("PICTURE_NAME"?&gt;" width="150" height="150"&gt;&lt;/p&gt;
&lt;p&gt;&nbsp;&lt;/p&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;?php
if(($i%2)==2){
?&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td height="5"&gt;&nbsp;&lt;/td&gt;

&lt;/tr&gt;
&lt;?php
}
?&gt;
&lt;?php
}
?&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;?php
$Recordset1-&gt;Close();
?&gt;


it needs some kind of movenext or something


thanks a lot

Keith Slater
Replied 27 Aug 2001 19:47:24
27 Aug 2001 19:47:24 Keith Slater replied:
wait a sec I was looking at the script and it places 15 no matter what... I want it to place it by how many their are by their user name so if their 13 of the user I want to shwo the 13 pictures....


thanks

Keith Slater
Replied 27 Aug 2001 20:53:11
27 Aug 2001 20:53:11 Bruno Mairlot replied:
Keith,

I've changed the code to make it work correctly...
<pre id=code><font face=courier size=2 id=code>
&lt;?php


// Copyright (c) Interakt Online 2001
// www.interakt.ro/

require("./adodb/adodb.inc.php";
require("./Connections/CaricaturePHP.php";
?&gt;&lt;?php
session_start();

// Copyright (c) Interakt Online 2001
// www.interakt.ro/

require("./adodb/adodb.inc.php";
require("./Connections/CaricaturePHP.php";
?&gt;&lt;?php
$Recordset1__MMColParam = "1";
if (isset($HTTP_SESSION_VARS["KT_Username"]))
{$Recordset1__MMColParam = $HTTP_SESSION_VARS["KT_Username"];}
?&gt;&lt;?php
$Recordset1=$CaricaturePHP-&gt;Execute("SELECT * FROM GALLERY_1 WHERE USER_NAME = '" . ($Recordset1__MMColParam) . "'" or DIE($CaricaturePHP-&gt;ErrorMsg());
$Recordset1_numRows=0;
$Recordset1__totalRows=$Recordset1-&gt;RecordCount();
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; ch****t=iso-8859-1"&gt;
&lt;/head&gt;
&lt;body bgcolor="#FFFFFF" text="#000000"&gt;
&lt;table width="600" border="0" cellspacing="0" cellpadding="0" align="center"&gt;
&lt;?php
while (($Repeat1__numRows-- != 0) && (!$Recordset1-&gt;EOF))

?&gt;
&lt;?php
if(($Repeat1__index%2)==0){
?&gt;
&lt;tr&gt;
&lt;?php
}
?&gt;
&lt;td&gt;
&lt;div align="center"&gt;
&lt;p&gt;&lt;img src="images/&lt;?php echo $Recordset1-&gt;Fields("PICTURE_NAME"?&gt;" width="150" height="150"&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;?php
if(($Repeat1__index%2)==2){
?&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td height="5"&gt; &lt;/td&gt;

&lt;/tr&gt;
&lt;?php
}
?&gt;
&lt;?php
$Repeat1__index++;
$Recordset1-&gt;MoveNext();
}
?&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;?php
$Recordset1-&gt;Close();
?&gt;

</font id=code></pre id=code>

"First they laugh at you, then they fight you, then you Win..." Ghandi
Replied 27 Aug 2001 21:21:51
27 Aug 2001 21:21:51 Keith Slater replied:
Hmm not im getting a parse error on line 61 which is:

&lt;?php
$Repeat1__index++;
$Recordset1-&gt;MoveNext();
}
?&gt;

I copied your script exact too
thank you!!

Keith Slater
Replied 27 Aug 2001 23:28:05
27 Aug 2001 23:28:05 Bruno Mairlot replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hmm not im getting a parse error on line 61 which is:

&lt;?php
$Repeat1__index++;
$Recordset1-&gt;MoveNext();
}
?&gt;

I copied your script exact too
thank you!!

Keith Slater

<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Yes you're right...I forget to include the first { just after the while !! (near line 30)

change the line with the while with :

while (($Repeat1__numRows-- != 0) && (!$Recordset1-&gt;EOF)) <font color=red><b>{</b></font id=red>

And it should be fine.

"First they laugh at you, then they fight you, then you Win..." Ghandi
Replied 28 Aug 2001 15:04:27
28 Aug 2001 15:04:27 Keith Slater replied:
I changed it now when I try it I get no images to display at all...

thanks
keith

Keith Slater
Replied 28 Aug 2001 20:52:10
28 Aug 2001 20:52:10 Keith Slater replied:
Hey thanks I got it to work now.... with the script you gave me!! Now Im trying to add navigation to it (next and previous) and its doing weird stuff. Its skipping the first 10 then display 10 on the page. Then you hit next, it skips 10 and displays the next 10, its weird, do you know what might be causing that?

Keith Slater
Replied 31 Aug 2001 15:00:30
31 Aug 2001 15:00:30 Keith Slater replied:
bump

Keith Slater
Replied 01 Sep 2001 16:14:07
01 Sep 2001 16:14:07 Tim Green replied:
Keith, the problem you are finding with the navigation is because you are using the standard navigation suite in a situation where you are using a customised repeat region.

In this instance you will also need to use a customized navigation suite, which you will have to write from scratch.

Please remember, that whenever you stray from the path of the inbuilt behaviours with UD, that you will also have to do the same for any behaviours relating to it.

The recordset is fine as you are using the standard recordset system, though anything relating to repeat regions, and region navigation will have to be hand-coded from hereon in when dealing with this specific page.

I would also like to remind you that this is now a new question, and therefore it requires a new thread. This thread may be related, but navigation issues should be dealt with separately.

Thanks

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Reply to this topic