Hello,

I am trying to get this to loop through all the available items in a database and return the results.

<?php 
    $qry = mysqli_query($con,"SELECT * FROM `favorites` WHERE `username` = '$id'") or die(mysqli_error($con));

        while($rowa = mysqli_fetch_array($qry)) {
            $slugname = $rowa['slug_name'];
            $url = $rowa['slug'];
    echo '<a href="'.$url.'>'.$slugname.'</a>"';

    }
?>

I think i need a foreach loop, but not sure how todo it.

Thanks in advance

Where is your connection string?

For your loop try this:

while($row = mysqli_fetch_array($qry)){
    echo '<a href="' . $row['slug'] . '">' . $row['slug_name'] .  '</a>';
}

My connecting string is attached above as an include. Is that going to return all results back to the user?

Is the new loop working? If not need to see the rest of the code.

Its working beautifully! Thanks