![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Oct 2006
Posts: 15
Rep Power: 0
![]() |
Trouble Retrieving Records From Database
Hi
I'm currently working on a website where people can submit links to music they have made. The submission form is now working (thanks to help from Styx) but now when I try to retrieve the contents of the database to display them on a page it doesn't seem to be able to. Here's the code I'm using to display them: [php] $username="*******"; $password="*******"; $database="*******"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die("Unable to connect to database"); $query="SELECT * FROM tunes"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; echo '<table border="1" align="center"> <tr> <td colspan="4"><center>Database contents</center></td> </tr> <tr> <td>Artist</td><td>Title</td><td>Genre</td><td>URL</td>'; while($i<$num) { $title=mysql_result($result,$i,"title"); $artist=mysql_result($result,$i,"artist"); $genre=mysql_result($result,$i,"genreID"); $url=mysql_result($result,$i,"url"); echo "<tr> <td>$artist</td> <td>$title</td> <td>$genre</td> <td>$url</td> </tr>"; $i++; } echo "</table>"; [/php] All the attribute names are correct and I'm doing things exactly the same as a tutorial said but this is how it's coming out: http://www.electricjustice.com/viewtracks.php As you can see, only the 'title' and 'url' attributes are being shown Any advice? Thanks Banjo |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() ![]() |
Change query to be this:
$query="SELECT title,artist,genreID,url FROM tunes"; Then try this while loop... while ($myrow = mysql_fetch_row($result))
{
echo "$myrow[0]<br>$myrow[1]<br>$myrow[2]<br>$myrow[3]<br><p>"";
}I haven't tested this, but it should work.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#3 | |
|
Newbie
Join Date: Oct 2006
Posts: 15
Rep Power: 0
![]() |
Quote:
|
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
hah, always the small things eh?
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Oct 2006
Posts: 15
Rep Power: 0
![]() |
Yeah - too much of the time
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Storing BLOBs in a database - problem | jonyzz | Other Programming Languages | 8 | Jan 31st, 2007 4:38 AM |
| .NET/ADO/MSACCESS database | hbe02 | Other Programming Languages | 4 | Sep 8th, 2006 2:57 PM |
| searching an access database? | designXperts.net | Visual Basic .NET | 12 | Nov 27th, 2005 5:03 PM |
| Using ODBC to connect to a remote database in a C program | bigi | C++ | 1 | Mar 8th, 2005 3:19 PM |