Jump to content


icons (PHP)


3 replies to this topic

#1 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 03 September 2007 - 08:50 PM

Right now im building my own forums, and im having trouble getting an image to display if the user hasnt been to the forums before or if theres a new post since there last visit. Here what I have so far:

<?php
$tocheckrep = mysql_query("SELECT * FROM topics WHERE tid = '$topic[id]' ORDER BY id DESC LIMIT 1")or die("CCE: ".mysql_erorr());
$lastchckrep = mysql_fetch_array($tocheckrep);
$check_last_rep = $lastchckrep['pos'];
if (isset($_SESSION['TW_forum_second'])){
$check_cookie_var_now = $_SESSION['TW_forum_second'];
//start of inside
if ($did!='no' && $topic[is] != "lock" && $check_cookie_var_now<$check_last_rep){
echo ('<img src="icons/default.png">');
}
if($did!='no' && $topic[is] != "lock" && $check_cookie_var_now>$check_last_rep){
$_SESSION['TW_forum_second'] = date("ymdgis");
echo ('<img src="icons/new.png">');
$did = 'no';
}
if ($topic[is] == "lock"){
echo("<img src='icons/locked.png'>");
}
//end of the inside
}
if(!isset($_SESSION['TW_forum_second']) && $topic[is] != "lock"){
$_SESSION['TW_forum_second'] = date("ymdgis");
echo ('<img src="icons/new.png">');
$did = 'no';
}
?>

Edited by Hip Hop Artist, 03 September 2007 - 08:50 PM.


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 03 September 2007 - 10:47 PM

From what i have read in your previous posts, you don't seem to be very experienced in php. As such, i would strongly recommend holding off on building a forum till you get a bit more experience.

Quote

or if theres a new post since there last visit
While i have no ideas on how to go about your first question at the present, i know that part has been discussed here at length, and i would recommend you do a forum search for it (you will find that the topic is still unresolved, if you have a resolution for it, please revive that topic. Till then stick to the first part of the question...).

Edited by rc69, 03 September 2007 - 10:48 PM.


#3 Braunson

    Young Padawan

  • Members
  • Pip
  • 237 posts
  • Gender:Male
  • Location:Ontario, Canada

Posted 06 September 2007 - 08:05 PM

Code = Cleaned up a bit.

I think the problem might of been the SQL ($tocheckrep) and so i fixed that as well as a > to an <.
That should work.

<?php

	$tocheckrep = mysql_query("SELECT * FROM `topics` WHERE `tid` = ".$topic['id']." ORDER BY `pos` DESC LIMIT 1")or die("CCE: ".mysql_error());
	$lastchckrep = mysql_fetch_array($tocheckrep)or die("CCE: ".mysql_error());

	$check_last_rep = $lastchckrep['pos'];
	$curr_date = date("ymdgis");
	$curr_sess = $_SESSION['TW_forum_second'];

		if(isset($_SESSION['TW_forum_second'])){
			$did = 'no';
		}
		
		if(!isset($did)){
			$_SESSION['TW_forum_second'] = $curr_date;
		}
		
		if($check_last_rep > $curr_sess){
			echo '<img src="icons/new.png">';
		}

		if($check_last_rep < $curr_sess){
			echo '<img src="icons/default.png">';
		}
	
		if($topic[is] == "lock"){
			echo '<img src="icons/locked.png">';
		}
?>

Edited by Braunson, 06 September 2007 - 08:17 PM.


#4 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 07 September 2007 - 01:52 PM

yup that worked perfect thanks.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users