Tutorialstream.com Forum Index
 FAQ   Search   Members   Usergroups   Register   Profile   Log in to check your private messages   Log in 

Log in
Username:    Password:      Log me on automatically each visit    
Total PHP/MYSQL beginner needs help

 
Post new topic   Reply to topic    Tutorialstream.com Forum Index -> Web Design
View previous topic :: View next topic  
Author Message
Pete23



Joined: 30 Jan 2007
Posts: 3
Location: Worksop, Nr Sheffield

PostPosted: Tue Jan 30, 2007 10:07 pm    Post subject: Total PHP/MYSQL beginner needs help Reply with quote

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
View user's profile Send private message Visit poster's website
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Wed Jan 31, 2007 11:21 am    Post subject: Reply with quote

First of everything else welcome Wink
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
View user's profile Send private message Send e-mail Visit poster's website
Pete23



Joined: 30 Jan 2007
Posts: 3
Location: Worksop, Nr Sheffield

PostPosted: Tue Feb 06, 2007 9:12 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Tue Feb 06, 2007 9:20 am    Post subject: Reply with quote

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 Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Tutorialstream.com Forum Index -> Web Design All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

phpBB SEO URLs V2 - Icons by Mark James

Powered by phpBB © 2001, 2005 phpBB Group