Results 1 to 9 of 9

Thread: MySQL & PHP

  1. #1

    MySQL & PHP

    Hi everybody, me again

    I got the MySQL tables to work at last. What I have now is a table called news, in which there are 4 fields and two rows of data. See the image below:

    [EDIT] Image taken out due to server downtime[/EDIT]

    So I have this script to put the data in a table.

    PHP Code:
    <?php
    mysql_connect
    ("hostname","username","password");
    mysql_select_db("mydatabase");

    $qr mysql_query("SELECT * FROM news");

    $nrows mysql_num_rows($qr);
    for (
    $i=0$i $nrows$i++) {
      
    $row mysql_fetch_array($qr);
    }

    ?>
    <html><head></head><body>
    <table border="0" cellpadding="0" width="50%" cellspacing="0" height="124">
      <tr>
        <td width="100%" bgcolor="#FFFFCC" height="21"><? echo "<b>".$row['titel']."</b>&nbsp;&nbsp;&nbsp;".$row['datum'];?></td>
      </tr>
      <tr>
        <td width="100%" bgcolor="#FFFFFF" height="103"><? echo $row['inhoud']."<br>";?></td>
      </tr>
    </table>
    </body>
    </html>
    This works fine so far, see an example of one the created table here. The problem is, how can I automatically add a table (in the PHP file, not in the database) when I add a new row of data to the database ? I had one row first, and it worked fine, but when I added one, the script I have now shows the second one one instead of the first.

    Can someone help me out please ?
    Last edited by Voetsjoeba; July 5th, 2003 at 09:43 AM.
    Wait, what?

  2. #2
    This code should work:

    PHP Code:
    <html><head></head><body>
    <table border="0" cellpadding="0" width="50%" cellspacing="0" height="124">

    <?
    mysql_connect
    ("hostname","username","password");
    mysql_select_db("mydatabase");

    $qr mysql_query("SELECT * FROM news");

    $nrows mysql_num_rows($qr);
    for (
    $i=0$i $nrows$i++) {
      
    $row mysql_fetch_array($qr);
      print 
    "<tr><td width=\"100%\" bgcolor=\"#FFFFCC\" height=\"21\"><b>" $row['titel'] . "</b>&nbsp;&nbsp;&nbsp;" $row['datum'] . "</td></tr>";
      print 
    "<tr><td width=\"100%\" bgcolor=\"#FFFFFF\" height=\"103\">" $row['inhoud'] . "</td></tr>";
    }
    ?>
    </table>
    </body>
    </html>

  3. #3
    Thanks Jubba ! Works like a charm !
    Wait, what?

  4. #4
    Hey Jubba, is it possible to get this auto-add feature into Flash (MX)? I know I might be asking a lot, but it would make my life so much better ...
    Wait, what?

  5. #5
    yes but its not really a simple process... i have to go now, I'll give you a hand later on.

  6. #6
    Thanks m8
    Wait, what?

  7. #7
    replace the 2 print lines by
    output="";

    output.="&titel".$i."=".$row['titel'];
    output.="&content".$i."=".$row['inhoud'];

    print $output;

    (not tested..)

    then in flash, use the titel1="....", titel2="....", content1="....",
    variables as you want...
    Joe
    www.eyezberg.com

  8. #8
    yeah what he said. Sorry I couldn't get to this sooner.

  9. #9
    Don't worry about it Thanks guys
    Wait, what?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012