View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Display data from related tables in results

Thread began 4/30/2009 2:48 pm by phil.evans372967 | Last modified 8/27/2010 3:04 pm by phil.evans372967 | 4354 views | 16 replies

phil.evans372967

Hi guys

Thanks for your help with this.

So far I've managed to get the page to display all the related records, but the script displays a row for each prop_id from prop_details that has a related img_thumb.

Any idea how I can get this to display just one row for each record for prop_id in prop_details and then display all related img_thumbs in one cell in the table (the one that currently shows <td><img src="../images/tns/<?php echo $row_Recordset1['img_thumb']; ?>" width="50" height="50" alt="<?php echo $row_Recordset1['short_desc']; ?>" /></td>)

Thanks again

Phil

<?php require_once('../Connections/prop.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}

mysql_select_db($database_prop, $prop);
$query_Recordset1 = "SELECT prop_details.prop_id, prop_details.prop_ref, prop_details.short_desc, prop_images.img_thumb, prop_images.prop_id FROM prop_details LEFT JOIN prop_images ON prop_details.prop_id=prop_images.prop_id";
$Recordset1 = mysql_query($query_Recordset1, $prop) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!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>Untitled Document</title>
</head>

<body>
<table width="80%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td>Prop ID</td>
<td>Office Ref</td>
<td>Short Desc</td>
<td>Thumbs</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['prop_id']; ?></td>
<td><?php echo $row_Recordset1['prop_ref']; ?></td>
<td><?php echo $row_Recordset1['short_desc']; ?></td>
<td><img src="../images/tns/<?php echo $row_Recordset1['img_thumb']; ?>" width="50" height="50" alt="<?php echo $row_Recordset1['short_desc']; ?>" /></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);

?>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...