| View previous topic :: View next topic |
| Author |
Message |
Pete23
Joined: 30 Jan 2007 Posts: 3 Location: Worksop, Nr Sheffield
|
Posted: Tue Jan 30, 2007 10:07 pm Post subject: Total PHP/MYSQL beginner needs help |
|
|
Hope this is the right place to try. If not sorry.
I've been building a personal web site and being quite adventurous as a newbie "developer". I started out used a CSS template site to get a layout and then totally rebuilt it using php include files etc. It's taken me ages to get so far without any one to one help, other than using Google to find answers.
I have a selection of discographys of bands i like. This is currently all added in a html file so I thought I'd create a MYSQL table and access the database using PHP and display it just like it is currently in HTML/CSS. The trouble is I haven't a clue how to integrate the PHP code with the HTML. I cannot find any articles to help me understand and for some reason I have a total mental block. Anyone fancy helping me?
The page I am working on is this...http://www.bargh.co.uk/music_neu3.php
It has the php in which pulls out the total list of albums by a band that I've added to my database and these are displaying, but I want them to be formatted like the html/css one at the end. I guess it's simple to you experts but I'm totally baffled.
Hope you can help. If you need anymore info/code let me know |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Wed Jan 31, 2007 11:21 am Post subject: |
|
|
First of everything else welcome
I had a look at your site, cool photos you have there (landscapes, waterfalls...)
I like photography but I'm not a pro, just to enjoy
I am not sure I got what you mean
if I understood correctly you're looking to understand how to display everything correctly and, you're right, there are not so much tutorials or guides on this basic stuff, mostly because it's not a real guide but it's all about understanding how it all works
you have to generate the HTML code with PHP
so for example you'll have a string variable that will contain all the page content coming from the database, along with some HTML
for example, this is not real code but just to make things clear
| Code: |
$query = mysql_query("SELECT song, artist, year, album, albumimage FROM albums WHERE year = 1980");
while($row = mysql_fetch_array($query))
{
if(mysql_num_rows($query) > 0)
{
$content .= "<div class=\"myrowclass\"><div class=\"albumimageclass\"><a href=\"#\"><img src="images/$row['albumimage']"></div><div class=\"albumdata\">Artist: ".$row['artist']."<br/>Title: ".$row['song']."<br/>Album: ".$row['album']."</div>";
}
}
|
and so on
the code might be full of syntax error etc but should be useful to understand how it all works
see that, as you might know, $content is appended each time so you'll have this done for all the records retrieved and your full page content will be generated;
I hope this helps you and I'm on the right track |
|
| Back to top |
|
 |
Pete23
Joined: 30 Jan 2007 Posts: 3 Location: Worksop, Nr Sheffield
|
Posted: Tue Feb 06, 2007 9:12 am Post subject: |
|
|
Thanks for that. I'll see if i can get it to work form your example above. Shame that this is not a busier site. Glad you like the photos  |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Tue Feb 06, 2007 9:20 am Post subject: |
|
|
| Pete23 wrote: | Thanks for that. I'll see if i can get it to work form your example above. Shame that this is not a busier site. Glad you like the photos  |
yep, there's not that much activity, mostly because these forums were born as user support for users having issues with the tutorials
if you need help you know what to do  |
|
| Back to top |
|
 |
|