Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Outputting a table from MySql database


  • Please log in to reply

#1
TheWern

TheWern

    Member

  • Member
  • PipPip
  • 81 posts
Hi All,
I have set up a MySql table with 15 cols of various data. Each row then represents a single transaction. There would be up to 25 rows max. The first col will be no's from 0-up to 25, but there may only be eg. 4 rows in the table at the time when they're viewed.

I've tried to create code with loops to retrieve line by line to output to a page with a table built into it. It goes into never-ending loops and I cant seem to find a way to retrieve 'as many' lines are there. I'm sure there is a simple-ish way to do this, but I cant find a working example to study.

Any ideas? ? ?
  • 0

Advertisements


#2
ditto

ditto

    - i pwn n00bs -

  • Member
  • PipPipPipPip
  • 1,260 posts
How are you accessing the data in the mysql database.

I am going to assume that you are using php.

This will give you a place to start.
http://www.thescript...ases/index.html
  • 0

#3
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
I normally do something like this, it is a bit different that that shown in ditto's link

$result = mysql_query("SELECT col FROM table") or die(mysql_error());
while($row = mysql_fetch_array($result)) {
	$col = $row['col'];
	//do something with $col
}

  • 0

#4
TheWern

TheWern

    Member

  • Topic Starter
  • Member
  • PipPip
  • 81 posts
Thanks for that Guys - I have it sorted now.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP