By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,060 Members | 1,906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,060 IT Pros & Developers. It's quick & easy.

Unable to see full result of mysql query in php

P: n/a
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

Oct 9 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Oct 9, 10:17 am, Terry <w...@rogers.comwrote:
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.

Oct 9 '07 #2

P: n/a
On Oct 9, 4:04 pm, dkruger <davidkru...@techie.comwrote:
On Oct 9, 10:17 am, Terry <w...@rogers.comwrote:


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.

Oct 9 '07 #3

P: n/a
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.
js*******@attglobal.net
==================
Oct 10 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.