Need Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
brookside
Forum Commoner
Posts: 30
Joined: Tue Mar 02, 2004 8:15 pm

Need Help

Post by brookside »

I have a question. I have a database that keeps information about a person. I am accessing the database and displaying their information in the browser. I have a problem with multiple fields. For instance. We have 3 phone numbers for that one individual. When I query the database to display their information, the first phone number stored is displayed three times, instead of each phone number in a seperate text box. How can I manipulate php to get a phone number, then get the next phone number, and finally get the third. I have this problem with multiple addresses also.

Thank you
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post by andre_c »

what does the db table look like?
brookside
Forum Commoner
Posts: 30
Joined: Tue Mar 02, 2004 8:15 pm

Post by brookside »

I have an Address_ID, then Street, city, state and zip. There are three different addresses stored in the database, but it repeats the first one three times?
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

show some code? 8)
brookside
Forum Commoner
Posts: 30
Joined: Tue Mar 02, 2004 8:15 pm

Post by brookside »

**I DO MY QUERIES UP HERE**
if($numRows > 0
{
while($rows = mysql_fetch_array($result))
{
echo '
brookside
Forum Commoner
Posts: 30
Joined: Tue Mar 02, 2004 8:15 pm

Post by brookside »

**I DO MY QUERIES UP HERE**
if($numRows > 0
{
while($rows = mysql_fetch_array($result))
{
echo '**THIS IS WHERE I ECHO OUT MY FORM THAT WILL BE DISPLAYED ON THE BROWSER CONTAINING THE INDIVIDUAL'S INFORMATION..
...
...
<input name="txtAreaCode1" type="text" id="txtAreaCode1" value="'.$rows['Area_Code'].'" size="5" maxlength="3"> **This will display a text box and put the area code in it.

<td><input name="txtPhoneNumber1" type="text" id="txtPhoneNumber1" value="'.$rows['Number'].'" size="10" maxlength="7"></td> **this puts the number into a text box

I just repeat this step three times, each time I name the txtBox and id a different name.
Pozor
Forum Commoner
Posts: 74
Joined: Tue Mar 30, 2004 11:11 pm
Location: Switzerland

Post by Pozor »

Hello,
<td><input name="txtPhoneNumber1" type="text" id="txtPhoneNumber1" value="'.$rows['Number'].'" size="10" maxlength="7"></td> **this puts the number into a text box

I just repeat this step three times, each time I name the txtBox and id a different name.
ok but was is with $rows['Number'], this is every time the same!

Please show your table and your sql query, otherwise it will be difficult to locate the mistake...

table like this with the most important informations
name: tablename
column1: columnname varchar(20)
column2: columnname varchar(20)
etc....

SQL like:

SQL SELECT column, column2 FROM tablename WHERE id = '100' //just an example
Post Reply