Need the correct link syntax for the following url...
07-07-2011, 07:13 PM
|
Need the correct link syntax for the following url...
|
Posts: 2,162
Name: ...
Location: ...
|
Basically, I am trying to link to the subcategories. The connection is correct, the url is not.
Can someone correct me on this?
PHP Code:
echo "<a href=\"$_SERVER[PHP_SELF]?$row[subcategory_id]\">$row[category_name]</a>";
Thank you! 
__________________
Made2Own
|
|
|
|
07-07-2011, 07:50 PM
|
Re: Need the correct link syntax for the following url...
|
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
|
Are you forgetting the parameter key name? Such as:
$_SERVER[PHP_SELF]?id=$row[subcategory_id]
__________________
<mgraphic /> - I don't have a solution but I admire the problem.
|
|
|
|
07-07-2011, 10:11 PM
|
Re: Need the correct link syntax for the following url...
|
Posts: 2,162
Name: ...
Location: ...
|
Quote:
Originally Posted by mgraphic
Are you forgetting the parameter key name? Such as:
$_SERVER[PHP_SELF]?id=$row[subcategory_id]
|
No, the output of the link is up to $_SERVER[PHP_SELF] (in which case is up to the filename of the page dot php, but nothing after that.
__________________
Made2Own
|
|
|
|
07-08-2011, 10:50 AM
|
Re: Need the correct link syntax for the following url...
|
Posts: 2,162
Name: ...
Location: ...
|
Anyone else have a solution to stubborn url?
__________________
Made2Own
|
|
|
|
07-08-2011, 10:54 AM
|
Re: Need the correct link syntax for the following url...
|
Posts: 2,815
Name: Matt
Location: Irvine, CA
|
Can you post the resulting url?
|
|
|
|
07-08-2011, 10:59 AM
|
Re: Need the correct link syntax for the following url...
|
Posts: 2,162
Name: ...
Location: ...
|
__________________
Made2Own
|
|
|
|
07-08-2011, 11:04 AM
|
Re: Need the correct link syntax for the following url...
|
Posts: 2,815
Name: Matt
Location: Irvine, CA
|
Quote:
Originally Posted by Brian07002
|
I don't see how that url can result from the code you posted. Where is the query string?
|
|
|
|
07-08-2011, 11:08 AM
|
Re: Need the correct link syntax for the following url...
|
Posts: 2,162
Name: ...
Location: ...
|
Here's the category.php source:
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> <head> <title>Reunite My Site - Category Index</title>
<!-- <link rel="stylesheet" type="text/css" href="/css/default.css" media="screen"> --> <link rel="stylesheet" type="text/css" href="/css/pagination.css" media="screen">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" > <meta name="Description" content="The World's Most Trusted Source For Online Advertising!">
<style type="text/css">
html { height: 100%; width: 100%; }
body { height: 100%; width: 100%; margin: 0px auto; }
#gradient { border: 1px solid #000; background: #c5deea; /* old browsers */ background: -moz-linear-gradient(top, #c5deea 0%, #8abbd7 31%, #066dab 100%) fixed no-repeat; /* firefox */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#c5deea), color-stop(31%,#8abbd7), color-stop(100%,#066dab)) fixed; /* webkit */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c5deea', endColorstr='#066dab',GradientType=0 ); /* ie */ margin: 0px auto; }
a:link {color:#fff; Tahoma, Geneva, sans-serif; font-weight:normal; font-size: 16px; text-decoration: none} a:visited {color:#fff; Tahoma, Geneva, sans-serif; font-weight:normal; font-size: 16px; text-decoration: none;} a:hover {color:#fff; Tahoma, Geneva, sans-serif; font-weight:normal; font-size: 16px; text-decoration: none;} a:active {color:#fff; Tahoma, Geneva, sans-serif; font-weight:normal; font-size: 16px; text-decoration: none;}
div { margin-left: 5px; margin-right: 5px; }
</style> </head>
<body>
<!-- The Following Php Code is the pagination script, which will create pages based on the number of banners in the database. Ex: 2 columns (across) x 5 Rows (down) the page -->
<?php
/* Include your code to connect to DB. */ include('cats_db.php');
/* Your DB table name */
$tbl_name="categories";
// How many adjacent pages should be shown on each side? $adjacents = 1;
/* First get total number of rows in data table. If you have a WHERE clause in your query, make sure you mirror it here. */
$query = "SELECT COUNT(*) as num FROM $tbl_name"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num];
/* Setup vars for query. */ $targetpage = "categories.php"; //your file name (the name of this file)
$limit = 16; //how many items to show per page
$page = $_GET['page']; if($page) $st = ($page - 1) * $limit; //first item to display on this page
else $st = 0; //if no page var is given, set st to 0 /* Get data. */
$sql = "SELECT category_name FROM $tbl_name LIMIT $st, $limit"; $result = mysql_query($sql);
/* Setup page vars for display. */
if ($page == 0) $page = 1; // if no page var is given, default to 1. $prev = $page - 1; // previous page is page - 1 $next = $page + 1; // next page is page + 1 $lastpage = ceil($total_pages/$limit); // lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; // last page minus 1
/* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */
$pagination = ""; if($lastpage > 1) { $pagination .= "";
//previous button
if ($page > 1) $pagination.= "<a href=\"$targetpage?page=$prev\" class=\"current\"> previous </a>"; else $pagination.= "<span class=\"disabled\"> previous </span>";
//pages
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"number\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\" class=\"number current\">$counter</a>"; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some {
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "<span class=\"number\">$counter </span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\" class=\"number current\">$counter</a>"; } $pagination.= "<span class=\"dots\">...</span>"; $pagination.= "<a href=\"$targetpage?page=$lpm1\" class=\"number\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\" class=\"number current\">$lastpage</a>"; }
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?page=1\" class=\"number\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\" class=\"number\">2</a>"; $pagination.= "<span class=\"dots\">...</span>"; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"number\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\" class=\"number current\">$counter</ a>"; } $pagination.= "<span class=\"dots\">...</span>"; $pagination.= "<a href=\"$targetpage?page=$lpm1\" class=\"number\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\" class=\"number current\">$lastpage</a>"; }
//close to end; only hide early pages
else { $pagination.= "<a href=\"$targetpage?page=1\" class=\"number\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\" class=\"number\">2</a>"; $pagination.= "<span class=\"dots\">...</span>"; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"number\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\" class=\"number current\">$counter</a>"; } } } //next button
if ($page < $counter - 1) $pagination.= "<a href=\"$targetpage?page=$next\" class=\"number current\"> next </a>"; else $pagination.= "<span class=\"disabled\"> next </span>"; $pagination.= "</div>\n"; } // End of Pagination Script //
?>
<!-- Table Output Code -->
<?php
$query = "SELECT * FROM categories subcategories LIMIT $st, $limit"; $result = mysql_query($query) or die(mysql_error());
$cols=4; // Here we define the number of columns echo "<div id=\"gradient\">"; echo "<div align=\"center\"><h2>Reunite My Site - Category Index</h2>"; echo "<table id=\"main\" width=\"100%\">"; // The container table with $cols columns do { echo "<tr>"; for($i=1;$i<=$cols;$i++) { // All the rows will have $cols columns even if the records are less than $cols
$row=mysql_fetch_array($result); if($row){ // $img = $row['image_path']; ?> <td> <table> <tr valign="top"> <!-- <td><img src="http://tycoontalk.freelancer.com/images/<?php $img ?>" /></td> <!-- columns can have both text and images -->
<td> <b><div align="center"> <?= "<a href=\"$row[url]\">". $row['category_name'] ?> </a></div></b> <!-- <br /> -->
<!-- <b><div align="center"> <?="<a href=\"$row[url]\">".$row['subcategory_name']?></a><br /></b> --> <!--<?=$row['password'] ?><br /> -->
</td>
<td id="3" width="50"> </td> <!-- Create gap between columns --> </tr> </table> </td>
<?php } else{ echo "<td> </td>"; //If there are no more records at the end, add a blank column } } } while($row); echo "</div>"; echo "</table>";?>
<?php // Print out the contents of each row into a table // echo "<a href=\".$_SERVER[PHP_SELF].'?id=\ . $row[subcategory_id] .\">$row[category_name]</a>";
echo "<a href=\"categories.php?scid=$subcategory_id\">$category_name</a>";
echo "<br />"; ?>
<?=$pagination?>
<script type="text/javascript" src="http://www.reunitemysite.com/scripts/stats/track.php?mode=js"></script> <noscript><img src="http://www.reunitemysite.com/scripts/stats/track.php?mode=img" border="0" alt="" width="1" height="1"></noscript>
<div class="pagination white">
<div align="center" valign="absbottom"><a href="http://www.reunitemysite.com/main.php#Top" target="_parent">Leave Category Index</a> <a name="Top" target="_TOP"> </a> </div> </body> </html>
Note: I used scid, rather than id since that is where the links are going to. Subcategory id
__________________
Made2Own
Last edited by Brian07002; 07-08-2011 at 11:09 AM..
|
|
|
|
07-08-2011, 12:31 PM
|
Re: Need the correct link syntax for the following url...
|
Posts: 2,162
Name: ...
Location: ...
|
Going somewhere for a few hours, be back online tonight to check back.
Thanks alot!
__________________
Made2Own
|
|
|
|
07-08-2011, 07:45 PM
|
Re: Need the correct link syntax for the following url...
|
Posts: 2,162
Name: ...
Location: ...
|
OK I am back. No replies, any suggestions?
__________________
Made2Own
|
|
|
|
07-09-2011, 05:06 AM
|
Re: Need the correct link syntax for the following url...
|
Posts: 807
Name: Mattias Nordahl
Location: Sweden
|
Very messy code... But I'm guessing the link in question is this one?
PHP Code:
echo "<a href=\"categories.php?scid=$subcategory_id\">$category_name</a>";
It looks alright. Again, how does the generated link look like?
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
|
|
|
|
07-09-2011, 09:14 AM
|
Re: Need the correct link syntax for the following url...
|
Posts: 2,162
Name: ...
Location: ...
|
Quote:
Originally Posted by lizciz
Very messy code... But I'm guessing the link in question is this one?
PHP Code:
echo "<a href=\"categories.php?scid=$subcategory_id\">$category_name</a>";
It looks alright. Again, how does the generated link look like?
|
Yes, that is the code. Let me show you the link in question, then have a look at the page source where the actual query is, it's not complete, or at least in the web page source it's not complete for some reason.
Page in question is:
http://reunitemysite.com/categories.php
__________________
Made2Own
|
|
|
|
07-09-2011, 12:46 PM
|
Re: Need the correct link syntax for the following url...
|
Posts: 807
Name: Mattias Nordahl
Location: Sweden
|
Ah. There is nothing wrong with the syntax for printing the link. The problem is that $subcategory_id and $category_name doesn't have any values.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
|
|
|
|
07-09-2011, 03:50 PM
|
Re: Need the correct link syntax for the following url...
|
Posts: 2,162
Name: ...
Location: ...
|
Quote:
Originally Posted by lizciz
Ah. There is nothing wrong with the syntax for printing the link. The problem is that $subcategory_id and $category_name doesn't have any values.
|
hmm, something like this?
$scid = $subcategory_id;
$cid = $category_name;
<a href=\"$_SERVER['PHP_SELF'] .? scid=$scid \">$cid</a>
-Brian
__________________
Made2Own
|
|
|
|
|
« Reply to Need the correct link syntax for the following url...
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|