Skip navigation
Currently Being Moderated

Show recordset content based on dynamic region on page (php/mysql)

Mar 15, 2012 9:07 AM

I have two recordsets in a page - rsDetail & rsPhotos

 

On the page is a dynamic region 'rsDetail.install_UID' which displays the unique install_UID of a record from the detail_tbl which I am viewing at that current time. I have labelled this region 'installnumber'

 

<td class="style1" id="installnumber"><?php echo $row_rsDetail['install_UID']; ?></td>

 

 

This is the detail_tbl (used in rsDetail)

 

install_UID

Column a

Column b

Column c

Column d

100755

2597

53

23

100629

100855

4329

83

62

102121

100752

1388

78

66

100452

100708

4329

53

62

101970

100630

2597

78

23

100629

100876

4329

116

62

102102

100565

1388

78

66

100452

100481

4386

0

66

86908

100451

4329

78

62

97043

100921

4329

116

62

102087

100447

4329

57

62

100405

100416

2597

78

23

100043

100019

1388

2

66

97847

100284

2597

57

23

94762

101007

4329

2

62

100654

159

1388

19

66

86662

164

4329

19

62

95578

100019

1388

2

66

97847

100565

1388

78

66

100452

100752

1388

78

66

100452

159

1388

19

66

86662

 

 

 

This is the photos_tbl (used in rsPhotos)

 

mediaUID

install_ID

Image_url

2136

100018

Images/Install100018/Install100018_95760_05.jpg

2135

100018

Images/Install100018/Install100018_95760_04.jpg

2134

100018

Images/Install100018/Install100018_95760_03.jpg

2133

100018

Images/Install100018/Install100018_95760_02.jpg

2132

100018

Images/Install100018/Install100018_95760_01.jpg

2123

100014

Images/Install100014/Install100014_95760_03.jpg

2120

100013

Images/Install100013/Install100013_97676_02.jpg

2121

100014

Images/Install100014/Install100014_95760_01.jpg

2122

100014

Images/Install100014/Install100014_95760_02.jpg

2131

100017

Images/Install100017/Install100017_95760_04.jpg


 

Is it possible to create a statement that says 'display records from photos_tbl where photos_tbl.install_ID = installnumber ?

 

I tried this in the rsPhotos recordset but it didn't work:

 

SELECT *

FROM photos_tbl

WHERE install_ID = ["installnumber"]

 

 

Thanks

 
Replies
  • Currently Being Moderated
    Mar 15, 2012 10:53 AM   in reply to Wookie

    You just need a single recordset.

    Assuming the relationship between the tables is install_ID = install_UID then

     

    SELECT *

    FROM photos_tbl, detail_tbl

    WHERE install_ID = install_UID

     

     

    Why do you need two recordsets?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 16, 2012 10:36 AM   in reply to Wookie

    >if so can you advise me on the correct syntax to use as I'm not fluent in php.

     

    I'm not a php developer so don't trust me on anything here.

     

    >SELECT *

    >FROM photos_tbl

    >WHERE install_ID = ["installnumber"]

     

    Here you are telling the where clause to look for an install_ID equal to the string "installnumber", which obviously is not correct.  Is "installnumber"  a variable you have created somewhere in the script? If so, then to create your SQL string you would use

     

    "SELECT *

    FROM photos_tbl

    WHERE install_ID =" . $installnumber

     

    Similar problem here

     

    >SELECT *

    >FROM photos_tbl

    >WHERE install_ID = "rsDetail.install_UID"

     

    You would not put variables inside of quotes. It would be something like

     

    "SELECT *

    FROM photos_tbl

    WHERE install_ID = " . $rsDetail.install_UID

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points