Jump to content

Displaying mysql results not working


aquatradehub

Recommended Posts

Hi, I got a page with labels for aquatic species. Next to the labels I want to display the results from the db table for that row, but I cant get it to work.

 

Here is what I got


<?php
$commonName = 'African Butter Catfish';
$connect_error = 'Sorry, we are currently experiencing database issues. We are working to resolve this and should be up and running again shortly.';
mysql_connect('localhost', 'username', 'password') or die($connect_error);
mysql_select_db('equatics_tropics') or die($connect_error);
mysql_query("SELECT * FROM species WHERE commonName='$commonName'") or die(mysql_error());



?>

<section id="content">
<article id="index">
<section class="index">

    

    <fieldset title="e-quatics.com">
        <legend>PHP CODE TO SHOW COMMON NAME</legend>
        <p><img src="../_images/tropical.png" height="250" width="250">
        Common Name: <? echo $rows['speciesCommon']; ?><br>
        Scientific Name: <? echo $rows['speciesScientific']; ?> <br>
        Synonym: <? echo $rows['speciesSynonym']; ?><br>
        Origin: <? echo $rows['origin']; ?><br>
        Size: <? echo $rows['size']; ?><br>
        Environment: <? echo $rows['environment']; ?><br>
        Water Chemistry: <? echo $rows['waterChemistry']; ?><br>
        Temperature: <? echo $rows['temperature']; ?><br>
        Feeding: <? echo $rows['feeding']; ?><br>
        Sexing: <? echo $rows['sexing']; ?><br>
        Compatability: <? echo $rows['compatability']; ?><br>
        Temperament: <? echo $rows['temperament']; ?><br>
        Sexing: <? echo $rows['sexing']; ?><br>
        Breeding: <? echo $rows['breeding']; ?><br>
        Comments: <? echo $rows['comments']; ?></p>
        
        
    </fieldset>
            
</form>
</section>
</article>

<?php
    include 'includes/overall/footer.php';
?>

</body>


 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/279879-displaying-mysql-results-not-working/
Share on other sites

$res = mysql_query('your query...');
while ($row = mysql_fetch_assoc($res)) {
?>
<fieldset title="e-quatics.com">
        <legend>PHP CODE TO SHOW COMMON NAME</legend>
        <p><img src="../_images/tropical.png" height="250" width="250">
        Common Name: <? echo $row['speciesCommon']; ?><br>
...
<?php
}

p.s. Do you know that mysql driver is deprecated by now? It is advisible to use mysqli or Pdo instead.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.