Page 1 of 1

File Upload -> Download function

Posted: 2012-09-17 14:37
by Jarno
I want to use the ADDT File Upload -> Download file function in my MySQL database, the uploading is going well, i can upload for example pdf files to a defined variable dir like /dir/{number} and the number is from a fill-in form of my database. But now i want to make a download link to a file in my database, as it's uploaded.

Can some one help me with that?

Re: File Upload -> Download function

Posted: 2012-09-17 19:44
by Fred
Just build your download recordset with the {number} as part of the result.

Example.
The mem_id in this case is the unique number that you are talking about.

Code: Select all

SELECT id, photo, phot_title, phot_description, mem_id, gal_id
FROM articles_photos
WHERE gal_id = $row_rs_article['a_gal_id'] AND articles_photos.phot_show = 1
Then just make it part of your url where to download the file from.

Code: Select all

uploads/media/{rs_photos.mem_id}/

Re: File Upload -> Download function

Posted: 2012-09-20 18:29
by Jarno
Fred,

Thanks for your help. I can make a download link to one file with variables. But i cant make it in my dynamic list.

I have a link like this:

<a href="drawings/<?php echo $row_download['number']; ?>/<?php echo $row_download['pdf']; ?>" target="_blank">here_should_be_the_name_stored_in_$row_download['pdf']</a>

This is poiting to the right file, but now i want to gave it the "here should be.." as name. And i want it in my dynamic list. It won't display there.

This is the code of my dynamic list field now:

<td><input type="text" name="tfi_listtbl_tekeningen8_pdf" id="tfi_listtbl_tekeningen8_pdf" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listtbl_tekeningen8_pdf']); ?>" size="20" maxlength="100" /></td>

This displays the right file name, but as i said i want to make that a link to my file location. As i past the href sentence it wont display a link.

Re: File Upload -> Download function

Posted: 2012-09-21 10:57
by Fred
Let see if I am on the right track here.

You have a db holding a lot of files that has been uploaded.
You want to display this files for download and use the name of the file as part of the link description.

Create a recordset retrieving the files.

Here is an example of mine.

Code: Select all

SELECT `links`.`l_id`, `links`.`l_order`, `links`.`l_file` FROM `links` WHERE `links`.`l_category` =  123456789 AND `links`.`l_visable` =  '1'
ORDER BY `links`.`l_order` ASC
Now create a repeat region displaying the records, that is your dynamic part.
Next you would use the download SB to create your link.

Here is an example of what it should look like when you done.

Code: Select all

<a href="<?php echo $downloadObj1->getDownloadLink(); ?>"><?php echo $row_detail2links['l_file']; ?></a>

Re: File Upload -> Download function

Posted: 2012-09-21 13:41
by Jarno
Fred,

What i did is create a recordset named "dowload" with the contents nummer (contains the dir name) and pdf (contains the filename). So now i can create links like:

<a href="tekeningen/<?php echo $row_download['nummer']; ?>/<?php echo $row_download['pdf']; ?>"><?php echo $row_download['pdf']; ?>

This will result in a link to my dir tekeningen/{dir nummer}/{filenamepdf} this is exactly what i want. But i want it in my dynamic list as i said before.

As you can see in the pic I added now i get the same links and files in that row, but what i want is like the "before" situation but then like the links in the after situation. So i need to make something that points to the right file for every row.

Image

Hope you understand my problem.

Re: File Upload -> Download function

Posted: 2012-09-21 14:48
by Fred
Just to make sure we are on the same track I created a page similar to what I think you want.
Dont know if ADDT download SB is any different from InterAkt. This is an InteAkt example.

Code: Select all

<?php require_once('siteConnect.php'); ?>
<?php
// Load the tNG classes
require_once('tng/tNG.inc.php');

