473,503 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MySql and PHP "Using WHERE in a SELECT statememt"

Ric
i have a basic php file that is trying to select information from a
mysql database.

echo "<br>";
include("dbConnect.inc");
$query = "SELECT * FROM client";
$result = mysql_query($query) or die("no select");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "Welcome ".$fName." ".$lName." - ".$deptID."<br>";
}

this works, but it doesnt return the first record from the table. when
i add a WHERE statement, nothing is returned. im using phpMyAdmin to
administer mysql. i can get all of the rows from the client table when
i browse from phpMyAdmin.

also, i can use PEAR database abstraction layer and it retrieves all
records and WHERE works in the select. is there a mysql or php setting
im missing?

im using mysql 4.01 and php 4.3
Jul 17 '05 #1
2 3220
Ric wrote:
i have a basic php file that is trying to select information from a
mysql database.

echo "<br>";
include("dbConnect.inc");
$query = "SELECT * FROM client";
$result = mysql_query($query) or die("no select");
$row = mysql_fetch_array($result,MYSQL_ASSOC); ### get the *FIRST* record into $row
while ($row = mysql_fetch_array($result)) ### get the *SECOND* (or 3rd, 4th, ...) record into $row
{
extract($row);
echo "Welcome ".$fName." ".$lName." - ".$deptID."<br>";
}

this works, but it doesnt return the first record from the table. when
i add a WHERE statement, nothing is returned.


remove the first mysql_fetch_array() and it should be ok
HTH

--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
Jul 17 '05 #2
Ric
thx. that worked. i really appreciate the help.

Pedro <he****@hotpop.com> wrote in message news:<bm************@ID-203069.news.uni-berlin.de>...
Ric wrote:
i have a basic php file that is trying to select information from a
mysql database.

echo "<br>";
include("dbConnect.inc");
$query = "SELECT * FROM client";
$result = mysql_query($query) or die("no select");
$row = mysql_fetch_array($result,MYSQL_ASSOC);

### get the *FIRST* record into $row
while ($row = mysql_fetch_array($result))

### get the *SECOND* (or 3rd, 4th, ...) record into $row
{
extract($row);
echo "Welcome ".$fName." ".$lName." - ".$deptID."<br>";
}

this works, but it doesnt return the first record from the table. when
i add a WHERE statement, nothing is returned.


remove the first mysql_fetch_array() and it should be ok
HTH

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
5641
by: ian justice | last post by:
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've...
16
2462
by: lkrubner | last post by:
Are there any benchmarks on how much an extra, unneeded VARCHAR, CHAR, INT, BIGINT, TEXT or MEDIUMTEXT slows down a database call with MySql? PostGre info would also be useful. I'm trying to...
9
10876
by: Scott Beavers | last post by:
I'm trying to create a form in Excel to sort from the form and take the data to another worksheet. I am very new to this and any help would be appreciated. I have a value in a cell that will...
2
2094
by: caprice | last post by:
I'm a MySQL newbie. As I have to access MySQL database in Pocket PC, I'm developing a evc++ program to read and retrieve data from MySQL table. Where can I get some detail information about how...
0
1785
by: Justin | last post by:
Hi. I decided to tidy up some of my queries, but I came across something that stumpt me: mysql> SELECT -> jobs.jobId, -> jobs.active, -> jobs.title, -> jobs.listed, -> ...
10
5584
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
6
2513
by: Don Leverton | last post by:
Hi All, I've got a situation where I am developing an Access 97 app for a client, and am in the "beta testing" stage. I have split the app up, using the DB splitter, into front-end /back-end...
2
3025
by: google | last post by:
Hello everyone, I am having an issue using the "Multi Select" option in a list box in MS Access 2003. I am making a form that users can fill out to add an issue to the database. Each issue can...
2
5952
by: sudhakaranr | last post by:
Hi Guys.... My input is something like this "c1cc(c(cc1)I)/C=N\n1c(nnc1)S". You can see the "\n" in between the input. It is not a newline character as my input has that...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7273
Oralloy
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,...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6982
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...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5000
isladogs
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...
0
3161
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...
0
1501
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 ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.