hi there,
I'm quite new to php/MySQl and I was wondering if anyone could help me out. I've basically got a MySQL database with a table called 'Ultra'. In this table i have three fields; 'webspace, database and email' Each of these fields is eaither going to contain a number (from 1 up to about 500000, or is going to say Unlimited) I have two questions, what properties should I set for the fields? should they be set as text or as varchars, what length and null or not null? My second question is i would like to be able to display in plain text on my webpage the data contained in one of the cells. For example I would like to be able to display the data contained in the webspace column as 'unlimited' or as say '100'. Could somebody please write me a small, simle script that I could use for this purpose. i should be able to edit it myself, I just need something that will work for now. My database is at localhost, user = root and has no password. Thank you for any help in advance,
-james moore
displaying data from a MySQL table
Moderator: General Moderators
-
shadow_blade47
- Forum Newbie
- Posts: 12
- Joined: Fri Nov 07, 2003 3:41 am
- Lord Sauron
- Forum Commoner
- Posts: 85
- Joined: Tue Apr 20, 2004 5:53 am
- Location: Tilburg, NL
You should set the fields to text. As for the code try something like:
That will display all of the emails in the table ultra. You should seriously consider buying a book or at least reading some tutorials.
Code: Select all
<?php
$link = mysql_connect("localost","root","");
mysql_select_db(dbname) or die(mysql_error());
$query = "SELECT * FROM Ultra";
$result = mysql_query($query) or die(mysql_error());
while (true)
{
$row = mysql_fetch_assoc($result);
if ($row == false) break;
$email = $row['email'];
print($email);
}
mysql_close($link);
?>