Note that there are some explanatory texts on larger screens.

plurals
  1. POGet ID count from Database and generate dynamic links to news
    primarykey
    data
    text
    <p>Yesterday I asked this question: <a href="https://stackoverflow.com/questions/15117767/add-dynamic-content-to-otherwise-static-php-page">https://stackoverflow.com/questions/15117767/add-dynamic-content-to-otherwise-static-php-page</a> I´m sorry for the not very precise question. I accomplished a lot more now by myself but I still have a few questions.</p> <p>I managed to put my news into a Database Table with the following columns: "id", "news_headline", "news_date", "news_teaser", "news_content", "news_external_link"</p> <p>On my news/index.php I have the following code now:</p> <pre><code>&lt;?php $con=mysqli_connect("localhost", "XXX", "oizQvdjh", "usr_web3_1"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT * FROM tbl_news ORDER BY id DESC"); while($row = mysqli_fetch_array($result)) { echo "&lt;li class='clearfix'&gt;"; echo "&lt;a class='news_pic'&gt;&lt;img src='/assets/images/news/news_".$row['id'] ."_thumb.jpg'&gt;&lt;/a&gt;"; echo "&lt;h2 class='info_headline'&gt;" . $row['news_headline'] . "&lt;/h2&gt;"; echo "&lt;p class='date'&gt;" . $row['news_date'] . " &amp;ndash; &lt;a href='#disqus_thread'&gt;&lt;/a&gt;&lt;/p&gt;"; echo "&lt;p class='news_text'&gt;" . $row['news_teaser'] . "&lt;br&gt;&lt;a class='more-link' href='WHERE_TO'&gt;Read more&lt;/a&gt;&lt;/p&gt;"; echo "&lt;/li&gt;"; } mysqli_close($con); ?&gt; </code></pre> <p>Everything looks great there and it fetches all my news from the database (five so far) and gets the image which I uploaded by myself on the server with names according to the id.</p> <p>The single News side has the same code except it has a "WHERE" statement and grabs the content text and not the teaser:</p> <pre><code>$result = mysqli_query($con,"SELECT * FROM tbl_news WHERE id='1' ORDER BY id DESC"); while($row = mysqli_fetch_array($result)) { echo "&lt;h2&gt;" . $row['news_headline'] . "&lt;/h2&gt;"; echo "&lt;p class='date'&gt;" . $row['news_date'] . " &amp;ndash; &lt;a href='#disqus_thread'&gt;&lt;/a&gt;&lt;/p&gt;"; echo "&lt;a class='news_pic'&gt;&lt;img src='/assets/images/news/news_".$row['id']." .jpg'&gt;&lt;/a&gt;"; echo "&lt;p class='news_text'&gt;" . $row['news_content'] . "&lt;/p&gt;"; } mysqli_close($con); ?&gt; </code></pre> <p>Now to my question. How do I have to save the file of the single news to get it dynamically updatet. In my Index where the href says "WHERE TO" I want a link like <code>&lt;a href="&lt;?php echo $row['news_date'] + slug</code> (I would add a column slug in my table).</p> <p>The news single php should then be generated and should also say the date and slug in the URL. Like XXX/news/2013-02-18_this-is-a-news-site.php I know that for that I also have to put a variable into the WHERE command: Instead of <code>WHERE id=1</code> --> id="GET AUTOMATICALLY". I also don´t know what to put here.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload