Welcome to TalkGraphics.com
Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Apr 2005
    Location
    Regional Victoria (Australia)
    Posts
    109

    Default Include sql data using PHP in placeholder

    The aim is to display a list of members from a sql database. I am a total novice & have created a form using Web Designer & put a placeholder on it. In the placeholder is the following code:

    <?php
    $host="localhost"; // Host name
    $username="xxx"; // Mysql username
    $password="yyy"; // Mysql password
    $db_name="db_members"; // Database name
    $tbl_name="members"; // Table name

    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");

    $user_result = "SELECT MembershipName, Email, PhoneHome, PhoneBus, PhoneMobile, MembershipType from members ORDER BY MembershipName;";
    $qry = mysql_query($user_result) OR die(mysql_error());

    // echo mysql_num_rows($qry);

    echo "<center>";
    echo "<table CELLPADDING=10 border =1 >";

    // Column headings
    echo "<tr align='center'>";
    echo "<td>MemName</td>";
    echo "<center><td>Email</td>";
    echo "<center><td>Home</td>";
    echo "<center><td>Bus</td>";
    echo "<center><td>Mob</td>";
    echo "<center><td>Type</td>";
    echo "</tr>";

    while($myrow = mysql_fetch_array($qry))
    {
    echo "<tr>";
    echo "<td>".$myrow['MembershipName']."</td>";
    echo "<td>".$myrow['Email']."</td>";
    echo "<td>".$myrow['PhoneHome']."</td>";
    echo "<td>".$myrow['PhoneBus']."</td>";
    echo "<td>".$myrow['PhoneMobile']."</td>";
    echo "<td>".$myrow['MembershipType']."</td>";
    echo "</tr>";
    // $user_array = mysql_fetch_assoc($qry);
    }

    echo "</table>";
    mysql_close();
    ?>

    This code works fine if run as a .PHP file.

    I have also tried saving the code as a php file and using an include statement

    Nothing appears in the placeholder.
    Any ideas pleas?
    t

  2. #2

    Default Re: Include sql data using PHP in placeholder

    Use an iframe in a placeholder and call the .php file into your main page

    <iframe name=myiframe src=file.php width=100% height=100% scrolling=auto frameborder=0></iframe)

    Create the placeholder the size you want in Web Designer

  3. #3
    Join Date
    Apr 2005
    Location
    Regional Victoria (Australia)
    Posts
    109

    Default Re: Include sql data using PHP in placeholder

    Thanks
    I assume the placeholder cannot be made a dynamic height?

    Quote Originally Posted by sledger View Post
    Use an iframe in a placeholder and call the .php file into your main page

    <iframe name=myiframe src=file.php width=100% height=100% scrolling=auto frameborder=0></iframe)

    Create the placeholder the size you want in Web Designer

  4. #4

    Default Re: Include sql data using PHP in placeholder

    No it cannot

  5. #5
    Join Date
    Apr 2005
    Location
    Regional Victoria (Australia)
    Posts
    109

    Default Re: Include sql data using PHP in placeholder

    You, my friend, are a gem. It works a treat.
    Thank you

  6. #6
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: Include sql data using PHP in placeholder

    Quote Originally Posted by sledger View Post
    No it cannot
    But it can! Using the dynamic page tweak.
    It's exactly the case this tweak was created for.
    Last edited by covoxer; 22 November 2009 at 06:49 AM.
    John.

  7. #7

    Default Re: Include sql data using PHP in placeholder

    My apologies John, I wasn't aware that the DPTweak was able to create dynamically expanding <iframes too.
    Perhaps you could demonstrate?

  8. #8
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: Include sql data using PHP in placeholder

    Quote Originally Posted by sledger View Post
    My apologies John, I wasn't aware that the DPTweak was able to create dynamically expanding <iframes too.
    Perhaps you could demonstrate?
    Not iframes, of course. But there's no need to use iframe in this case. Or am I missing something?
    John.

  9. #9

    Default Re: Include sql data using PHP in placeholder

    Yes possibly, in post#3 Teedee asked about the placeholder for the <iframe suggestion being made dynamic. This is what I answered in post#4

  10. #10
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: Include sql data using PHP in placeholder

    Quote Originally Posted by Teedee View Post
    This code works fine if run as a .PHP file.
    I have also tried saving the code as a php file and using an include statement
    Nothing appears in the placeholder.
    Any ideas pleas?
    Include works in PHP files.
    What stops you from using PHP files?
    John.

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •