How do you replace do while and print on echo?



  • <?php
    if (!isset($id)) {
        $result = mysql_query("SELECT id,title FROM articles");
        $myrow  = mysql_fetch_array($result);
        do {
            printf("<p><a href='edit_article.php?id=%s'>%s</a></p>", $myrow['id'], $myrow['title']);
        } while ($myrow = mysql_fetch_array($result));
    } else {
        print <<<HERE
       <form method="POST" name="form1" action="update_article.php">
            <p><label>Mətnin başlığını daxil et:<br/>
                <input name="title" value="$myrow[title]" id="title" type="text" size="30"></input>
            </label></p>
            <p><label>Meta teq daxil et:<br/>
                <input name="meta_d" value="$myrow[meta_d]" id="meta_d" type="text" size="30"></input>
            </label></p>
            <p><label>Acar soz daxil et:<br/>
                <input name="meta_k" value="$myrow[meta_k]" id="meta_k" type="text" size="30"></input>
            </label></p>
            <p>
                <input name="id" type="hidden" value="myrow[id]"></input>
            </p>
            <p>
                <input name="submit" id="submit" type="submit" value="Bazaya elave et"></input>
            </p>
        </form>
    HERE;
    }
    ?>
    


  • $html = '';
    while($myrow = mysql_fetch_array($result)){
       $html .= '<p><a href="edit_article.php?id='.$myrow['id'].'">'.$myrow['title'].'</a></p>';
    }
    echo $html;
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2