E
E
eellazy2016-02-26 11:59:53
MySQL
eellazy, 2016-02-26 11:59:53

How to insert a php function?

Hello! I have something like this

<?php
                
                            $result = mysql_query(" SELECT * FROM eb_notes ORDER BY `id` DESC");
                            while ($row = mysql_fetch_array ($result)) { ?>

                                    <div class="item_notes">
                                    <span class="description_notes"><?php echo $row ['description']; ?></span>
                                    <div class="desc_data_time">
                                    <span class="notes_dt"><?php echo $row ['date']; ?></span>
                                    <span class="notes_dt" ><?php echo $row ['time']; ?></span>
                                    </div>
                                    </div>
                                
                        <?php }?>

It's all in the index file, so you don't need to do this, and I understand that. How can this be written into a function?
Tried like this
<?php
                
                            function hello()
                            while ($row = mysql_fetch_array ($result)) { ?>

                                    <div class="item_notes">
                                    <span class="description_notes"><?php echo $row ['description']; ?></span>
                                    <div class="desc_data_time">
                                    <span class="notes_dt"><?php echo $row ['date']; ?></span>
                                    <span class="notes_dt" ><?php echo $row ['time']; ?></span>
                                    </div>
                                    </div>
                                
                        <?php }?>

function hello(){
    $result = mysql_query(" SELECT * FROM eb_notes ORDER BY `id` DESC");

}

But unfortunately writes an error in . It seems to me that the variable is not being transferred... How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Silm, 2016-02-26
@Silm

Have you tried learning the language you want to write in first?
I'll even give you a link: php.net/manual/ru/language.functions.php
After 5 minutes of reading enlightenment will come, try starting with this next time

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question