Page 1 of 1
how could i do this??
Posted: Tue Aug 02, 2005 6:52 am
by ericburnard
Hi again.
i have a email system which uses a db. when a new email is sent (enterd into the database) the feild "new" defults as 1. Now in my inbox i have it so that it displays the number 1 from the db next to the email. I would like to know to things.
How can i make it so that if when the email is read it changes the 1 to a 0.
Can instead of the number 1 or 0 now beig displayed in the inbox a checkbox be ticked or an image displayed for each number so the user can tell if they have read the email or not.
Hope this makes sence :s
Thanks
Eric
Posted: Tue Aug 02, 2005 7:12 am
by feyd
changing a field involves:
UPDATE
as for showing a checkbox or image, use an
if to tell you which to actually display...
Posted: Tue Aug 02, 2005 8:18 am
by ericburnard
i no the if function is really really simple but i cnt get it to work. i have a loop with echos in to display the latest mail but i cant seem to get it to work with the if function in:S what am i doing wrong?
Code: Select all
<?
include('http://eric.madashatters.com/header.inc');
?>
<?php
// Connecting, selecting database
mysql_connect('localhost', '*******', '*****')
or die('Could not connect: ' . mysql_error());
mysql_select_db('madashat_mail') or die('Could not select database');
echo "<BR>";
$offset = $_GET['offset'];
if($offset == "") $offset = 0;
$max = $offset + 10;
$username = mysql_real_escape_string($_GET['user']);
$query = "SELECT * FROM pm WHERE user='$username' order by id desc";
$result = mysql_query($query) or die(mysql_error());
$rows = mysql_numrows($result);
if($max > $rows) $max = $rows;
echo "<center><u><b>Inbox</u></b><br><BR><a href='http://eric.madashatters.com/sendmail.php?user=".$username."'>New Email Message</a> | <a href='http://eric.madashatters.com/sentmail.php?userm=".$username."'>Sent</a><br><table align='middle' cellpadding='5' style='border: dotted 1px'>
<tr>
<td><div class='white'>New</td>
<td><div class='white'>Date</td>
<td><div class='white'>Subject</td>
<td><div class='white'>Sender</td>
<td><div class='white'>Delete</td>";
for($i=$offset;$i<$max;$i++){
$subject = mysql_result($result,$i,"subject");
$new = mysql_result($result,$i,"new");
$message = mysql_result($result,$i,"message");
$date = mysql_result($result,$i,"date");
$sender = mysql_result($result,$i,"sender");
$id = mysql_result($result,$i,"id");
echo "<tr style='border: dotted 1px'>";
echo "<td><div class='white'>";
if ($new = 1)
echo 'New';
echo "</td>";
echo "<td><div class='white'>$date</td>";
echo "<td><div class='white'><a href='http://eric.madashatters.com/readmail.php?user=".$user."&mail=".$id."'>$subject</a></td>";
echo "<td><div class='white'>$sender</td>";
echo "<td></td>";
echo "</tr>";
}
?>
</table> <BR><BR>
<?
include('http://eric.madashatters.com/footer.inc');
?>
i guessed i would have to put it in an echo function but that dosnt seen to want to work either.
Any ideas??
Thanks again
Eric
Posted: Tue Aug 02, 2005 8:20 am
by theda
You don't echo mysql functions...
Posted: Tue Aug 02, 2005 8:23 am
by ericburnard
theda wrote:You don't echo mysql functions...
so what would i do with the if function then to get it to work?? because at the moment its saying that all messages are new
Eric
Posted: Tue Aug 02, 2005 8:28 am
by theda
I was just saying you dont echo mysql functions.
Oh, I'm curious what does "<you><b>Inbox</you>" <- what do the you tags do? Edit: Oh yeah, dumb filter changes the underline tag <_<
Posted: Tue Aug 02, 2005 8:35 am
by ericburnard
theda wrote:I was just saying you dont echo mysql functions.
Oh, I'm curious what does "<you><b>Inbox</you>" <- what do the you tags do? Edit: Oh yeah, dumb filter changes the underline tag <_<
thats good then lol cos i cudnt remember putting them in

i still cant seem to get it to work. any pointers at all ??
eric
Posted: Tue Aug 02, 2005 12:42 pm
by josh
$rows = mysql_numrows($result);
should be mysql_num_rows
PHP should throw a syntax error about that, unless you turned down error reporting which is NOT recommended during development