Page 2 of 2
Posted: Thu Jan 08, 2004 8:09 am
by malcolmboston
lol bech
you should know by now the amount of times ive posted here
my net is down @ home and im @ uni, my web server account at uni only supports HTML not PHP, so i cant test it until i get on my web server at home, NET BACK ON IN 2 WEEKS!!! 2mb wahoooo!
still though what the hell is that code for!?!?!?!!?
also i was wondering, i heard about a function in PHP ythat turns a numerical value into a picture/graph is this true?
Posted: Thu Jan 08, 2004 8:10 am
by JayBird
i think fastfingertips was getting excited and maybe didn't read the problem correctly. i would just ignore it. Unless he can tell you otherwise
Mark
Posted: Thu Jan 08, 2004 8:12 am
by malcolmboston
yeah thats what i thought, i mean ive pretty much done exactly the same thing as i have done before sucessfully, only without the "double SQL filter"
Posted: Thu Jan 08, 2004 8:13 am
by JayBird
well, i shoudl work now if you use the corrected query i gave you
Mark
Posted: Thu Jan 08, 2004 8:15 am
by malcolmboston
thank you bech, you are always helpful
cheers mate
Posted: Fri Jan 09, 2004 9:32 am
by malcolmboston
ok guys last night i edited and compacted all of the code i had into this
Code: Select all
<?php
$_SESSION['username'] = malcolmboston;
// database variables for connections
$host = "localhost";
$user = "malcolmboston";
$password = "xxxxxxxx";
$DBname = "tees-drug-network";
$tablename = "private_messaging";
//connection variables completed
// establishing connections
$link = mysql_connect ($host, $user, $password);
//connection established
//the query defined
$query = "SELECT *
FROM $tablename
WHERE recipient = '".$_SESSION['username']."'
AND Read_Unread = 'unread'";
// select the database
mysql_select_db($DBname);
// query the database
$result = mysql_query($query);
$data = mysql_fetch_array($result, MYSQL_ASSOC);
//statement to see if theres any new e-mail for the user
if (mysql_num_rows($result) >=1) {
header("mail_yes.php");
} else {
header("mail_no.php");
}
exit;
now that will print my unread messages, ok thats done and working
how should i go about gathering unread messages?
should i create a new query or is there something else i can do?
also this is the bit i think i may have problems on
i had alot of problems trying to display what it actually in the array, i could only view what was in it with this
is there anyway i could easily echo it in a page as what i usually do to do this isnt working!
after i know this then it'll be nearly completed
thanks in advance
Posted: Fri Jan 09, 2004 9:41 am
by JayBird
what do you usually do?
Posted: Fri Jan 09, 2004 9:59 am
by malcolmboston
well my code for one of my other projects is very similar
but this wont work

Posted: Fri Jan 09, 2004 10:03 am
by JayBird
yeah, becuase you have a query that has return numerous rows.
What you need to do is this (your first useful use for a loop

)
Code: Select all
while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) {
print $data['recipient'];
}
and remove this line, you don't need it
Code: Select all
$data = mysql_fetch_array($result, MYSQL_ASSOC);
Mark
Posted: Fri Jan 09, 2004 10:08 am
by malcolmboston
ok cool, thanks alot, just one more question for when i come to echoing it for the user
say i have 16 unread messages each one coming from a different row
how do i turn row 1 into a var, row to into another var etc
i might no how to do this, because i only managed to fix the code i submitted 2 mins before i came out so didnt get to test this out, but it wouldnt do it last night
Posted: Fri Jan 09, 2004 10:14 am
by JayBird
malcolmboston wrote:say i have 16 unread messages each one coming from a different row
how do i turn row 1 into a var, row to into another var etc
Why would you want to do that? The code i gave you will echo ALL unread messages (obviously you need to add the other print statement to print the other columns from the DB).
Mark
Posted: Fri Jan 09, 2004 10:16 am
by malcolmboston
ah yeah sorry, i missed the comment about the loop
now getting the read messages i can do, dont need any code, just wondered what is the standard way of doing it?
creating a new query or something else?
Posted: Fri Jan 09, 2004 10:18 am
by JayBird
i would do another query and select the messages that are read.
Mark
Posted: Fri Jan 09, 2004 10:22 am
by malcolmboston
cheers bech, its appreciated