473,652 Members | 2,935 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("dbConn ect.inc");
$query = "SELECT * FROM client";
$result = mysql_query($qu ery) or die("no select");
$row = mysql_fetch_arr ay($result,MYSQ L_ASSOC);
while ($row = mysql_fetch_arr ay($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 3238
Ric wrote:
i have a basic php file that is trying to select information from a
mysql database.

echo "<br>";
include("dbConn ect.inc");
$query = "SELECT * FROM client";
$result = mysql_query($qu ery) or die("no select");
$row = mysql_fetch_arr ay($result,MYSQ L_ASSOC); ### get the *FIRST* record into $row
while ($row = mysql_fetch_arr ay($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_arr ay() 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("dbConn ect.inc");
$query = "SELECT * FROM client";
$result = mysql_query($qu ery) or die("no select");
$row = mysql_fetch_arr ay($result,MYSQ L_ASSOC);

### get the *FIRST* record into $row
while ($row = mysql_fetch_arr ay($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_arr ay() 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
5665
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 reduced my form request to a simple text string entry, instead of my desired optional parameters. As i have been stuck with a single unfathomable glitch for over a year. Basically, if i enter queries such as ; "select * from table" "select * from...
16
2477
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 explain to some friends the utility of making database calls return only needed data. As an example of what I'm talking about, suppose we had a database table sort of like this:
9
10887
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 direct what sheet I want the cells copied to, so I thought I could use an If statement but have been unable to right the code properly, ie... If "f2" = 1 Then Sheets("XX1").Select
2
2102
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 "select" and "where" statements work in the format, index and data files of MySQL database? Thanks a tone!!!
0
1795
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, -> industries.industry, -> occupations.occupation,
10
5613
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 create a single View and specify also in this View the WHERE clause that is common in these stored procedures, I will have the new stored procecures changed to be like:
6
2522
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 for the usual reason ... so I can mess with form/report revisions. Since splitting, I've had issues with re-linking the tables ... as it relates to the completetely different "My Documents" data paths on several different Win98 / Win XP computers.
2
3033
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 be associated with multiple categories. I have an "Issue," "IssueCategory," and "Category" in the database (among other tables). The form has a subform in it which is tied to the "IssueCategory" table. The main form is tied to the "Issue"...
2
5974
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 character. I want to insert the input as it is. But When I try to insert into mysql database, it's stored as two lines like the below.. c1cc(c(cc1)I)/C=N 1c(nnc1)S I want to insert as it is!!!!!!
0
8370
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8811
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, 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...
1
8470
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,...
0
7302
agi2029
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...
1
6160
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 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...
0
5620
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();...
0
4147
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...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
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.