Web designing newb. Creating a PHP forum from scratch!

That's fair enough then. Next time though, you may want to keep an ordered CSS file. Maybe even use different stylesheets for different elements of the design. This will make it easier to change the appearance of the site, and a hell of a lot quicker. :)

Good luck with. Been following with interest. :)
Thank you for your input. I always used to be very keen about learning CSS someday, especially when I found your site back in the days . . .it was very inspiring :)

Hopefully, I'll starting teaching myself more stuff. I've bookmarked a number of resources that I intend to go back to :)

All in, I'm very pleased with what I managed to knock up, albeit breaking a number of rules and a few things that consist of 'bad practice' but it's all a part of the learning curve I suppose.

Feel like bit of a pillock, I've spent a stupid amount of hours, infact I've never in my life spent so much time on a project. If everything went to plan I could have been looking at 90%. I'm going to try my best but I don't think I can finish what I intended to do, I've been going through the process of trial and for hours and it just isn't working out :(
 
Code:
*Connect to table members, to retrieve avatar info* ~This is the one where everything messes up~

well you'd need to get the avatar for every post - and this is what i don't get.... where are you getting the username from?? if you can get the username, why can't you get the avatar?
 
Code:
*Connect to table members, to retrieve avatar info* ~This is the one where everything messes up~

well you'd need to get the avatar for every post - and this is what i don't get.... where are you getting the username from?? if you can get the username, why can't you get the avatar?

Because of the following reason:

Create_reply constsis of:
reply id
a id
myusername
a reply
a datetime

create_thread:
id
topic
detail
myusername
datetime
view
reply

members:
myusername
mypassword
email
avatar

The top 2 use sessions in order to retrieve myusername.

I've made a mess of things, I exhausted most of my efforts and i'm still trying!

So . . .

> create thread contains all its information
> create reply keep stacking in view thread, both are present in order to make a thread
> members are used share information above such as myusername and in order to post
 
well you're going to have to query the database for each post to get the avatar

$result = mysql_query("SELECT avatar FROM members WHERE myusername = '$post_username'");

hardly ideal but i don't think you can change it now....

really you shouldn't be storing the username in the thread and post tables but rather a user_id from your users table. have you not done any database normalisation before?
 
sorry i haven't got any instant messaging. no one else i know goes online. :p

ignore the last sentence of mine as it's too late to change now.

one dirty workaround is this. somewhere before you start displaying the thread/posts. run a query to build an array of username/avatars like this....

Code:
$result = mysql_query("SELECT * FROM members");
while($row = mysql_fetch_assoc($result)) {
    $avatars[$row['myusername']] = $row['avatar'];
}

now when displaying each post, you can access the avatars array using the username

Code:
echo '<img src="' . $avatars[$username] . " />';

bit of a bodge but should work.... :o
 
Still having problems

Code:
<td>&nbsp;<img src="' . $avatar[$myusername] . "';/></td>
<td>&nbsp;<? echo $rows['avatar']; ?></td>
I've tried echo's just the avatar url but it seems it isn't communicating with the db.

At the very I have following defined:

Code:
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name="create_thread"; // Table name



// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("")or die("cannot select DB");

// get value of id that sent from address bar
$id=$_GET['id'];
$sql="SELECT * FROM $tbl_name WHERE id='$id'";
$result=mysql_query($sql);

$rows=mysql_fetch_array($result);

?>

Bit of html stuff . . and then

Code:
<div>
<? echo $rows['datetime']; ?>
</div>
</td>
</tr>
<?php
$tbl_name2="members"; // Table name


$result2 = mysql_query("SELECT * FROM members");
while($row = mysql_fetch_assoc($result2)) {
    $avatar[$row['myusername']] = $row['avatar'];
}
?>

<td>
<!-- user info -->
<table class="t5" cellspacing="6" >
<tr>
[B]<td>&nbsp;<img src="' . $avatar[$myusername] . "';/></td>
<td>&nbsp;<? echo $rows['avatar']; ?></td>
<td class="bigusername"><? echo $rows['myusername']; ?></td>[/B]
<td width="100%">&nbsp;</td>
<td valign="top" nowrap="nowrap">
<div></div>
</div> 
</td>
</tr>
</table>
</td>

Thanks once again marc.
 
Last edited:
something like....

Code:
$post_username = $row['myusername'];
?>
//html
<td>&nbsp;<img src="<?php echo $avatars[$post_username]; ?>" /></td>
<td class="bigusername"><?php echo $post_username; ?></td>
//html
 
Starting to make some progress, it's only displaying the same image for all users, in the db 2 users have different avatars set, yet it's only showing one :\
 
This is really retarded :\

Every member has to have an avatar and even then it will only display 1 image and that was whatever was most recently added to the db :confused:
 
well i assumed you were getting $row['myusername] inside some sort of loop? if it's displaying the right username in text, then the avatar should work as well.

to debug, just after

Code:
$result2 = mysql_query("SELECT * FROM members");
while($row = mysql_fetch_assoc($result2)) {
    $avatar[$row['myusername']] = $row['avatar'];
}

add these lines of code

Code:
print_r($avatar);
die;

does that match the username to the correct avatar?

now when you access the avatar array using this code $avatar[$post_username] - it should return the correct url. just looking back at the first page- avatars are optional. maybe you should leave it out? :)
 
I'd like to thank everyone for their contribution, in particular I'd like to thank you marc. You've been superb and very patient. Thank you.

I've learnt so much is a short amount of time, I've now go to the urge to spend some of my free time designing a personal site for myself.

I'm still very curious on a number of issues, I intend to add a little more to this forum, as I'm convinced I can finish what I started :)

marc, after taking out the die; statement it seems it's definitely storing every users avatar, however it's refusing to display them. What do you make of this?:

avsii9.jpg
 
Why dont you just give everyone in the same class the same avatar, like this forum. Then just create one class, therefore one avatar, is that allowed ?

Great work though, considering you didnt have a clue to start with.

Make sure what you hand in doesnt then belong to the Uni, so a they dont sell it, and b you can use it in the future!
 
Just got my marks back, I got 82/100. If I had managed to scrape some better admin features and got quotes and edits working I could have been looking at 95-100!

Ah well, all in it was a great experience. I hope to re-visit it sometime soon and work on it.

I thank you all for everything especially marc2003 :)
 
Back
Top Bottom