E
E
Erl2017-10-26 12:36:26
PHP
Erl, 2017-10-26 12:36:26

How to make change for all elements?

Link to the structure: https://jsfiddle.net/o28r7cc6/
There is a structure:
1) date
2) title
3) announcement
You need to do the following:
1) remove the title
2) add a link to "More" at the end of the announcement

Decided as follows, moved heading to the bottom of the announcement and changed the heading text to "More", but it only worked for the first element
How to apply to all elements?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
I
irishmann, 2019-07-29
@IwanQ

So you take a closer look at your code. The first 4 lines and the last one work regardless of $_POST['submit']. In other words, when you refresh the page, you generate a shortened link for empty $url, then check if there is $_POST['submit'], if there is, display the link, write to files, if not, then do not output anything and do not write to any files, then write the link for empty $urlto the database. Doesn't it bother you? You don't have to be a pro to understand what a stupid mistake this is.
This is how it should be for you so that there are no false positives

↓ ↓ ↓ CODE ↓ ↓ ↓
<?php
    if ($_POST['submit']) {
        $h = "QqWwEeRrTtYyUuIiOoPpAaSsDdFfGgHhJjKkLlZzXxCcVvBbNnMm1234567890"; //Выбираем символы, из которых будет состоять наш рандом
        $rand = substr(str_shuffle($h), 0, 5); //создаём ранд. Цифра 5 обозначает длину ранда
        $site = "http://test.com/"; //Адрес сайта. 
        $url = $_POST['url'];
        echo "<div class='a'>
        <a href='".$site.$rand."'>".$site.$rand."
        </a>
        </div>"; //выводим пользователю ссылку, в виде ссылки
        $f = fopen("a/$rand.php", "w"); //Файл с именем ранда.
        fwrite($f, "<?php header('Location: $url') ?>"); //И записываем в код редиректа, с ссылкой которую ввёл пользователь
        fclose($f); //Закрываем файл
        $fh = fopen(".htaccess", "a"); //Открываем файл .htaccess с дозаписью на последний байт
        fwrite($fh, "
        RewriteRule ^$rand$ /a/$rand.php"); //Записываем ссылку на файл в каталоге a и её сокращённый вариант, который был дан пользователю. 
        fclose($fh); //Закрываем файл
        $connect->query("INSERT INTO `url` (`url`) VALUES ('".$site.$rand."')");
    }

A
Anton R., 2019-07-29
@anton_reut

<a href='$site$rand'>$site$rand
In my opinion, it is impossible to sculpt variables to each other, where is the concatenation through points?

0
0xD34F, 2017-10-26
@NooBiToo

[...document.getElementsByClassName('news-block_item')].forEach(n => {
  n.querySelector('.tit_link').innerHTML = '[Подробнее]';
  n.appendChild(n.querySelector('.news-item_title'));
});

S
Stalker_RED, 2017-10-26
@Stalker_RED

Hiding the header with css
For each announcement (.each())
Adding a "more" link
https://jsfiddle.net/o28r7cc6/2/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question