0

Hi

I am trying to echo this info with the different rows in the database but when I try the following code only the first result shows up. Please can someone help

<?php
$con = mysql_connect("localhost","blar","blar");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("blar", $con);

$result = mysql_query("SELECT * FROM TABLE") or trigger_error(mysql_error().$sql);
$row = mysql_fetch_array($result); {
echo '<ul class="feature-list-smaller">
            <li>
                <a href="#" class="icon"><img src="image.png" width="52" height="52" alt="" /></a>
                <div class="text">
                    <h4><a href="'. $row['Link'].'-contract.php">'. $row['Make'].' '. $row['Model'].'</a></h4>
                </div>
            </li>
            </ul>';
}
echo "/n";
?>

Hope someone can help. Thanks in advance

4
Contributors
7
Replies
9
Views
5 Years
Discussion Span
Last Post by LastMitch
0

Yes, well it will unless you use a loop. Try

while($row = mysql_fetch_array($result)){
0

BTW: Adam's is better if you're not using column numbers to reference your fields, which I assume you're not. The *_array() function returns an index-based array AND an associative array, whereas the *_assoc() just returns the associative array. For a good look, print out the result with something like print_r($row).

If solved, please mark it so.

0

Hi Sorry, now i have a problem with this, if you can help please

fields have spaces in the fields being echoed, how would I use the replace to change those spaces to a dash.

Make field will be something like blar blar blar and I need it to be blar-blar-blar

<h4><a href="">'. $row['Make'].'</a></h4>

Hope you can help again. Thanks

0
echo '<h4><a href="">'. str_replace(' ','-',trim($row['Make'])) . '</a></h4>';

Edited by diafol

0

@diafol

I think he double post this. You gave the correct answer for this post and the other post

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.