J
J
JustMuve2018-05-05 23:18:18
In contact with
JustMuve, 2018-05-05 23:18:18

How to pass variables through a link in php?

Good day, how can I make it so that when a post in index.php is clicked, view.php opens, and the id of the post that was clicked in index.php is passed to the $post_id parameter view.php
index.php

<?php
    require_once("config.php");

    for ($i = 1; $i < count($wall); $i++) {
    $str = preg_replace("/#([\S]+)/", "<b><span class='badge badge-primary'>#\\1</span></b>", $wall[$i]->text);
        echo "
        <div class='annt'><a class='annt__photo' href='https://vk.com/wall-{$group_id}_{$wall[$i]->id}' ><img src=".$wall[$i]->attachments[0]->photo->photo_130." width='80' height='60' alt></a><div class='annt__services'>
        </div><div class='annt__note'>Недвижимость › Коммерческая недвижимость </div><a class='annt__text' href='https://vk.com/wall-{$group_id}_{$wall[$i]->id}' >".$str."</a>
    <div class='annt__note'>Обновлено:".date("Y-m-d H:i:s", $wall[$i]->date)."</div></div>";
    }
    ?>

view.php
<?php
$records_json=file_get_contents("https://api.vk.com/method/wall.getById?posts=-***$post_id***&extended=0&v=5.60");
$records=json_decode($records_json, true);


foreach($records['response'] as $record) {
    echo "<li id='".$record['id']."'>".$record['text']."";

   // if (isset($record['attachment']['photo']['src_big']))
        for ($i = 0; $i < 10; $i++) {
  echo "<p><img src='".$record['attachments'][$i]['photo']['photo_604']."'></p>";
}
    echo "</li>";
}
?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question