close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Get info from 2 tables?

Thread began 1/07/2011 10:57 am by willo009412397 | Last modified 2/09/2011 6:39 pm by willo009412397 | 3583 views | 15 replies

twitchr377598

On pages that get information from the database you will have a recordset. It probably looks something like this: (keep in mind where I have "recordset" yours may say something else. Same with "yourdatabase".

php:
mysql_select_db($database_yourdatabase, $yourdatabase);

$query_recordset = "SELECT * FROM customer";
$recordset = mysql_query($query_recordset, $yourdatabase) or die(mysql_error());
$row_recordset = mysql_fetch_assoc($recordset);
$totalRows_recordset = mysql_num_rows($recordset);



The query above will get all the columns from the customer table. To display the information you would have a repeating region that shows all the customers. It may look something like:

php:
<table>

    <?php do { ?>
                <tr><td>
<?php echo $row_recordset['customerName']; ?>
</td></tr>
                              <?php } while ($row_recordset mysql_fetch_assoc($recordset)); ?>
</table>


If you wanted to pull data from both the customer and pet tables using one recordset instead of two, you would replace:

php:
"SELECT * FROM customer";



With the one I posted earlier:

php:
"SELECT * FROM customer INNER JOIN pet ON (customer.customerID = pet.customerID)"



Then you could have a repeat region like:

php:
<table>

    <?php do { ?>
                <tr><td>
<?php echo "Customer name: ".$row_recordset['customerName']."<br/>Pet name: ".$row_recordset['petName']; ?>
</td></tr>
                              <?php } while ($row_recordset mysql_fetch_assoc($recordset)); ?>
</table>

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...