Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 20th, 2004, 03:53 PM
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default To tables combined to two levels

Could anyone tell me why it do not work with this - supposed to make a two level combination à la this (sorry, but "art" here is Danish for sort!):

portalart1
portalA
portalB
portalart2
portalC
portalart3
portalD
portalE

$result = mysql_query(" SELECT
a.portalart, a.portalart_nr, p.portaladresse_art, p.portaladresse_navn, p.portaladresse_url
FROM portalart AS a, portaladresser AS p
WHERE p.portaladresse_art = a.portalart_nr
ORDER by a.portalart_nr ASC ");

while ( $row = mysql_fetch_row($result) )
{
            echo "<tr>";
            echo "<td align=\"center\">";
            echo "<b>Portalart: " . $row['0'] . "</b>";
            echo "</td>";
            echo "</tr>";

            echo "<tr>";
            echo "<td align=\"left\">";
            echo "URL og navn: <a href=\"" . $row['4'] . "\">" . $row['3'] . "</a>";
            echo "</td>";
            echo "</tr>";
}

//tb portalart: id, portalart, portalart_nr
//tb portaladresser: id, portaladresse_art, portaladresse_navn, portaladresse_url

The result is Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource - regarding while...
 
Old October 20th, 2004, 04:14 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I have three things to say to you:

1) It is ALWAYS a good idea to test for errors:
mysql_query('text') or die('error in query: '.mysql_error());

2) Why is your Warning about mysql_fetch_array() when you're using mysql_fetch_row()?

3) This topic really doesn't belong in the Feedback area.

HTH!

-Snib <><
Try new FreshView 0.2!
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
 
Old October 20th, 2004, 04:20 PM
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for wrong forum - and too quick questioning.

I have found the solution as this one (and mysql_fetch_array and mysql_fetch_row are both ok):

$result = mysql_query(" SELECT
a.portalart, p.portaladresse_navn, p.portaladresse_url
FROM portalart AS a, portaladresser AS p
WHERE p.portaladresse_art = a.portalart_nr
ORDER by a.portalart_nr ASC ") or die(mysql_error());

$gammelportal = '';
while ( $row = mysql_fetch_array($result) )
{
    if( $gammelportal != $row[0] )
    {
            $gammelportal = $row[0];
            echo "<tr>";
            echo "<td align=\"center\">";
            echo "<b>Portalart: " . $row['0'] . "</b>";
            echo "</td>";
            echo "</tr>";
    }
            echo "<tr>";
            echo "<td align=\"left\">";
            echo "URL og navn: <a href=\"" . $row['2'] . "\">" . $row['1'] . "</a>";
            echo "</td>";
            echo "</tr>";
}






Similar Threads
Thread Thread Starter Forum Replies Last Post
Apply-templates combined with with-param ? Smirre XSLT 6 November 11th, 2008 08:25 AM
Getting data from xml and xsl files combined hema_latha7 General .NET 0 May 19th, 2006 08:27 AM
How to Prepare Combined Setup using VS 2005 ramana.gali ASP.NET 2.0 Professional 0 May 9th, 2006 02:38 PM
Date combined from three combo boxes njava Access VBA 1 January 6th, 2004 09:12 AM
user levels dazednconfused Beginning PHP 3 July 8th, 2003 04:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.