Jump to content

Need help with select statement in php to show two select statements.


redarrow

Recommended Posts

How do i work this out please cheers.

There are two database tables here we go.
[code]
topic << table 1 name
id
name
tilte
description
date
time
[/code]

[code]
member_comments << table 2 name
id
name
tilte
comment
date // date from form from topic
time// time from form from topic
[/code]

This pull the data from the database with a while loop and assoc statement.

This is to show the members topic.
[code]
$query_topic="SELECT FROM topic WHERE id='".$_GET['id']."' and date='".$_GET['date']."' and time='".$_GET['time]."' ";

$result_topic=mysql_query($query_topic);

while($record=mysql_fetch_assocc($result_topic){

echo "$record['id'] : $record['name'] : $record['date'] : $record['time'] : $record['description'] ";

}
[/code]

this is the bit i dont get i goto get the date and time to match the topic in the comment table to show the  comment and topic together cheers.

example only
[code]
$query_comment="SELECT FROM member_comments WHERE id='".$record['id']."' and date='".$record['date']."' and time='".$record['time]."' ";

$result_comment=mysql_query($query_topic);

while($data=mysql_fetch_assocc($result_comment){

echo "$data['id'] : $data['name'] : $data['date'] : $data['time'] : $data['description'] ";

}

[/code]

So heres the full code and i wrote it on here live so i need to konow is this the correct way to get the member_comments to show on the same page as topic cheers.

[code]

$query_topic="SELECT FROM topic WHERE id='".$_GET['id']."' and date='".$_GET['date']."' and time='".$_GET['time]."' ";

$result_topic=mysql_query($query_topic);

while($record=mysql_fetch_assocc($result_topic){

echo "$record['id'] : $record['name'] : $record['date'] : $record['time'] : $record['description'] ";

}

$query_comment="SELECT FROM member_comments WHERE id='".$record['id']."' and date='".$record['date']."' and time='".$record['time]."' ";

$result_comment=mysql_query($query_topic);

while($data=mysql_fetch_assocc($result_comment){

echo "$data['id'] : $data['name'] : $data['date'] : $data['time'] : $data['description'] ";

}

[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.