--------------------------------------…
OUTPUT
--------------------------------------…
1 name1
2 name2
3 name3
4 name4
5 name5
6 name6
--------------------------------------…
here is my script which i have used ...
--------------------------------------…
mypage.php
----------------------------------
***** PLEASE USE PHP CODE TAGS *****
Code: Select all
<?php
$conn = mysql_connect('localhost','root','') or die('could not connect to remote server');
mysql_select_db('emailactivation') or die('could not connect to database ');
$qry = "select * from users";
$result = mysql_query($qry) or die(mysql_error());
$rows = mysql_num_rows($result);
for($i = 1;$i<=$rows;$i++)
while($ma = mysql_fetch_array($result))
{
echo $i . $ma['username'] . "
" ;
}
?>but m getting this output using the above script .. .
--------------------------------------…
1 name1
1 name2
1 name3
1 name4
1 name5
1 name6
1 name7
--------------------------------------…
whats wrong in my script .. i want to get the output which i have told at the start .. please help me whats wrong in my code to get the starting output ..
i have also tried this script ..
---------------------------------------…
Code: Select all
<?php
$conn = mysql_connect('localhost','root','') or die('could not connect to remote server');
mysql_select_db('emailactivation') or die('could not connect to database ');
$qry = "select * from users";
$result = mysql_query($qry) or die(mysql_error());
$rows = mysql_num_rows($result);
while($ma = mysql_fetch_array($result))
{
for($i = 1;$i<=$rows;$i++)
echo $i . $ma['username'] . "
" ;
}
?>and getting this output now ..
---------------------------------------…
1 name1
2 name1
3 name1
4 name1
5 name1
1 name2
2 name2
3 name2
4 name2
5 name2
---------------------------------------…