google-site-verification: googlebaca44933768a824.html so... php - Old Royal Hack Forum

Announcement

Collapse
No announcement yet.

so... php

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    so... php

    Hello, I'm trying to make a simple image gallery which will check the image urls from my mysql databse, also in that database I have descriptions for those images, but now I'm doing something wrong, see my code:
    Code:
    <?php
    require_once "config.php"; //connect to mysql and select db here
    $kuvahaku = mysql_query("SELECT photopath, 'desc' FROM kuvat") or die (mysql_error()); //"kuvahaku" is finnish and means "get pics"
    $row_kuvahaku = mysql_fetch_assoc($kuvahaku);
    $totalRows_kuvahaku = mysql_num_rows($kuvahaku);
    ?>
    
    <table border="1" align="center"> // simple table to show pic thumbnails
    <?php $i=0; $numberpage=7; ?>
    <?php do { ?>
    <?php if($i%$numberpage==0) echo "<tr>";?>
    	<td align="center">
        <img src=<?php echo $row_kuvahaku['photopath']; ?> height="100" width="100"><br /><?php echo $row_kuvahaku['desc']; ?></td> //PROBLEM HERE!!
    <?php $i++; if($i%$numberpage==0) echo "</tr>";?>
    <?php } while ($row_kuvahaku = mysql_fetch_assoc($kuvahaku)); ?>
    </table></div> // don't care about this div, this code is just the snippet from my site!
    <?php
    mysql_free_result($kuvahaku);
    ?>
    So I'm trying to thumbnails of the pics, it works fine ( <img src=<?php echo $row_kuvahaku['photopath']; ?> height="100" width="100"> ),

    but for the description (desc), something is wrong?

    here's image: as you can see there only reads "desc" where should be the descriptions.

    every picture is right, every pic is different so no problems from there but this desc thing drives me crazy!!! :D
    ok bai

    #2
    Re: so... php

    found the problem at mysql query:
    'desc' should be `desc`

    this php & mysql is a crazy world
    ok bai

    Comment

    Working...
    X