Easy input into tables
Moderator: General Moderators
-
phpnewbie1985
- Forum Commoner
- Posts: 33
- Joined: Thu Jan 08, 2004 6:15 am
Easy input into tables
Hi, as you can probably tell my the name im new to PHP so be gentle! :S I want to have a text file on server which i can update from time to time and then a page called "table.php" will load each row in the text file into a new row in a table.. is this possible? if so could somebody please explain how i could do this?
Many thanks
Chris
Many thanks
Chris
Of course this is all possible. But would you not like to use a database instead. You can update it very easily. Have a look around for a few tutorials and don't hesitate: ask here for directions.
Depends how newbie you arethisis quite good.
Dr Evil
Depends how newbie you arethisis quite good.
Dr Evil
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
-
phpnewbie1985
- Forum Commoner
- Posts: 33
- Joined: Thu Jan 08, 2004 6:15 am
HELLP!!
I have made a database called matrix_lists with a table called nokia6600 and a record in it. now when i try to retrieve the data from the database it says Connected Successfully, Could not select database... I got the code striaght from php.net and im just confused now!!!
HELP!
Many thanks
Chris
HELP!
Code: Select all
<?php
/* Connecting, selecting database */
$link = mysql_connect("localhost", "username", "password")
or die("Could not connect : " . mysql_error());
echo "Connected successfully";
mysql_select_db("matrix_lists") or die("Could not select database");
/* Performing SQL query */
$query = "SELECT * FROM nokia6600";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
/* Printing results in HTML */
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $name) {
echo "\t\t<td>$name</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
/* Free resultset */
mysql_free_result($result);
/* Closing connection */
mysql_close($link);
?>Chris
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Try changing:
to
to see if you get a more useful error message.
Mac
Code: Select all
mysql_select_db("matrix_lists") or die("Could not select database");Code: Select all
mysql_select_db("matrix_lists") or die("Could not select database".'<p>'.mysql_error().'</p>');Mac
-
phpnewbie1985
- Forum Commoner
- Posts: 33
- Joined: Thu Jan 08, 2004 6:15 am
WOOHOO
Brilliant! i had not assigned that user to database... dumb ass i am! :S thanks for all your help!
its much appreciated! thats why i love this forum such speedy replies!
Chris
Chris