Unable to see full result of mysql query in php

Unable to see full result of mysql query in php

am 09.10.2007 17:17:36 von Terry

Hi folks.
I am just starting to dabble in php.

I am trying to do some simple pagination in php/mysql.

For whatever reason I am only getting the first digit of my result.

For example:

$result = mysql_query("select lamp_no from lamps as l where id=20");
$row = mysql_fetch_array($result);
echo "20 = " . $row[0]['l']

only displays 1 it should have displayed 15 for me.

Thanks,
Terry

Re: Unable to see full result of mysql query in php

am 09.10.2007 23:04:58 von davidkruger

On Oct 9, 10:17 am, Terry wrote:
> Hi folks.
> I am just starting to dabble in php.
>
> I am trying to do some simple pagination in php/mysql.
>
> For whatever reason I am only getting the first digit of my result.
>
> For example:
>
> $result = mysql_query("select lamp_no from lamps as l where id=20");
> $row = mysql_fetch_array($result);
> echo "20 = " . $row[0]['l']
>
> only displays 1 it should have displayed 15 for me.
>
> Thanks,
> Terry

Not from the way your query looks. what happens if you run that exact
query in your mysql client?

what I would try is run the query:

"select lamp_no as l from lamps where id=20"

with my suggestion, l will be used for the column name instead of
lamp_no. From the looks of your query, your column name would still
be lamp_no instead of l.

Re: Unable to see full result of mysql query in php

am 09.10.2007 23:09:03 von davidkruger

On Oct 9, 4:04 pm, dkruger wrote:
> On Oct 9, 10:17 am, Terry wrote:
>
>
>
>
>
> > Hi folks.
> > I am just starting to dabble in php.
>
> > I am trying to do some simple pagination in php/mysql.
>
> > For whatever reason I am only getting the first digit of my result.
>
> > For example:
>
> > $result = mysql_query("select lamp_no from lamps as l where id=20");
> > $row = mysql_fetch_array($result);
> > echo "20 = " . $row[0]['l']
>
> > only displays 1 it should have displayed 15 for me.
>
> > Thanks,
> > Terry
>
> Not from the way your query looks. what happens if you run that exact
> query in your mysql client?
>
> what I would try is run the query:
>
> "select lamp_no as l from lamps where id=20"
>
> with my suggestion, l will be used for the column name instead of
> lamp_no. From the looks of your query, your column name would still
> be lamp_no instead of l.- Hide quoted text -
>
> - Show quoted text -

One thing when working with arrays, if you are unsure what might be
going on with data not matching what you expect, I would try using the
command print_r(array) to display the contents of the array, and all
of the keys etc. This will usually give you an idea where a problem
might be occuring in your code.

Re: Unable to see full result of mysql query in php

am 10.10.2007 04:49:51 von Jerry Stuckle

Terry wrote:
> Hi folks.
> I am just starting to dabble in php.
>
> I am trying to do some simple pagination in php/mysql.
>
> For whatever reason I am only getting the first digit of my result.
>
> For example:
>
> $result = mysql_query("select lamp_no from lamps as l where id=20");
> $row = mysql_fetch_array($result);
> echo "20 = " . $row[0]['l']
>
> only displays 1 it should have displayed 15 for me.
>
> Thanks,
> Terry
>

Yep. $row[0] is a string, containing the value of lamp_no. $row[0][1]
is a character in that string.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================