mysql_select_db($database_siteConn, $siteConn);
$query_Recordset1 = "SELECT l_id, l_title, l_file FROM links WHERE l_type = 2";
$Recordset1 = mysql_query($query_Recordset1, $siteConnect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

// Download File downloadObj1
$downloadObj1 = new tNG_Download("", "KT_download1");
// Execute
$downloadObj1->setFolder("media/Files/");
$downloadObj1->setRenameRule("{Recordset1.l_file}");
$downloadObj1->Execute();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<table border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>l_title</td>
    <td>l_file</td>
  </tr>
  <?php do { ?>
  <tr>
    <td><?php echo $row_Recordset1['l_title']; ?></td>
    <td><a href="<?php echo $downloadObj1->getDownloadLink(); ?>"><?php echo $row_Recordset1['l_file']; ?></a></td>
  </tr>
  <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
And here is the result
http://www.leadingwebexposure.com/repeat.php

Re: File Upload -> Download function

Posted: 2012-09-21 17:02
by Jarno
Fred,

I am getting steps further now. I only have one problem now, the files are showing but the first file is for the first record and the second for the second record etc.

See it here: Image

"reactie op dispuut.pdf" must display in the second row. I know it's something with the do-while loop, but i can't solve it myself.

my code:

Code: Select all

<?php require_once('Connections/tekening_db.php'); ?>
<?php
// Load the common classes
require_once('includes/common/KT_common.php');

// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

// Load the required classes
require_once('includes/tfi/TFI.php');
require_once('includes/tso/TSO.php');
require_once('includes/nav/NAV.php');

// Make unified connection variable
$conn_tekening_db = new KT_connection($tekening_db, $database_tekening_db);

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

// Filter
$tfi_listtbl_tekeningen8 = new TFI_TableFilter($conn_tekening_db, "tfi_listtbl_tekeningen8");
$tfi_listtbl_tekeningen8->addColumn("tbl_tekeningen.nummer", "NUMERIC_TYPE", "nummer", "=");
$tfi_listtbl_tekeningen8->addColumn("tbl_tekeningen.omschrijving", "STRING_TYPE", "omschrijving", "%");
$tfi_listtbl_tekeningen8->addColumn("tbl_tekeningen.pdf", "FILE_TYPE", "pdf", "%");
$tfi_listtbl_tekeningen8->addColumn("tbl_tekeningen.dxf", "FILE_TYPE", "dxf", "%");
$tfi_listtbl_tekeningen8->addColumn("tbl_tekeningen.dwg", "FILE_TYPE", "dwg", "%");
$tfi_listtbl_tekeningen8->addColumn("tbl_klanten.naam", "STRING_TYPE", "klant", "%");
$tfi_listtbl_tekeningen8->addColumn("tbl_leveranciers.naam", "STRING_TYPE", "leverancier", "%");
$tfi_listtbl_tekeningen8->addColumn("tbl_tekeningen.commentaar", "STRING_TYPE", "commentaar", "%");
$tfi_listtbl_tekeningen8->Execute();

// Sorter
$tso_listtbl_tekeningen8 = new TSO_TableSorter("rstbl_tekeningen1", "tso_listtbl_tekeningen8");
$tso_listtbl_tekeningen8->addColumn("tbl_tekeningen.nummer");
$tso_listtbl_tekeningen8->addColumn("tbl_tekeningen.omschrijving");
$tso_listtbl_tekeningen8->addColumn("tbl_tekeningen.pdf");
$tso_listtbl_tekeningen8->addColumn("tbl_tekeningen.dxf");
$tso_listtbl_tekeningen8->addColumn("tbl_tekeningen.dwg");
$tso_listtbl_tekeningen8->addColumn("tbl_klanten.naam");
$tso_listtbl_tekeningen8->addColumn("tbl_leveranciers.naam");
$tso_listtbl_tekeningen8->addColumn("tbl_tekeningen.commentaar");
$tso_listtbl_tekeningen8->setDefault("tbl_tekeningen.nummer");
$tso_listtbl_tekeningen8->Execute();

// Navigation
$nav_listtbl_tekeningen8 = new NAV_Regular("nav_listtbl_tekeningen8", "rstbl_tekeningen1", "", $_SERVER['PHP_SELF'], 10);

mysql_select_db($database_tekening_db, $tekening_db);
$query_Recordset2 = "SELECT naam, naam FROM tbl_klanten ORDER BY naam";
$Recordset2 = mysql_query($query_Recordset2, $tekening_db) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);

mysql_select_db($database_tekening_db, $tekening_db);
$query_Recordset1 = "SELECT naam, naam FROM tbl_leveranciers ORDER BY naam";
$Recordset1 = mysql_query($query_Recordset1, $tekening_db) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_select_db($database_tekening_db, $tekening_db);
$query_download = "SELECT id, nummer, pdf, dxf, dwg FROM tbl_tekeningen";
$download = mysql_query($query_download, $tekening_db) or die(mysql_error());
$row_download = mysql_fetch_assoc($download);
$totalRows_download = mysql_num_rows($download);

//NeXTenesio3 Special List Recordset
$maxRows_rstbl_tekeningen1 = $_SESSION['max_rows_nav_listtbl_tekeningen8'];
$pageNum_rstbl_tekeningen1 = 0;
if (isset($_GET['pageNum_rstbl_tekeningen1'])) {
  $pageNum_rstbl_tekeningen1 = $_GET['pageNum_rstbl_tekeningen1'];
}
$startRow_rstbl_tekeningen1 = $pageNum_rstbl_tekeningen1 * $maxRows_rstbl_tekeningen1;

// Defining List Recordset variable
$NXTFilter_rstbl_tekeningen1 = "1=1";
if (isset($_SESSION['filter_tfi_listtbl_tekeningen8'])) {
  $NXTFilter_rstbl_tekeningen1 = $_SESSION['filter_tfi_listtbl_tekeningen8'];
}
// Defining List Recordset variable
$NXTSort_rstbl_tekeningen1 = "tbl_tekeningen.nummer";
if (isset($_SESSION['sorter_tso_listtbl_tekeningen8'])) {
  $NXTSort_rstbl_tekeningen1 = $_SESSION['sorter_tso_listtbl_tekeningen8'];
}
mysql_select_db($database_tekening_db, $tekening_db);

$query_rstbl_tekeningen1 = "SELECT tbl_tekeningen.nummer, tbl_tekeningen.omschrijving, tbl_tekeningen.pdf, tbl_tekeningen.dxf, tbl_tekeningen.dwg, tbl_klanten.naam AS klant, tbl_leveranciers.naam AS leverancier, tbl_tekeningen.commentaar, tbl_tekeningen.id FROM (tbl_tekeningen LEFT JOIN tbl_klanten ON tbl_tekeningen.klant = tbl_klanten.naam) LEFT JOIN tbl_leveranciers ON tbl_tekeningen.leverancier = tbl_leveranciers.naam WHERE {$NXTFilter_rstbl_tekeningen1} ORDER BY {$NXTSort_rstbl_tekeningen1}";
$query_limit_rstbl_tekeningen1 = sprintf("%s LIMIT %d, %d", $query_rstbl_tekeningen1, $startRow_rstbl_tekeningen1, $maxRows_rstbl_tekeningen1);
$rstbl_tekeningen1 = mysql_query($query_limit_rstbl_tekeningen1, $tekening_db) or die(mysql_error());
$row_rstbl_tekeningen1 = mysql_fetch_assoc($rstbl_tekeningen1);

if (isset($_GET['totalRows_rstbl_tekeningen1'])) {
  $totalRows_rstbl_tekeningen1 = $_GET['totalRows_rstbl_tekeningen1'];
} else {
  $all_rstbl_tekeningen1 = mysql_query($query_rstbl_tekeningen1);
  $totalRows_rstbl_tekeningen1 = mysql_num_rows($all_rstbl_tekeningen1);
}
$totalPages_rstbl_tekeningen1 = ceil($totalRows_rstbl_tekeningen1/$maxRows_rstbl_tekeningen1)-1;
//End NeXTenesio3 Special List Recordset

$nav_listtbl_tekeningen8->checkBoundries();

// Download File downloadObj1
$downloadObj1 = new tNG_Download("", "KT_download1");
// Execute
$downloadObj1->setFolder("tekeningen/{download.nummer}/");
$downloadObj1->setRenameRule("{download.pdf}");
$downloadObj1->Execute();

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tekening DB Manager</title>
<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script src="includes/skins/style.js" type="text/javascript"></script>
<script src="includes/nxt/scripts/list.js" type="text/javascript"></script>
<script src="includes/nxt/scripts/list.js.php" type="text/javascript"></script>
<script type="text/javascript">
$NXT_LIST_SETTINGS = {
  duplicate_buttons: true,
  duplicate_navigation: true,
  row_effects: true,
  show_as_buttons: true,
  record_counter: false
}
</script>
<style type="text/css">
  /* Dynamic List row settings */
  .KT_col_nummer {width:140px; overflow:hidden;}
  .KT_col_omschrijving {width:140px; overflow:hidden;}
  .KT_col_pdf {width:140px; overflow:hidden;}
  .KT_col_dxf {width:140px; overflow:hidden;}
  .KT_col_dwg {width:140px; overflow:hidden;}
  .KT_col_klant {width:140px; overflow:hidden;}
  .KT_col_leverancier {width:140px; overflow:hidden;}
  .KT_col_commentaar {width:140px; overflow:hidden;}
</style>
</head>

<body>
<div class="KT_tng" id="listtbl_tekeningen8">
  <h1>Overzicht tekeningen</h1>
  <div class="KT_tnglist">
    <form action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>" method="post" id="form1">
      <div class="KT_options"> <a href="<?php echo $nav_listtbl_tekeningen8->getShowAllLink(); ?>"><?php echo NXT_getResource("Show"); ?>
        <?php 
  // Show IF Conditional region1
  if (@$_GET['show_all_nav_listtbl_tekeningen8'] == 1) {
?>
          <?php echo $_SESSION['default_max_rows_nav_listtbl_tekeningen8']; ?>
          <?php 
  // else Conditional region1
  } else { ?>
          <?php echo NXT_getResource("all"); ?>
          <?php } 
  // endif Conditional region1
?>
<?php echo NXT_getResource("records"); ?></a> &nbsp;
        &nbsp;
        <?php 
  // Show IF Conditional region2
  if (@$_SESSION['has_filter_tfi_listtbl_tekeningen8'] == 1) {
?>
          <a href="<?php echo $tfi_listtbl_tekeningen8->getResetFilterLink(); ?>"><?php echo NXT_getResource("Reset filter"); ?></a>
          <?php 
  // else Conditional region2
  } else { ?>
          <a href="<?php echo $tfi_listtbl_tekeningen8->getShowFilterLink(); ?>"><?php echo NXT_getResource("Show filter"); ?></a>
          <?php } 
  // endif Conditional region2
?>
      </div>
      <table cellpadding="2" cellspacing="0" class="KT_tngtable">
        <thead>
          <tr class="KT_row_order">
            <th> <input type="checkbox" name="KT_selAll" id="KT_selAll"/>
            </th>
            <th id="nummer" class="KT_sorter KT_col_nummer <?php echo $tso_listtbl_tekeningen8->getSortIcon('tbl_tekeningen.nummer'); ?>"> <a href="<?php echo $tso_listtbl_tekeningen8->getSortLink('tbl_tekeningen.nummer'); ?>">Tekeningnummer</a></th>
            <th id="omschrijving" class="KT_sorter KT_col_omschrijving <?php echo $tso_listtbl_tekeningen8->getSortIcon('tbl_tekeningen.omschrijving'); ?>"> <a href="<?php echo $tso_listtbl_tekeningen8->getSortLink('tbl_tekeningen.omschrijving'); ?>">Omschrijving</a></th>
            <th id="pdf" class="KT_sorter KT_col_pdf <?php echo $tso_listtbl_tekeningen8->getSortIcon('tbl_tekeningen.pdf'); ?>"> <a href="<?php echo $tso_listtbl_tekeningen8->getSortLink('tbl_tekeningen.pdf'); ?>">PDF</a></th>
            <th id="dxf" class="KT_sorter KT_col_dxf <?php echo $tso_listtbl_tekeningen8->getSortIcon('tbl_tekeningen.dxf'); ?>"> <a href="<?php echo $tso_listtbl_tekeningen8->getSortLink('tbl_tekeningen.dxf'); ?>">DXF</a></th>
            <th id="dwg" class="KT_sorter KT_col_dwg <?php echo $tso_listtbl_tekeningen8->getSortIcon('tbl_tekeningen.dwg'); ?>"> <a href="<?php echo $tso_listtbl_tekeningen8->getSortLink('tbl_tekeningen.dwg'); ?>">DWG</a></th>
            <th id="klant" class="KT_sorter KT_col_klant <?php echo $tso_listtbl_tekeningen8->getSortIcon('tbl_klanten.naam'); ?>"> <a href="<?php echo $tso_listtbl_tekeningen8->getSortLink('tbl_klanten.naam'); ?>">Klant</a></th>
            <th id="leverancier" class="KT_sorter KT_col_leverancier <?php echo $tso_listtbl_tekeningen8->getSortIcon('tbl_leveranciers.naam'); ?>"> <a href="<?php echo $tso_listtbl_tekeningen8->getSortLink('tbl_leveranciers.naam'); ?>">Leverancier</a></th>
            <th id="commentaar" class="KT_sorter KT_col_commentaar <?php echo $tso_listtbl_tekeningen8->getSortIcon('tbl_tekeningen.commentaar'); ?>"> <a href="<?php echo $tso_listtbl_tekeningen8->getSortLink('tbl_tekeningen.commentaar'); ?>">Commentaar</a></th>
            <th>&nbsp;</th>
          </tr>
          <?php 
  // Show IF Conditional region3
  if (@$_SESSION['has_filter_tfi_listtbl_tekeningen8'] == 1) {
?>
            <tr class="KT_row_filter">
              <td>&nbsp;</td>
              <td><input type="text" name="tfi_listtbl_tekeningen8_nummer" id="tfi_listtbl_tekeningen8_nummer" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listtbl_tekeningen8_nummer']); ?>" size="20" maxlength="100" /></td>
              <td><input type="text" name="tfi_listtbl_tekeningen8_omschrijving" id="tfi_listtbl_tekeningen8_omschrijving" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listtbl_tekeningen8_omschrijving']); ?>" size="20" maxlength="100" /></td>
              <td><input type="text" name="tfi_listtbl_tekeningen8_pdf" id="tfi_listtbl_tekeningen8_pdf" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listtbl_tekeningen8_pdf']); ?>" size="20" maxlength="100" /></td>
              <td><input type="text" name="tfi_listtbl_tekeningen8_dxf" id="tfi_listtbl_tekeningen8_dxf" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listtbl_tekeningen8_dxf']); ?>" size="20" maxlength="100" /></td>
              <td><input type="text" name="tfi_listtbl_tekeningen8_dwg" id="tfi_listtbl_tekeningen8_dwg" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listtbl_tekeningen8_dwg']); ?>" size="20" maxlength="100" /></td>
              <td><select name="tfi_listtbl_tekeningen8_klant" id="tfi_listtbl_tekeningen8_klant">
                <option value="" <?php if (!(strcmp("", @$_SESSION['tfi_listtbl_tekeningen8_klant']))) {echo "SELECTED";} ?>><?php echo NXT_getResource("None"); ?></option>
                <?php
do {  
?>
                <option value="<?php echo $row_Recordset2['naam']?>"<?php if (!(strcmp($row_Recordset2['naam'], @$_SESSION['tfi_listtbl_tekeningen8_klant']))) {echo "SELECTED";} ?>><?php echo $row_Recordset2['naam']?></option>
                <?php
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
  $rows = mysql_num_rows($Recordset2);
  if($rows > 0) {
      mysql_data_seek($Recordset2, 0);
	  $row_Recordset2 = mysql_fetch_assoc($Recordset2);
  }
?>
              </select></td>
              <td><select name="tfi_listtbl_tekeningen8_leverancier" id="tfi_listtbl_tekeningen8_leverancier">
                <option value="" <?php if (!(strcmp("", @$_SESSION['tfi_listtbl_tekeningen8_leverancier']))) {echo "SELECTED";} ?>><?php echo NXT_getResource("None"); ?></option>
                <?php
do {  
?>
                <option value="<?php echo $row_Recordset1['naam']?>"<?php if (!(strcmp($row_Recordset1['naam'], @$_SESSION['tfi_listtbl_tekeningen8_leverancier']))) {echo "SELECTED";} ?>><?php echo $row_Recordset1['naam']?></option>
                <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
	  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
              </select></td>
              <td><input type="text" name="tfi_listtbl_tekeningen8_commentaar" id="tfi_listtbl_tekeningen8_commentaar" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listtbl_tekeningen8_commentaar']); ?>" size="20" maxlength="100" /></td>
              <td><input type="submit" name="tfi_listtbl_tekeningen8" value="<?php echo NXT_getResource("Filter"); ?>" /></td>
            </tr>
            <?php } 
  // endif Conditional region3
?>
        </thead>
        <tbody>
          <?php if ($totalRows_rstbl_tekeningen1 == 0) { // Show if recordset empty ?>
            <tr>
              <td colspan="10"><?php echo NXT_getResource("The table is empty or the filter you've selected is too restrictive."); ?></td>
            </tr>
            <?php } // Show if recordset empty ?>
          <?php if ($totalRows_rstbl_tekeningen1 > 0) { // Show if recordset not empty ?>
            <?php do { ?>
              <tr class="<?php echo @$cnt1++%2==0 ? "" : "KT_even"; ?>">
                <td><input type="checkbox" name="kt_pk_tbl_tekeningen" class="id_checkbox" value="<?php echo $row_rstbl_tekeningen1['id']; ?>" />
                  <input type="hidden" name="id" class="id_field" value="<?php echo $row_rstbl_tekeningen1['id']; ?>" /></td>
                <td><div class="KT_col_nummer"><?php echo KT_FormatForList($row_rstbl_tekeningen1['nummer'], 20); ?></div></td>
                <td><div class="KT_col_omschrijving"><?php echo KT_FormatForList($row_rstbl_tekeningen1['omschrijving'], 20); ?></div></td>
                <td><div class="KT_col_pdf"></div>  <?php do { ?>
<a href="<?php echo $downloadObj1->getDownloadLink(); ?>"><?php echo $row_download['pdf']; ?></a>
  <?php } while ($row_download = mysql_fetch_assoc($download)); ?>
</td>
                <td><div class="KT_col_dxf"><?php echo KT_FormatForList($row_rstbl_tekeningen1['dxf'], 20); ?></div></td>
                <td><div class="KT_col_dwg"><?php echo KT_FormatForList($row_rstbl_tekeningen1['dwg'], 20); ?></div></td>
                <td><div class="KT_col_klant"><?php echo KT_FormatForList($row_rstbl_tekeningen1['klant'], 20); ?></div></td>
                <td><div class="KT_col_leverancier"><?php echo KT_FormatForList($row_rstbl_tekeningen1['leverancier'], 20); ?></div></td>
                <td><div class="KT_col_commentaar"><?php echo KT_FormatForList($row_rstbl_tekeningen1['commentaar'], 20); ?></div></td>
                <td><a class="KT_edit_link" href="db_man_edit_tek.php?id=<?php echo $row_rstbl_tekeningen1['id']; ?>&KT_back=1"><?php echo NXT_getResource("edit_one"); ?></a> <a class="KT_delete_link" href="#delete"><?php echo NXT_getResource("delete_one"); ?></a></td>
              </tr>
              <?php } while ($row_rstbl_tekeningen1 = mysql_fetch_assoc($rstbl_tekeningen1)); ?>
            <?php } // Show if recordset not empty ?>
        </tbody>
      </table>
      <div class="KT_bottomnav">
        <div>
          <?php
            $nav_listtbl_tekeningen8->Prepare();
            require("includes/nav/NAV_Text_Navigation.inc.php");
          ?>
        </div>
      </div>
      <div class="KT_bottombuttons">
        <div class="KT_operations"> <a class="KT_edit_op_link" href="#" onclick="nxt_list_edit_link_form(this); return false;"><?php echo NXT_getResource("edit_all"); ?></a> <a class="KT_delete_op_link" href="#" onclick="nxt_list_delete_link_form(this); return false;"><?php echo NXT_getResource("delete_all"); ?></a></div>
        <span>&nbsp;</span>
        <select name="no_new" id="no_new">
          <option value="1">1</option>
          <option value="3">3</option>
          <option value="6">6</option>
        </select>
        <a class="KT_additem_op_link" href="db_man_edit_tek.php?KT_back=1" onclick="return nxt_list_additem(this)"><?php echo NXT_getResource("add new"); ?></a></div>
    </form>
  </div>
  <br class="clearfixplain" />
</div>
</body>
</html>
<?php
mysql_free_result($Recordset2);

mysql_free_result($Recordset1);

mysql_free_result($download);

mysql_free_result($rstbl_tekeningen1);
?>

Re: File Upload -> Download function

Posted: 2012-09-21 23:02
by Fred
The problem is not with the "do-while" loop. It is with your mysql query construction.

You need to join the two tables on some common key, I would imagine it to be the klanten_id.
Your db should be something like the following, not taking the anything else into consideration.

Klanten:
Klanten_id
Klanten_naam

Tekeningen
tekeningen_id
Klanten_id
tekeningen_nummer
tekeningen_omschrijving
tekeningen_pdf

Now your mysql query for the list can be constructed like this;

Code: Select all

SELECT Klanten.Klanten_id, Klanten.Klanten_naam, tekeningen.tekeningen_id,tekeningen.tekeningen_nummer,tekeningen.tekeningen_omschrijving,tekeningen.tekeningen_pdf FROM Klanten INNER JOIN Klanten.Klanten_id ON tekeningen.Klanten_id
The Klanten_id is the foreign key in the one to many relationship.
meaning one klant can have more than one tekeningen

You will have to redo the list and define the query first then select the "From Recordset" in the dropdown when you apply the SB.

You can do it in a different way but you will still need a foreign key in the tekeningen table

In het geval dat je je afvraagt​​, ik ben oorspronkelijk uit Zuid-Afrika, ik kan begrijpen Nederlands, maar mijn grammatica en spelling is niet de beste.