Ben aşağıdaki yapıda 'mesg' adında bir veritabanı tablo var:
receiver_id | sender_id | message | timestamp | read
Örnek:
2 *(«me)* | 6 *(«nice girl)* | 'I like you, more than ghoti' | yearsago | 1 *(«seen it)*
2 *(«me)* | 6 *(«nice girl)* | 'I like you, more than fish' | now | 1 *(«seen it)*
6 *(«nice girl)* | 2 *(«me)* | 'Hey, wanna go fish?' | yearsago+1sec | 0 *(«she hasn't seen it)*
Ben başarmak istiyorum oldukça zor bir şey.
most recent message (= SİPARİŞ zaman DESC) + 'kişi adı' + her 'konuşma' zamanı: Ben almak istiyorum.
- İletişim name = uname NEREDE uid = 'contact ID' (kullanıcı adı başka bir tablo)
- Contact ID = if (SessionID * (me «) * = sender_id) {} else {receiver_id sender_id}
- Konuşma olduğunu me = receiver OR me = sender
Örneğin:
From: **Bas Kreuntjes** *(« The message from bas is the most recent)*
Hey $py, How are you doing...
From: **Sophie Naarden** *(« Second recent)*
Well hello, would you like to buy my spam? ... *(«I'll work on that later >p)*
To: **Melanie van Deijk** *(« My message to Melanie is 3th)*
And? Did you kiss him? ...
Yani kaba bir çıkıştır.
QUESTION: Could someone please help me setup a good SQL command. This will be the while loup
<?php
$sql = "????";
$result = mysql_query($sql);
while($fetch = mysql_fetch_assoc($result)){ ?>
<div class="message-block">
<h1><?php echo($fetch['uname']); ?></h1>
<p><?php echo($fetch['message']); ?></p>
<p><?php echo($fetch['time']); ?></p>
</div>
<?php } ?>
I hope my explanation is good enough, if not, please tell me. Please don't mind my English, and the Dutch names (I am Dutch myself) Feel free to correct my English
UPDATE1: Best I've got until now: But I do not want more than one conversation to show up... u=user table m=message table
SELECT u.uname, m.message, m.receiver_uid, m.sender_uid, m.time
FROM m, u
WHERE (m.receiver_uid = '$myID' AND u.uid = m.sender_uid)
OR (m.sender_uid = '$myID' AND u.uid = m.receiver_uid)
ORDER BY time DESC;