php - Display multiple rows in html -


i having issue pulling info database , displaying on page. in table have multiple entries in each column. need pull info , display in descending order column id. displays rows on page:

### ### ### #1# #1# #1# ### ### ###  ### ### ### #2# #2# #2# ### ### ###  ### ### ### #3# #3# #3# ### ### ### 

i can't figure out doing wrong here. it's been little bit since did php , mysql may writing incorrectly don't know.

<? require 'dbinfo.php';     $link = mysqli_connect($servername, $username, $password);     if (!$link) {     die('could not connect: ' . mysqli_error($link));     }     mysqli_select_db($link, $database) or die(mysqli_error($link));      $query = "select `id`, `build`, `buildby`, `description`, `download` `buildlist` order id desc";     $result = mysqli_query($link,$query) or die(mysqli_error($link));      $row = mysqli_fetch_row($result);     $num = mysqli_num_rows($result);     ?>  <?       $num = mysqli_num_rows($result);       if($num) {         while( $row = mysqli_fetch_array($result) ) {     ?>      <article class="one_third">       <h2>build <? echo $row['build'] ?></h2>       <img src="images/80x80.gif" alt="">       <p>build <? echo $row['buildby'] ?><br />       <br /><br /><br />       <? echo $row['description'] ?><br />       <br / >       <a href="<? echo $row['download'] ?>" class="download">download build</a></p><br />     </article>      <article class="one_third midbox">       <h2>build <? echo $row['build'] ?></h2>       <img src="images/80x80.gif" alt="">       <p>build <? echo $row['buildby'] ?><br />       <br /><br /><br />       <? echo $row['description'] ?><br />       <br / >       <a href="<? echo $row['download'] ?>" class="download">download build</a></p><br /><br /><br />     </article>      <article class="one_third lastbox">       <h2>build <? echo $row['build'] ?></h2>       <img src="images/80x80.gif" alt="">       <p>build <? echo $row['buildby'] ?><br />       <br /><br /><br />       <? echo $row['description'] ?><br />       <br / >       <a href="<? echo $row['download'] ?>" class="download">download build</a></p><br />     </article>      <? }} ?> 

there mistakes in code. first don't need fetch row before loop. second - should use mysqli_fetch_assoc instead of mysqli_fetch_array or use $row[index] instead of $row[string].

here correct code:

<?     require 'dbinfo.php';      $link = mysqli_connect($servername, $username, $password);      if (!$link) {         die('could not connect: ' . mysqli_error($link));     }     mysqli_select_db($link, $database) or die(mysqli_error($link));      $query = "select `id`, `build`, `buildby`, `description`, `download` `buildlist` order id desc";     $result = mysqli_query($link,$query) or die(mysqli_error($link));      $num = mysqli_num_rows($result);     if($num) {         while( $row = mysqli_fetch_assoc($result) ) { ?> 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -