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
ankurdave
Forum Newbie
Posts: 7 Joined: Tue May 18, 2004 12:35 am
Location: INDIA
Post
by ankurdave » Tue May 18, 2004 12:35 am
My problem is very simple
In the result i got the all values in tables but my counter always shows value 1 in all the fields
My code is as follows
Code: Select all
<?php
while ($row = mysql_fetch_object($result))
{
$counter = 1;
$value = $row -> innovatorid;
$result1 = mysql_query("SELECT * FROM innovator WHERE innovatorid="$value"") or die("Query 2 Wrong");
$total1 = mysql_num_rows($result1);
while ($row1 = mysql_fetch_object($result1))
{
print("<tr>");
print("<td align="center">" . $counter++ . "</td>");
print("<td align="center"><a href="innovators.php? innovatorid=" . $row1 -> innovatorid . "">" . $row1 -> fname . "</a></td>");
print("<td align="center"><a target="New Window" href="http:\cases" . $row1 -> linkpage . "">" . $row1 -> linkpage . "</a></td>");
print("</tr>");
}
$counter = $counter + 1;
// echo "$counter";
}
?>
The problem is in the line
Code: Select all
<?php
print("<td align="center">" . $counter++ . "</td>");
?>[/b]
It always shows 1 in each column
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue May 18, 2004 1:00 am
($counter++) maybe ..
ankurdave
Forum Newbie
Posts: 7 Joined: Tue May 18, 2004 12:35 am
Location: INDIA
Post
by ankurdave » Tue May 18, 2004 1:47 am
I do it in this way then it show 2 in all column
Code: Select all
<?php
$counter = $counter+1;
print("<td align="center">" . $counter . "</td>");
?>
it show 2 in all column
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue May 18, 2004 2:19 am
okay.. looking at your script more closely.. you seem to be only returning 1 object for the second query.
Since you have $counter = 1, inside the loop.. it gets reset for each one found.
so.. pull the $counter=1 bit out of the loop.
ankurdave
Forum Newbie
Posts: 7 Joined: Tue May 18, 2004 12:35 am
Location: INDIA
Post
by ankurdave » Wed May 19, 2004 8:39 am
thnx
I done it