Jump to content


Photo

Displaying mysql results not working


  • Please log in to reply
4 replies to this topic

#1 aquatradehub

aquatradehub

    Advanced Member

  • Members
  • PipPipPip
  • 57 posts

Posted 04 July 2013 - 04:54 PM

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, 14 July 2013 - 09:27 PM.
code tags


#2 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,540 posts

Posted 04 July 2013 - 05:01 PM

you already posted this question on this forum, about three minutes ago :hammer_time:


Edited by mac_gyver, 04 July 2013 - 05:01 PM.

multi-purpose programming fool. well written source-code should be self-documenting. well written code should be self-troubleshooting. 


#3 aquatradehub

aquatradehub

    Advanced Member

  • Members
  • PipPipPip
  • 57 posts

Posted 04 July 2013 - 05:02 PM

sorry, it came up with a message saying it hadnt been posted and to wait and try posting again lol



#4 dodgeitorelse3

dodgeitorelse3

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts

Posted 10 July 2013 - 03:49 PM

try

mysql_query("SELECT * FROM species WHERE commonName='".$commonName."'") or die(mysql_error());


#5 web_craftsman

web_craftsman

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts
  • LocationUkraine

Posted 11 July 2013 - 01:55 AM

$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.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com