Forums
This topic is locked
Where am I in the recordset?
16 Nov 2001 20:38:50 David Fee posted:
I'm using PHP4-Ultradev with a Postgres database. The recordset results are displayed in an HTML table. How do I determine how PHP/Ultradev knows where it is in the recordset as it creates the table. Ultradev writes an if statement that runs as many times as there are records in the recordset and then writes the table code. Thanks,
Dave
Replies
Replied 18 Nov 2001 01:17:42
18 Nov 2001 01:17:42 Tim Green replied:
To determine which row is the current row in the recordset you can use the ADODB function CurrentRow() like this:-
<?php
$rsRow = $RecordsetName->CurrentRow();
?>
The value produced is a zero-based integer that represents the current row number.
Hope this helps.
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>
<?php
$rsRow = $RecordsetName->CurrentRow();
?>
The value produced is a zero-based integer that represents the current row number.
Hope this helps.
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>
Replied 19 Nov 2001 23:47:40
19 Nov 2001 23:47:40 David Fee replied:
Thanks rawveg, that did answer my question. But I have another question/problem that is php and javascript driven. Let me know if my question belongs in a java forum, and I'll post one there. My recordset is created by php and I have the results dumped into a table. The first column of my table is a "go to detail page" link with an image that says "details". I want to use onMouseOver to change the color of the image but when the code is executed, only the first record in the recordset changes color, no mater which record my mouse is over. Can you tell me what I'm doing wrong? I've attached a section of my code below but I left out the other columns and only gave you the "go to details" code.
<?php while (($Repeat1__numRows-- != 0) && (!$Recordset1->EOF))
{
?>
<tr>
<td>
<div align="center"><A HREF="details.php?<?php echo $MM_keepNone.MM_keepNone!""?"&":""."userid=".$Recordset1->Fields("userid" ?>"
onMouseOver="document.pic1.src='details_on.gif'"
onMouseOut="document.pic1.src='details_off.gif'">
<IMG SRC="details_off.gif" BORDER=0 NAME="pic1"></a>
</div>
</td>
</tr>
<?php>$Repeat1__index++;
$Recordset1->MoveNext();
}
?>
Thanks for your help.
Dave
<?php while (($Repeat1__numRows-- != 0) && (!$Recordset1->EOF))
{
?>
<tr>
<td>
<div align="center"><A HREF="details.php?<?php echo $MM_keepNone.MM_keepNone!""?"&":""."userid=".$Recordset1->Fields("userid" ?>"
onMouseOver="document.pic1.src='details_on.gif'"
onMouseOut="document.pic1.src='details_off.gif'">
<IMG SRC="details_off.gif" BORDER=0 NAME="pic1"></a>
</div>
</td>
</tr>
<?php>$Repeat1__index++;
$Recordset1->MoveNext();
}
?>
Thanks for your help.
Dave
Replied 23 Nov 2001 02:18:09
23 Nov 2001 02:18:09 Tim Green replied:
If you're using a combination of PHP and Javascript like this, I think it's fair to deal with it here.
The problem you are having arises from the fact that you're resultant code sent to the browser has multiple images with the same name (pic1). There is a tendency for Javascript to go a little gaga (technical term there) when you're trying to refer to multiple elements with the same name like this.
I would suggest a minor amendment, as follows:-
<?php while (($Repeat1__numRows-- != 0) && (!$Recordset1->EOF))
{
?>
<tr>
<td>
<div align="center"><A HREF="details.php?<?php echo $MM_keepNone.MM_keepNone!""?"&":""."userid=".$Recordset1->Fields("userid" ?>"
onMouseOver="document.pic<?php echo $Repeat1__index; ?>.src='details_on.gif'"
onMouseOut="document.pic<?php echo $Repeat1__index; ?>.src='details_off.gif'">
<IMG SRC="details_off.gif" BORDER=0 NAME="pic<?php echo $Repeat1__index; ?>"></a>
</div>
</td>
</tr>
<?php>$Repeat1__index++;
$Recordset1->MoveNext();
}
?>
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>
The problem you are having arises from the fact that you're resultant code sent to the browser has multiple images with the same name (pic1). There is a tendency for Javascript to go a little gaga (technical term there) when you're trying to refer to multiple elements with the same name like this.
I would suggest a minor amendment, as follows:-
<?php while (($Repeat1__numRows-- != 0) && (!$Recordset1->EOF))
{
?>
<tr>
<td>
<div align="center"><A HREF="details.php?<?php echo $MM_keepNone.MM_keepNone!""?"&":""."userid=".$Recordset1->Fields("userid" ?>"
onMouseOver="document.pic<?php echo $Repeat1__index; ?>.src='details_on.gif'"
onMouseOut="document.pic<?php echo $Repeat1__index; ?>.src='details_off.gif'">
<IMG SRC="details_off.gif" BORDER=0 NAME="pic<?php echo $Repeat1__index; ?>"></a>
</div>
</td>
</tr>
<?php>$Repeat1__index++;
$Recordset1->MoveNext();
}
?>
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>