Jump to content


Photo

Another question


  • Please log in to reply
5 replies to this topic

#1 Renlok

Renlok
  • Members
  • PipPipPip
  • Advanced Member
  • 258 posts
  • Locationnewbury

Posted 21 October 2006 - 10:05 PM

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.

#2 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 21 October 2006 - 10:30 PM

Well, if you could do something like:

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

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.

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

Of course, that is just an example.

#3 Renlok

Renlok
  • Members
  • PipPipPip
  • Advanced Member
  • 258 posts
  • Locationnewbury

Posted 22 October 2006 - 12:23 AM

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

Main 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();
	  ?>

I have that but it just shows a blank page with the html code on it not sure why.

#4 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 22 October 2006 - 12:32 AM

Can you post the code you have for the other page, the one that generates the links to go to the main page.

#5 Renlok

Renlok
  • Members
  • PipPipPip
  • Advanced Member
  • 258 posts
  • Locationnewbury

Posted 22 October 2006 - 09:21 AM

Ok there it is
          <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>


#6 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 22 October 2006 - 12:18 PM

it would be something to do with the getting the results. check to see if your actually getting information from the table.
Good luck with your coding.
Jason / ProjectFear / Jaysonic




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users