[Solved]-Making a dynamic link from a database object
Posted: Thu Apr 14, 2005 10:08 pm
Im trying to make a dynamic link from something i grabbed from a databse. The database shows an image and when i click on that image i want a link that gets created on a new tempelate with more pics included.
Here is the code i have written so far
Here is where i grab the data. i wanna make a link to a tempelate i have named mainitem.php
How do i proceed
Regards
Chris
feyd | Please review how to post code using
Here is the code i have written so far
Code: Select all
<body>
<br>
<br>
<?php
// Database Connection
include 'connect.php';
// If current page number, use it
// if not, set one!
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
// Define the number of results per page
$max_results = 6;
// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);
// Perform MySQL query on only the current page number's results
$sql = mysql_query("SELECT * FROM coats LIMIT $from, $max_results");
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM coats"),0);
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
// Build Page Number Hyperlinks
//echo "<center>Select a Page<br />";
// Build Previous Link
if($page > 1){
$prev = ($page - 1);
$prevs .= "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<[Previous]</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
//echo "$i ";
} else {
$pages .= "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\"> $i </a> ";
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
$nexts .= "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">[Next]>></a>";
}
//echo "</center>";
?>
<table class="mainTable" align="center">
<td align="left" valign="top" width="100">
<?coatmenu();?>
</td>
<td align="center" valign="top" width="600">
<table class="topmiddle" >
<td class ="topcenterpic" colspan=2 align="center" width=350>Online Catalog<br><a class="pic" href="mensmain.php"><img src="pix/men.jpg"></a><img src="pix/dash.jpg"><img src="pix/women.jpg"><br><?//=$prevs?><?//=$pages?><?//=$nexts?></td><td width=250>Search: <INPUT maxLength=200 size=18></td>
<tr>
<?php
$k=0;
while($row = mysql_fetch_array($sql)){
$l = 3;
if (($k % $l) == 0){
echo '<tr></tr>';
}
echo '<td class="maindisplay"><img src="pix/'.$row["name"].'"><br>'.$row["shortdescript"].'<br>'.$row["price"].'</td>';
$k++;
}
?>
</table>
</td>
</table>
</body>How do i proceed
Regards
Chris
feyd | Please review how to post code using
Code: Select all
andCode: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]