Linked Recordsets in Dreamweaver

Discussion in 'PHP' started by jamjam1, Jul 23, 2010.

  1. #1
    Hi

    To better explain my problem and hopefully find a solution, here is a backstory.

    I am building a database driven website with PHP and MySQL using Dreamweaver CS5.

    One of the pages on site is called programme, and it access by query string like this

    www.domain.com/programme/?id=10000000

    Depending on the value of the query string, programme data is retrieved from the database and is displayed on the page. All this is working without any problems.

    In addition to the main programme information, I also want to display related ‘programmes’ on the bottom of the page.

    To achieve this I have created two ‘record sets’ in Dreamweaver.

    The first recordset retrieves the main programme and the second recordset will retrieves the related programmes.

    These are the fields in the database.

    Id, programme, episode, date, time


    Recordset 1 : SQL

    
    $programme_Programme = "-1"; 
    if (isset($_GET['id'])) { 
      $programme_Programme = $_GET['id']; 
    } 
    mysql_select_db($database_main, $main); 
    $query_Programme = sprintf("SELECT * FROM main WHERE id = %s", GetSQLValueString($programme_Programme, "int")); 
    $Programme = mysql_query($query_Programme, $main) or die(mysql_error());
    $row_Programme = mysql_fetch_assoc($Programme); 
    $totalRows_Programme = mysql_num_rows($Programme); 
    
    PHP:
    I have had great difficulty in the SQL for the second recordsets.

    I think the solution involves in taking $programme defined in first recodset and using in the second recordset SQL somehow.

    Something like

    $related_Related = "-1"; 
    if (isset($_GET['programme'])) { 
      $related_Related = $_GET['programme']; 
    } 
    mysql_select_db($database_main, $main); 
    $query_Related = sprintf("SELECT * FROM main WHERE %s = programme", GetSQLValueString($related_Related, "text")); 
    $Related = mysql_query($query_Related, $main) or die(mysql_error()); 
    $row_Related = mysql_fetch_assoc($Related); 
    $totalRows_Related = mysql_num_rows($Related); 
    PHP:
    But, this does not work.

    I know this is totally messed-up
    So I would really appreciate if someone can let me know what I should be doing to get this to work.

    Thanks
     
    jamjam1, Jul 23, 2010 IP