php - Stuck with SQL repeating first row only -


ok, here goes.

i'm trying write blogging system (learning how anyway), , problem have sql returning first line in database. many times records have. can't work out going wrong. can point me in right direction please?

<?php      include "db_connect.php";     include "functions.php";     include "style/header.php"; ?>  <link href="style/style.css" rel="stylesheet" type="text/css">  <div id="main">  <?php        echo 'welcome forest, '.$_session['username'];     $sql = mysql_query("select post_id, post_user, post_title, post_description, post_info, post_date posts");    $row = mysql_fetch_array($sql);     $post_id = $row['post_id'];    $post_user = $row['post_user'];    $post_title = $row['post_title'];    $post_description = $row['post_description'];    $post_info = $row['post_info'];    $post_date = $row['post_date'];    { ?>  <article> <h2>  <?php  echo  $post_title;  ?> </h2> <?php     echo $post_description;     echo $post_info;     echo 'posted '.$post_user.' on '.$post_date;  } while ($row = mysql_fetch_array($sql));  ?> </article> </div> 

you better served write code (for example, this page)

$result = mysql_query("select id, name mytable");  while ($row = mysql_fetch_array($result, mysql_assoc)) {     printf("id: %s  name: %s", $row["id"], $row["name"]); } 

also please note using mysql_* functions not recommended, these functions deprecated , removed in future versions of php.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -