Page 1 of 1

displaying data from a MySQL table

Posted: Mon Mar 08, 2004 12:43 pm
by shadow_blade47
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

Posted: Thu Aug 26, 2004 1:34 pm
by Lord Sauron
Just read some tutorials, practise a little and when you still encounter problems, you can always come back with specific questions. If you want someone to write your scripts, then were is the fun in programming it yourself?

Posted: Thu Aug 26, 2004 1:53 pm
by Joe
You should set the fields to text. As for the code try something like:

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);
?>
That will display all of the emails in the table ultra. You should seriously consider buying a book or at least reading some tutorials.

Posted: Thu Aug 26, 2004 1:56 pm
by Draco_03
Try out the tutorial I made..
They'r in my signature