Re: [PHP] MySQL and Array's REALLY simple question but I'm not GETTING it.. Ugh..

2002-09-06 Thread Chulkee Sung

> $sql2_results = mysql_fetch_array($top_level);

I guess this must be in a loop otherwise your $sq12_results keep getting
overwitten; thus,
the last record will be shown at the end.


> $query_sql2_rows = mysql_num_rows($top_level);
> 
> echo $query_sql2_rows;
> // echo's 2 rows
> 
> print " cellpadding=4 width=90%>";
> 
> print "Action ID width=100>OwnerTechnologySummary";
> 
> for ($counter=0; $counter < $query_sql2_rows; $counter++) {
> $tabledata = mysql_fetch_array($top_level);
> echo "$tabledata[0]";
> echo "$tabledata[6]";
> echo "$tabledata[2]";
> echo "$tabledata[3]";
> echo "";
> }
> print "";
> 
> Thanks.
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
i18n Engineer
SCO, Inc.
www.sco.com (801) 765-4999 x5647
355 South 520 West, Suit 100, Lindon, Utah 84042 USA

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




Re: [PHP] MySQL and Array's REALLY simple question but I'm not GETTING it .. Ugh..

2002-09-06 Thread Brad Bonkoski

It doesn't matter what variables you assign to "fetch" the data, one of 
the effects of mysql_fetch_array() is to increment the database result 
variable.  It does this without you even knowing it.  check out the 
mysql_data_seek() function to see how you can make the adjustments 
yourself.  i.e. mysql_data_seek($result, 0) would set you back at the 
beginning, record one.

-Brad

Steve Gaas wrote:
> OK, this works.. This is wonderful.. But I don't get it.. I assigned two
> separate variables to that array function..  I don't understand why this
> works now, but thanks a lot for the help. 
> 
> I hope I don't inadvertently run into this again...
> 
> -steve
> 
> 
> $sql2 = mysql_connect("localhost", "eweb", "dbfun")
>   or die("Could not connect using default username and password LINE
> 14 ");
> 
> mysql_select_db("actionregs", $sql2);
> 
> $top_level = mysql_query("SELECT * FROM williams", $sql2)
>   or die("Could not do query sql1 to find username. Link might not
> have been made. What's up? LINE 19 ");
> 
> // $sql2_results = mysql_fetch_array($top_level);
> $query_sql2_rows = mysql_num_rows($top_level);
> $rows = 0;
> echo $query_sql2_rows;
> 
> 
> print " cellpadding=4 width=90%>";
> print "Action ID width=100>OwnerTechnologySummary";
> 
> for ($counter=0; $counter < $query_sql2_rows; $counter++) {
>   $tabledata = mysql_fetch_array($top_level);
>   echo "$tabledata[0]";
>   echo "$tabledata[6]";
>   echo "$tabledata[2]";
>       echo "$tabledata[3]";
>   echo "";
>   }
> print "";
> -Original Message-
> From: Brad Bonkoski [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, September 06, 2002 3:34 PM
> To: Steve Gaas
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] MySQL and Array's REALLY simple question but I'm not
> GETTING it .. Ugh..
> 
> Well, when you run the command:
> 
> $sql2_results = mysql_fetch_array($top_level);
> 
> The first time, it automatically increments the result...
> so you fetch the data bu do nothing with it...
> so when you get to your loop, you are already at the second entry in 
> your database..
> 
> So, remove the first instance of that and see how it works..
> HTH
> -Brad
> 
> 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 ");
>>
>>mysql_select_db("actionregs", $sql2);
>>
>>$top_level = mysql_query("SELECT * FROM williams", $sql2)
>>  or die("Could not do query ");
>>
>>$sql2_results = mysql_fetch_array($top_level);
>>$query_sql2_rows = mysql_num_rows($top_level);
>>
>>echo $query_sql2_rows;
>>// echo's 2 rows
>>
>>print ">cellpadding=4 width=90%>";
>>
>>print "Action ID>width=100>OwnerTechnologySummary";
>>
>>for ($counter=0; $counter < $query_sql2_rows; $counter++) {
>>  $tabledata = mysql_fetch_array($top_level);
>>  echo "$tabledata[0]";
>>  echo "$tabledata[6]";
>>  echo "$tabledata[2]";
>>  echo "$tabledata[3]";
>>  echo "";
>>  }
>>print "";
>>
>>Thanks.
>>
>>
>>
>> 
>>
> 
> 
> 



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




RE: [PHP] MySQL and Array's REALLY simple question but I'm not GETTING it .. Ugh..

2002-09-06 Thread Steve Gaas

OK, this works.. This is wonderful.. But I don't get it.. I assigned two
separate variables to that array function..  I don't understand why this
works now, but thanks a lot for the help. 

I hope I don't inadvertently run into this again...

-steve


$sql2 = mysql_connect("localhost", "eweb", "dbfun")
or die("Could not connect using default username and password LINE
14 ");

mysql_select_db("actionregs", $sql2);

$top_level = mysql_query("SELECT * FROM williams", $sql2)
or die("Could not do query sql1 to find username. Link might not
have been made. What's up? LINE 19 ");

// $sql2_results = mysql_fetch_array($top_level);
$query_sql2_rows = mysql_num_rows($top_level);
$rows = 0;
echo $query_sql2_rows;


print "";
print "Action IDOwnerTechnologySummary";

for ($counter=0; $counter < $query_sql2_rows; $counter++) {
$tabledata = mysql_fetch_array($top_level);
echo "$tabledata[0]";
echo "$tabledata[6]";
echo "$tabledata[2]";
echo "$tabledata[3]";
echo "";
}
print "";
-Original Message-----
From: Brad Bonkoski [mailto:[EMAIL PROTECTED]] 
Sent: Friday, September 06, 2002 3:34 PM
To: Steve Gaas
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] MySQL and Array's REALLY simple question but I'm not
GETTING it .. Ugh..

Well, when you run the command:

$sql2_results = mysql_fetch_array($top_level);

The first time, it automatically increments the result...
so you fetch the data bu do nothing with it...
so when you get to your loop, you are already at the second entry in 
your database..

So, remove the first instance of that and see how it works..
HTH
-Brad

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 ");
>
>mysql_select_db("actionregs", $sql2);
>
>$top_level = mysql_query("SELECT * FROM williams", $sql2)
>   or die("Could not do query ");
>
>$sql2_results = mysql_fetch_array($top_level);
>$query_sql2_rows = mysql_num_rows($top_level);
>
>echo $query_sql2_rows;
>// echo's 2 rows
>
>print "cellpadding=4 width=90%>";
>
>print "Action IDwidth=100>OwnerTechnologySummary";
>
>for ($counter=0; $counter < $query_sql2_rows; $counter++) {
>   $tabledata = mysql_fetch_array($top_level);
>   echo "$tabledata[0]";
>   echo "$tabledata[6]";
>   echo "$tabledata[2]";
>   echo "$tabledata[3]";
>   echo "";
>   }
>print "";
>
>Thanks.
>
>
>
>  
>


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