Re: [PHP-DB] mysql_fetch_array problem

2001-07-09 Thread bleythbe

I was having the same problem for a while... although, I
was using this:

for($i=0;$i

Good luck,
Ben

Quoting BrianSander <[EMAIL PROTECTED]>:

> Greetings,
> 
> I'm experiencing the strangest problem and I was
> wondering if anyone
> else has had the same problem.
> 
> I have a fairly simple script setup that queries
> a mySQL database and
> displays the records in a HTML table. Everything
> works fine except it
> keeps omitting the first record. Running the
> query directly on the
> database returns 3 records but only 2 are
> displayed in the table.
> 
> I just upgraded to PHP 4.0.6 and I'm still
> having the problem. I've also
> tried using mysql_fetch_array and
> mysql_fetch_object, both produce the
> same results. The first record is left out every
> time.
> 
> Any idea as to what the problem might be?
> 
> 
> Thanks. 
> 
> -- 
> PHP Database Mailing List
> (http://www.php.net/)
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
> 
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] mysql_fetch_array problem

2001-07-09 Thread BrianSander

Greetings,

I'm experiencing the strangest problem and I was wondering if anyone
else has had the same problem.

I have a fairly simple script setup that queries a mySQL database and
displays the records in a HTML table. Everything works fine except it
keeps omitting the first record. Running the query directly on the
database returns 3 records but only 2 are displayed in the table.

I just upgraded to PHP 4.0.6 and I'm still having the problem. I've also
tried using mysql_fetch_array and mysql_fetch_object, both produce the
same results. The first record is left out every time.

Any idea as to what the problem might be?


Thanks. 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] mysql_fetch_array problem...!

2001-03-05 Thread JJeffman

You must use a loop to show each row of your query.
"mysql_fetch_array($result)" only get the current row.

while($row = mysql_fetch_array($result) ){

// do something

}

The "mysql_fetch_array" function returns an associative array where you can
use the field names  to have access to its value :

$row = mysql_fetch_array($result) ;
$v1 = $row["fieldname1"] ;
$v2 = $row["fieldname2"] ;
$v3 = $row["fieldname3"] ;

You're going to  use the alias names you are creating on the query.

See more details on php manual at mysql functions.

HTH.

Jayme.

-Mensagem Original-
De: Trond Erling Hundal <[EMAIL PROTECTED]>
Para: PHP-DB-LIST <[EMAIL PROTECTED]>
Enviada em: segunda-feira, 5 de março de 2001 09:56
Assunto: [PHP-DB] mysql_fetch_array problem...!


> I want to run a query to my db, fetching different fields from three
> different tables.
> In order to recognise the individual fields I give them names:
>
> select portal.portal as portal, portal.portalid as id... etc etc
>
>
> How can I refer to one specific row in this query..?
> What I mean is, how can i refer to result row number 4...?
>
> If I only selected rows from one table I could do something like this:
>
> $i = mysql_fetch_array($sql) ;
>
> echo "$i[4]" ;
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] mysql_fetch_array problem...!

2001-03-05 Thread Darryl Friesen

> How can I refer to one specific row in this query..?
> What I mean is, how can i refer to result row number 4...?
>
> If I only selected rows from one table I could do something like this:
>
> $i = mysql_fetch_array($sql) ;
> echo "$i[4]" ;

Actually, no.  mysql_fetch_array return the _current row_ from the query
(use this function in a loop to process each row of the resulting data).
$i[4] in your case is the fourth field in the current row.

If you really don't want to process the rows in order, look at the
documentation for mysql_data_seek; it can be used to jump around the result
set.


- Darryl

 --
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education & Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] mysql_fetch_array problem...!

2001-03-05 Thread Andrew Hill

Trond,

What is your table structure?
I'm guessing you need a different query.

Also, be aware that mysql_fetch_array returns an array with the field name
as value, so:

$sql="select fields from table where id = $id";

$connection_handle=(mysql_connect($user, $pass, $host);
mysql_select_db($database, $connection_handle);
$result=(mysql_query($sql, $connection_handle);
$i = mysql_fetch_array($result);
echo $i[fieldname];

will produce a single result item.


Best regards,
Andrew
--
Andrew Hill - OpenLink Software
Director Technology Evangelism
eBusiness Infrastructure Technology
http://www.openlinksw.com


> -Original Message-
> From: Trond Erling Hundal [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 05, 2001 7:56 AM
> To: PHP-DB-LIST
> Subject: [PHP-DB] mysql_fetch_array problem...!
>
>
> I want to run a query to my db, fetching different fields from three
> different tables.
> In order to recognise the individual fields I give them names:
>
> select portal.portal as portal, portal.portalid as id... etc etc
>
>
> How can I refer to one specific row in this query..?
> What I mean is, how can i refer to result row number 4...?
>
> If I only selected rows from one table I could do something like this:
>
> $i = mysql_fetch_array($sql) ;
>
> echo "$i[4]" ;
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] mysql_fetch_array problem...!

2001-03-05 Thread Trond Erling Hundal

I want to run a query to my db, fetching different fields from three
different tables.
In order to recognise the individual fields I give them names:

select portal.portal as portal, portal.portalid as id... etc etc


How can I refer to one specific row in this query..?
What I mean is, how can i refer to result row number 4...?

If I only selected rows from one table I could do something like this:

$i = mysql_fetch_array($sql) ;

echo "$i[4]" ;




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]