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

Edited by fenway
code tags
Link to comment
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.