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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.