Need some help converting some code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jwashburn
Forum Newbie
Posts: 5
Joined: Thu Apr 20, 2006 10:21 pm

Need some help converting some code

Post by jwashburn »

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am new to PHP and only a novice at ASP so please hang in there.

I am returning records from a database with a thunbmail image and a name.  I want 5 records to be displayed and then a break.  I tried an ASP to PHP convertor, but they have proven to not be very reliable.

Here is the code in ASP

[syntax="asp"]   <% 
    
While ((Repeat1__numRows <> 0) AND (NOT rsTrack.EOF)) 
	if iTracksLineBreak >=6 then
		Response.Write "</tr>"
		response.Write "<tr>"
		iTracksLineBreak = 1
	End if
%>
    <td valign="top"><p align="center"><A HREF="detailride.asp?<%= Server.HTMLEncode(MM_keepURL) & MM_joinChar(MM_keepURL) & "ID=" & rsTrack.Fields.Item("ID").Value %>"><%=(rsTrack.Fields.Item("DisplayName").Value)%></A><br>
      <A HREF="detailride.asp?<%= Server.HTMLEncode(MM_keepURL) & MM_joinChar(MM_keepURL) & "ID=" & rsTrack.Fields.Item("ID").Value %>"><img src="<%=(rsTrack.Fields.Item("pic_thumb").Value)%>" alt="" border="0"></A></p>
    </td>
    <% 
    iTracksLineBreak = iTracksLineBreak + 1
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsTrack.MoveNext()
Wend
%>
The part I am having trouble with is the While statement. This is what I have come up with so far using the convertor tools and some infromation I have picked up reading around on the net[/syntax]

Code: Select all

<? 
    
While (($Repeat1__numRows <> 0) AND (NOT $rsTrack.$EOF)); 
	if ($iTracksLineBreak >=6) {
		echo "</tr>";
		echo "<tr>";
		$iTracksLineBreak = 1;
	}
?>
    <td valign="top"><p align="center"><A HREF="detailride.asp?<?= Server.$HTMLEncode[$MM_keepURL].$MM_joinChar[$MM_keepURL]."ID=".$rsTrack.$Fields.$Item["ID"].$Value ?>"><?=($rsTrack.$Fields.$Item["DisplayName"].$Value)?></A><br>
      <A HREF="detailride.asp?<?= Server.$HTMLEncode[$MM_keepURL].$MM_joinChar[$MM_keepURL]."ID=".$rsTrack.$Fields.$Item["ID"].$Value ?>"><img src="<?=($rsTrack.$Fields.$Item["pic_thumb"].$Value)?>" alt="" border="0"></A></p>
    </td>
    <? 
    $iTracksLineBreak = $iTracksLineBreak + 1;
  $Repeat1__index=$Repeat1__index+1;
  $Repeat1__numRows=$Repeat1__numRows-1;
  $rsTrack.$MoveNext();
}
?>
I get an error on the first line, so something is wrong with the while statement. I believe its the EOF that is doing, I dont think its a variable, but i can find how to do it with PHP

Any help would be appreciated.


Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
jwashburn
Forum Newbie
Posts: 5
Joined: Thu Apr 20, 2006 10:21 pm

Post by jwashburn »

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have modifed the code to

Code: Select all

While ($Repeat1__numRows <> 0); 
	if ($iTracksLineBreak >=6) {
		echo "</tr>";
		echo "<tr>";
		$iTracksLineBreak = 1;
	}
?>
    <td valign="top"><p align="center"><A HREF="detailride.asp?<?= Server.$HTMLEncode[$MM_keepURL].$MM_joinChar[$MM_keepURL]."ID=".$rsTrack.$Fields.$Item["ID"].$Value ?>"><?=($rsTrack.$Fields.$Item["DisplayName"].$Value)?></A><br>
      <A HREF="detailride.asp?<?= Server.$HTMLEncode[$MM_keepURL].$MM_joinChar[$MM_keepURL]."ID=".$rsTrack.$Fields.$Item["ID"].$Value ?>"><img src="<?=($rsTrack.$Fields.$Item["pic_thumb"].$Value)?>" alt="" border="0"></A></p>
    </td>
    <? 
    $iTracksLineBreak = $iTracksLineBreak + 1;
  $Repeat1__index=$Repeat1__index+1;
  $Repeat1__numRows=$Repeat1__numRows-1;
  $rsTrack.$MoveNext();

?>
Now my error is at

Code: Select all

$rsTrack.$MoveNext();

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply