let's say i have a table in my database, with only one column. all i
want to do is retrieve a list of the entries.. i could do it like this
$result = mysql_query("SE LECT * FROM t1");
while( $x = mysql_fetch_row ($result) ) {
echo $x[0];
}
but it seems kinda silly to fetch an entire array, when only the first
index is used. is there a better/more efficient way? 7 6017
Mark wrote:
let's say i have a table in my database, with only one column. all i
want to do is retrieve a list of the entries.. i could do it like this
$result = mysql_query("SE LECT * FROM t1");
while( $x = mysql_fetch_row ($result) ) {
echo $x[0];
}
but it seems kinda silly to fetch an entire array, when only the first
index is used. is there a better/more efficient way?
mysql_fetch_row () fetches a row !
as your table has only 1 column the row consists of only 1 value.
What you require is
$result = mysql_query("SE LECT * FROM t1");
while ($row = mysql_fetch_arr ay($result)) {
echo $x[0];
}
Suffering from cut&pasteitis
$result = mysql_query("SE LECT * FROM t1");
while ($x = mysql_fetch_arr ay($result)) {
echo $x[0];
}
davie wrote:
Mark wrote:
let's say i have a table in my database, with only one column. all i
want to do is retrieve a list of the entries.. i could do it like this
$result = mysql_query("SE LECT * FROM t1");
while( $x = mysql_fetch_row ($result) ) {
echo $x[0];
}
but it seems kinda silly to fetch an entire array, when only the first
index is used. is there a better/more efficient way?
mysql_fetch_row () fetches a row !
as your table has only 1 column the row consists of only 1 value.
What you require is
$result = mysql_query("SE LECT * FROM t1");
while ($row = mysql_fetch_arr ay($result)) {
echo $x[0];
}
davie wrote:
Mark wrote:
let's say i have a table in my database, with only one column. all i
want to do is retrieve a list of the entries.. i could do it like this
$result = mysql_query("SE LECT * FROM t1");
while( $x = mysql_fetch_row ($result) ) {
echo $x[0];
}
but it seems kinda silly to fetch an entire array, when only the first
index is used. is there a better/more efficient way?
mysql_fetch_row () fetches a row !
as your table has only 1 column the row consists of only 1 value.
What you require is
$result = mysql_query("SE LECT * FROM t1");
while ($row = mysql_fetch_arr ay($result)) {
echo $x[0];
}
uhmm... a row is an array... what exactly is the difference between
your solution and mine?? (aside from also returning an associative
array by default, which i do not need)
perhaps you misinterpreted what i was asking. i'm asking for a solution
that does NOT return an array, but is equally or more efficient.
perhaps this is the best way to do it i guess.
You wanted a list of all entries that is an array
As you have only 1 field (column) per record it is a 1 dimentional
array.
If it had more than 1 field it would be a 2 dimentional array.
mysql_fetch_row () fetches an array of row.
I suggest you read http://www.php.net/manual/en/ref.mysql.php
Mark wrote:
davie wrote:
Mark wrote:
let's say i have a table in my database, with only one column. all i
want to do is retrieve a list of the entries.. i could do it like this
>
$result = mysql_query("SE LECT * FROM t1");
while( $x = mysql_fetch_row ($result) ) {
echo $x[0];
}
>
but it seems kinda silly to fetch an entire array, when only the first
index is used. is there a better/more efficient way?
mysql_fetch_row () fetches a row !
as your table has only 1 column the row consists of only 1 value.
What you require is
$result = mysql_query("SE LECT * FROM t1");
while ($row = mysql_fetch_arr ay($result)) {
echo $x[0];
}
uhmm... a row is an array... what exactly is the difference between
your solution and mine?? (aside from also returning an associative
array by default, which i do not need)
perhaps you misinterpreted what i was asking. i'm asking for a solution
that does NOT return an array, but is equally or more efficient.
perhaps this is the best way to do it i guess.
davie wrote:
You wanted a list of all entries that is an array
As you have only 1 field (column) per record it is a 1 dimentional
array.
If it had more than 1 field it would be a 2 dimentional array.
mysql_fetch_row () fetches an array of row.
I suggest you read http://www.php.net/manual/en/ref.mysql.php
Mark wrote:
davie wrote:
Mark wrote:
let's say i have a table in my database, with only one column. all i
want to do is retrieve a list of the entries.. i could do it like this
$result = mysql_query("SE LECT * FROM t1");
while( $x = mysql_fetch_row ($result) ) {
echo $x[0];
}
but it seems kinda silly to fetch an entire array, when only the first
index is used. is there a better/more efficient way?
mysql_fetch_row () fetches a row !
as your table has only 1 column the row consists of only 1 value.
What you require is
$result = mysql_query("SE LECT * FROM t1");
while ($row = mysql_fetch_arr ay($result)) {
echo $x[0];
}
uhmm... a row is an array... what exactly is the difference between
your solution and mine?? (aside from also returning an associative
array by default, which i do not need)
perhaps you misinterpreted what i was asking. i'm asking for a solution
that does NOT return an array, but is equally or more efficient.
perhaps this is the best way to do it i guess.
in such case it should be used as
$result = mysql_query("SE LECT * FROM t1");
$arr = mysql_fetch_arr ay($result)) ;
foreach($arr as $val) {
// do something with $val
}
if it does indeed retrieve the entire column, no?
I'll look into this more. thanks anyway.
If you have multiple column in your table then use
$result = mysql_query("SE LECT column1 FROM t1");
while( $x = mysql_fetch_row ($result) ) {
echo $x[0];
}
would limit the return data to column1 hence save bandwidth and memory.
Dan.
Mark wrote:
davie wrote:
You wanted a list of all entries that is an array
As you have only 1 field (column) per record it is a 1 dimentional
array.
If it had more than 1 field it would be a 2 dimentional array.
mysql_fetch_row () fetches an array of row.
I suggest you read http://www.php.net/manual/en/ref.mysql.php
Mark wrote:
davie wrote:
Mark wrote:
let's say i have a table in my database, with only one column. all i
want to do is retrieve a list of the entries.. i could do it like this
>
$result = mysql_query("SE LECT * FROM t1");
while( $x = mysql_fetch_row ($result) ) {
echo $x[0];
}
>
but it seems kinda silly to fetch an entire array, when only the first
index is used. is there a better/more efficient way?
mysql_fetch_row () fetches a row !
as your table has only 1 column the row consists of only 1 value.
What you require is
$result = mysql_query("SE LECT * FROM t1");
while ($row = mysql_fetch_arr ay($result)) {
echo $x[0];
}
>
uhmm... a row is an array... what exactly is the difference between
your solution and mine?? (aside from also returning an associative
array by default, which i do not need)
>
perhaps you misinterpreted what i was asking. i'm asking for a solution
that does NOT return an array, but is equally or more efficient.
>
perhaps this is the best way to do it i guess.
in such case it should be used as
$result = mysql_query("SE LECT * FROM t1");
$arr = mysql_fetch_arr ay($result)) ;
foreach($arr as $val) {
// do something with $val
}
if it does indeed retrieve the entire column, no?
I'll look into this more. thanks anyway.
dan wrote:
If you have multiple column in your table then use
$result = mysql_query("SE LECT column1 FROM t1");
while( $x = mysql_fetch_row ($result) ) {
echo $x[0];
}
would limit the return data to column1 hence save bandwidth and memory.
Dan.
Mark wrote:
davie wrote:
You wanted a list of all entries that is an array
As you have only 1 field (column) per record it is a 1 dimentional
array.
If it had more than 1 field it would be a 2 dimentional array.
mysql_fetch_row () fetches an array of row.
I suggest you read http://www.php.net/manual/en/ref.mysql.php
Mark wrote:
davie wrote:
Mark wrote:
let's say i have a table in my database, with only one column. all i
want to do is retrieve a list of the entries.. i could do it like this
$result = mysql_query("SE LECT * FROM t1");
while( $x = mysql_fetch_row ($result) ) {
echo $x[0];
}
but it seems kinda silly to fetch an entire array, when only the first
index is used. is there a better/more efficient way?
mysql_fetch_row () fetches a row !
as your table has only 1 column the row consists of only 1 value.
What you require is
$result = mysql_query("SE LECT * FROM t1");
while ($row = mysql_fetch_arr ay($result)) {
echo $x[0];
}
uhmm... a row is an array... what exactly is the difference between
your solution and mine?? (aside from also returning an associative
array by default, which i do not need)
perhaps you misinterpreted what i was asking. i'm asking for a solution
that does NOT return an array, but is equally or more efficient.
perhaps this is the best way to do it i guess.
in such case it should be used as
$result = mysql_query("SE LECT * FROM t1");
$arr = mysql_fetch_arr ay($result)) ;
foreach($arr as $val) {
// do something with $val
}
if it does indeed retrieve the entire column, no?
I'll look into this more. thanks anyway.
so dont fetch more than you need. got it.
but still..
array mysql_fetch_row ( resource result )
Returns a numerical array that corresponds to the fetched row and moves
the internal data pointer ahead
vs
array mysql_fetch_arr ay ( resource result [, int result_type] )
Returns an array that corresponds to the fetched row and moves the
internal data pointer ahead.
they both return arrays.. but in your case
result_type
The type of array that is to be fetched. It's a constant and can
take the following values: MYSQL_ASSOC, MYSQL_NUM, and the default
value of MYSQL_BOTH.
which defaults to MYSQL_BOTH thus also returns an associative array
which isn't needed...
so IMHO my original solution was ever so slightly more efficient..?
not that i'm trying to stir up an argument, i just don't understand why
you insist that mysql_fetch_arr ay is better than mysql_fetch_row for
this scenario. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ssb |
last post by:
Hello,
This may be very elementary, but, need help because I am new to access
programming.
(1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor
?) the values one by one and populate a combo box with these names.
(this way, I can display all the EMPLOYEE_NAME values)
(2) In general, can I do additional processing on column values from
|
by: Daves |
last post by:
trying to get a boolean value from DataReader (that is, result from a SQL
query);
boolean MyBool = MyDataReader.GetBoolean(3);
well it works using that number 3 but of course I would like to do something
like
... = MyDataReader.GetBoolean;
since I don't always know the field number of the IsLocked field. Why is
|
by: Shujun Huang |
last post by:
Hi,
I am working on converting Informix database to Postgre. I have one
question for fetching records using PostgreSQL. The record I am fetching
is a variable size text string. Before fetching the record, a
preallocated static buffer size will have to be declared beforehand in
the declaration section. Since the record sizes vary a lot, instead of
using the static buffer, is there a dynamic way to fetch these records?
Informix (Oracle...
|
by: Florian Albrecht |
last post by:
Hi there,
as I am trying to write a recordset class, I am interested in fetching
field information from an oracle db. Several information on the fields
are very simple to request. So I already receive the field properties
name, max_length, type not_null, has_default and defaul_value. This is
achieved by using functions like oci_field_name(). But I am not able to
request the information on if the field is primary key or marked as
unique...
|
by: Sandman |
last post by:
So, I have this content management system I've developed myself. The
system has a solid community part where members can register and then
participate in forums, write weblogs and a ton of other things.
So, in instances where I list, for example, the latest weblogs. I list
the headline of the weblog, the date and the name of the member who
wrote it.
Now, the name isn't just "Smith", but rather Smith's online status,
his nick and his...
| |
by: Bhavesh |
last post by:
Hello genious people,
I m trying to insert a LARGE text from Multiline Textbox into my
table
of sqlserver2000. I m using vs-2005.
Please note that I dont want to store blob data From FILE TO TABLE,
like storing IMAGE into DB.
|
by: Bhavesh |
last post by:
Hi Bruce,
Thanks For Reply.
U were right, Needed to pass string , but also need to pass size of
Data( instead of 16, passed actual length of data). So that worked for
me & didn't get any error.
But now problem in fetching, not able to fetch data from table
correctly. Here is my code. I hav following problems with this coding
|
by: joberman |
last post by:
I've about give up with the whole mysql_insert_id function. Always returns a "0". I do have an auto-incrementing field in my database called "ordernumber", which when I query it from another page, always gives the right answer of "45" or "60" or whatever. User fills out simple form on page 1. Form info is POSTed to response Page 2. If all goes well, and user does as instructed (field validation), user gets a nice pretty page to print out...
|
by: nitin005 |
last post by:
hi,
after fetching the data into the datagridview, how to display the value of a particular field of a selected row, in a textbox. it is a windows application in c#
|
by: SunshineInTheRain |
last post by:
I'm trying to modify a long long code within a button click by make the insert/update/delete/select using the same transaction. Purpose is to make sure every operation can be rollback instead of some table inserted but some not. But I get this error:
The SqlCommand is currently busy Open, Fetching.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |