Jump to content

Another question


Renlok

Recommended Posts

If you have a page set out like the following

Name  ¦  Rating 
Tey    ¦      7
Lay      ¦    3
Hey    ¦      8

Each item in the Name collom would be a link to another page showing more information about that item such as description comments etc.

how would you do this without individually creating each page.
Link to comment
Share on other sites

Well, if you could do something like:

[code]
$query = "SELECT name FROM table ORDER BY name";
$result = mysql_query($query) OR die(mysql_error());
while ($row = mysql_fetch_array($result))
{
$name = $row['name'];
echo "<a href=page.php?page=$name>$name</a>";
        //url parameters would be page.php?page=Page
}
[/code]

Then make your page.php. On page.php you would use the $_GET global to get the page name and return your results based on the page.

[code]
$page = $_GET['page'];
$query = "SELECT * FROM table WHERE page = '$page'";
//etc
[/code]

Of course, that is just an example.
Link to comment
Share on other sites

Thanks for that i added it to my page
Page Title (shows at top of page:
[code] <?php
$page = $_GET['page'];
$query = "SELECT * FROM link WHERE siteName = '$page'";
echo $page;
?>[/code]

Main code:
[code]   <?php
  $result = $db->query($query);
$row = $result->fetch_assoc();
echo '<font size=6><b><u>'.stripslashes($row['siteName']).'</b></u></font>';
echo '<p>';
echo 'Added to Our Database at:<br>';
echo stripslashes($row['timeEdited']).'<p>';
echo '<a href="'.stripslashes($row['url']).'">'.stripslashes($row['url']).'</a>';
echo '<p>';
echo '<u>Sites Description:</u>';
echo stripslashes($row['discription']).'<br>';
echo '<u>Keywords Entered For Site:</u>';
echo stripslashes($row['keywords']).'<br>';
echo 'Current Rating: ';
$URL = ($row['url']);
        $rate_query = "SELECT AVG(ratingValue) FROM rating WHERE URL = '$URL'";
        $rate_result = $db->query($rate_query);
        $row = $rate_result->fetch_row();
        $avg = $row[0];
        echo $avg;
echo 'Rate Site:<br>';
        echo '<form name="'.$URL.'" form action="rate.php" method="post" target="_blank" form>'.
        '<select name="rate">'.
            '<option value="1">1</option>'.
            '<option value="2">2</option>'.
            '<option value="3">3</option>'.
            '<option value="4">4</option>'.
          '<option value="5">5</option>'.
              '<option value="6">6</option>'.
              '<option value="7">7</option>'.
              '<option value="8">8</option>'.
              '<option value="9">9</option>'.
                '<option value="10">10</option>'.
        '</select>'.
        '<input name="url" type="hidden" value="'.$URL.'" size="13" maxlength="125">'.
      '<input type="submit" value="Submit">'.
    '</form>';
  mysqli_free_result($result);
      $db->close();
  ?>[/code]

I have that but it just shows a blank page with the html code on it not sure why.
Link to comment
Share on other sites

Ok there it is
[code]          <tr>
            <td nowrap class="datacelltwo">
                <?php
                    echo stripcslashes($row['siteName']);
                ?>
            </td>
            <td class="datacellone">
                    <?php                   
                        $name = $row['siteName'];
                    echo "<a href=page.php?page=$name>$name</a>";
                    ?>
            </td>[/code]
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.