Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Reading out data from tables.

Author  Topic 

seanghatch
Starting Member

6 Posts

Posted - 2004-11-11 : 12:25:58
Hello, I am an sql n00b, but I'm pretty good with the PHP side of things.

My question is: How can I make PHP do something once for every row of my table there is. What I'm trying to do is list out all the entries in my table. Could I set this up in a while( ) loop? I'm not sure.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-11-11 : 13:43:15
No need for a loop. Looping will cause performance problems. To do something for each row, you need to think set-based. Please post your table structure and explain what you want to do with some sample data and the expected result set, then we'll be able to help you out better.

Tara
Go to Top of Page

seanghatch
Starting Member

6 Posts

Posted - 2004-11-11 : 13:59:17
Deal.

I have a table called visits, with 3 fields: name, email, times. I'd like to print them out something like this

Name: Kevin
email: Kevin@Kevin.com
Times Visited: 6
<hr>

I'd also like to include some css elements, but if you could just help me with this, I think I could figure that out.
Go to Top of Page

seanghatch
Starting Member

6 Posts

Posted - 2004-11-11 : 14:00:40
Oops, forgot to mention that I'd like to do what I did in the above example for all rows of the table.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-11-11 : 14:03:58
Your PHP code would handle how to display it, but here's the code to get the data:

SELECT Name, email, Times
FROM Visit

Tara
Go to Top of Page

seanghatch
Starting Member

6 Posts

Posted - 2004-11-11 : 15:02:10
Alright Thanks, but could you show me how to output it? I thought I knew but I'm having troubles.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-11-11 : 15:26:04
I'm not familiar with PHP. I'd try a PHP site for specific coding questions.

Tara
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-11-11 : 15:29:11
Seeing that you are using PHP, I assume it is relevant to ask:

Are you trying to connect to a MySQL database or a Microsoft SQL Server database ?


- Jeff
Go to Top of Page

seanghatch
Starting Member

6 Posts

Posted - 2004-11-11 : 15:42:41
mysql
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-11-11 : 15:46:31
You've reached an MS SQL Server site. Try the mysql forum over at dbforums.com. I believe they even have a PHP forum there.

Tara
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-11-11 : 15:48:01
Ha! I knew it !!!!



Damn, I'm good.

- Jeff
Go to Top of Page

seanghatch
Starting Member

6 Posts

Posted - 2004-11-11 : 15:53:37
Sorry dudes
Go to Top of Page
   

- Advertisement -