Current location: Hot Scripts Forums » Programming Languages » PHP » retrieve information from tables


retrieve information from tables

Reply
  #1 (permalink)  
Old 11-12-11, 10:57 AM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 132
Thanks: 2
Thanked 0 Times in 0 Posts
retrieve information from tables

Hi guys i have this two tables:
Topic Table
PHP Code:

topic_id     int(10)     AUTO_INCREMENT  Primary     

sub_id             int
(10)                 
topic     varchar(255
Problem Table
PHP Code:

problem_id     int(10)     AUTO_INCREMENT  Primary     

topic_id             int
(10)                 
problem     varchar(255
I want retrieve the problems that are related with in the topic table this way
PHP Code:

<?php

 login
();
         
$topic_id $_GET['cat'];
         
$query="SELECT  problem_id, problem from problems WHERE topic_id=$topic_id";
         
$result=mysql_query($query);
         while(
$row=mysql_fetch_array($result,MYSQL_ASSOC))
         {

                  
$problem_id $row['problem_id'];
                  
$problem $row['problem'];

             echo 
"<h3><a href=\"index.php?content=answers&cat=$topic_id\">$problem</a></h3><br>\n";
         }
?>
it returns the same problems in every topic... how I fix that??

PHP Code:

http://localhost/study.com/index.php?content=problems&cat=1 

The problem cat = 1 is returned in every topic
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieve information from drop down list from mysql xxreenaxx1 PHP 1 02-15-11 08:17 PM
retrieve information from MYSQL through drop down list minglou PHP 3 04-03-09 09:43 PM
Using the SELECT LIKE statement to retrieve data from two tables eric1959 PHP 3 03-15-09 05:30 PM
[SOLVED] Find information based on variables from 3 tables lindasnephew Database 2 06-27-08 04:36 AM
Help with sending multiple emails from with information coming from 3 tables sn0wy PHP 1 01-01-07 09:48 AM


All times are GMT -5. The time now is 08:54 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.