SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how can i do this...

    PHP Code:
    <?PHP

    include "inc/header.inc";

    // select newest entry

    $rar date("d.m.y");

    $result mysql_query("SELECT * FROM diary WHERE date = \"$rar\" ORDER BY id DESC"); 
                        
    ?> <table width=350 border=0 cellspacing=3 cellpadding=3 align=center> <?PHP

    while ( $row mysql_fetch_array($result) ) { 

    // Smilie function

    $result mysql_query("SELECT * FROM smilies"); 

    while ( 
    $row mysql_fetch_array($result) ) {
    $search $row[search];
    $replace $row[smilie];
    $entry str_replace($search$replace$entry);
    }

    // Replace functions

    $result mysql_query("SELECT * FROM friends"); 

    while ( 
    $row mysql_fetch_array($result) ) {

    $entry str_replace("$row[name]""<a href=bio.php?name=" $row[name] . ">" $row[name]. "</a>"$entry);
    }

    echo ( 
    "
        <tr> 
            <td><b><u>
    $row[title]</u></b></td>
            <td> 
              <div align=right><b>
    $row[date]</b></div>
            </td>
          </tr>
          <tr> 
            <td colspan=2>
    $row[entry]</td>
          </tr>
            " 
    ); }
    basically im having problems doing what i want to do. You should be able to tell what im doing with that piece of code. Ive got a feeling the reason it doesnt work is cos theres 'while' comments and 'sql' actions within each other. Is there anyway i can get around this problem?
    hmm...

  2. #2
    will code HTML for food Michel V's Avatar
    Join Date
    Sep 2000
    Location
    Corsica
    Posts
    552
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You've got these variables $result and $row referencing several different mysql queries, so when you get get back to do the second iteration of the outer while() loop, it must do it with the latest assigned values of $row and $result, which aren't what you want.
    Try doing each imbricated while() use a different pair of variables to avoid conflict. I know what it is, I've been pulling my air off on the same kind of problem this week

  3. #3
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx alot

    it occurred to me this morning that was probably the problem. But for some reason i had it in my head that i had to use those variables hehe im the worst PHP programmer in the world
    hmm...


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
  •