Hello, Steve,

When you call mysql_fetch_array the first time, you are accessing the data
from the first row of your results and then moving the pointer to the next
row. So, when you call mysql_fetch_array the second time, it is already
starting with the second row of your results. Try something like this
instead:

<?
$sql2 = mysql_connect("localhost", "eweb", "dbfun")
or die("Could not connect <BR>");

mysql_select_db("actionregs", $sql2);

$top_level = mysql_query("SELECT * FROM williams", $sql2)
or die("Could not do query <BR>");

print "<table style=\"font-family:Verdana; font-size:10pt\" border=0
cellpadding=4 width=90%>";

print "<tr bgcolor=\"#c0c0c0\"><th width=50>Action ID</th><th
width=100>Owner</th><th width=250>Technology</th><th>Summary</th></tr>";

while ($tabledata = mysql_fetch_array($top_level)) {
echo "<tr>";
echo "<td>$tabledata[0]</td>";
echo "<td>$tabledata[6]</td>";
echo "<td>$tabledata[2]</td>";
echo "<td>$tabledata[3]</td>";
echo "</tr>";
}
print "</table>";
?>

You may need to pull the table data array items into variables before
echoing them. Does this work?

HTH!
Jed

On the threshold of genius, Steve Gaas wrote:

> Can anyone tell me what's wrong with my code?  All I get output from this is
> the LAST row of data from my Database.  There are 2 rows, how do I make it
> pull data from all of the rows?  It's not going through the loop like it
> should....  I need to be able to tell the mysql_fetch_array which row I want
> in each it iteration of the for loop.  The For loop increments counter, but
> there is no syntax to add $counter to the result_type.  The same goes with
> fetch_row...  
> 
> What am I forgetting!!??  I know it's something simple
> 
> 
> *******
> 
> $sql2 = mysql_connect("localhost", "eweb", "dbfun")
> or die("Could not connect <BR>");
> 
> mysql_select_db("actionregs", $sql2);
> 
> $top_level = mysql_query("SELECT * FROM williams", $sql2)
> or die("Could not do query <BR>");
> 
> $sql2_results = mysql_fetch_array($top_level);
> $query_sql2_rows = mysql_num_rows($top_level);
> 
> echo $query_sql2_rows;
> // echo's 2 rows
> 
> print "<table style=\"font-family:Verdana; font-size:10pt\" border=0
> cellpadding=4 width=90%>";
> 
> print "<tr bgcolor=\"#c0c0c0\"><th width=50>Action ID</th><th
> width=100>Owner</th><th width=250>Technology</th><th>Summary</th></tr>";
> 
> for ($counter=0; $counter < $query_sql2_rows; $counter++) {
> $tabledata = mysql_fetch_array($top_level);
> echo "<td>$tabledata[0]</td>";
> echo "<td>$tabledata[6]</td>";
> echo "<td>$tabledata[2]</td>";
> echo "<td>$tabledata[3]</td>";
> echo "</tr>";
> }
> print "</table>";
> 
> Thanks.
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to