SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2002
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Database search and link

    I have a database with columns for name, keyword, description, and link.
    I have the following code to search the database and want it to make the name a link, but the link doesn't match the 'link' row in the database, all I get is the same link for all the names. I'm still new at PHP, and I have no idea what I've done wrong here. Can anyone help? Thanks in advance.

    $result = mysql_query("SELECT * FROM products where keyword like '%$look%' ");
    if (!$result) {
    echo("<P>Error performing query: " .
    mysql_error() . "</P>");
    exit();
    }
    while ( $row = mysql_fetch_array($result) ) {
    ?><a href="<?php ($row["link"]) ?> "><?php echo("<P>" . $row["name"] . "</P>");
    ?></a>
    <?php
    echo("<P>" . $row["description"] . "</P>");
    ?><hr color="0066ff"> <?php
    }
    ?>

  2. #2
    SitePoint Zealot
    Join Date
    Mar 2002
    Location
    Perth, Australia
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ron bennett
    I have a database with columns for name, keyword, description, and link.
    I have the following code to search the database and want it to make the name a link, but the link doesn't match the 'link' row in the database, all I get is the same link for all the names. I'm still new at PHP, and I have no idea what I've done wrong here. Can anyone help? Thanks in advance.

    $result = mysql_query("SELECT * FROM products where keyword like '%$look%' ");
    if (!$result) {
    echo("<P>Error performing query: " .
    mysql_error() . "</P>");
    exit();
    }
    while ( $row = mysql_fetch_array($result) ) {
    ?><a href="<?php ($row["link"]) ?> "><?php echo("<P>" . $row["name"] . "</P>");
    ?></a>
    <?php
    echo("<P>" . $row["description"] . "</P>");
    ?><hr color="0066ff"> <?php
    }
    ?>
    try changing
    PHP Code:
    <?php ($row["link"]) ?>
    to
    PHP Code:
    <?php echo($row["link"]); ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •