Page 1 of 1
ARGH!!!
Posted: Sun Nov 14, 2004 5:58 pm
by patch2112
I'm trying to create a bread crumb using variables passed on the URL. Here is the code in question...
Code: Select all
<a href="product.php?category=<?php echo($rowї"cat_name"]); ?>"><?php echo($rowї"cat_name"]); ?></a> > <?php echo($rowї"item_name"]); ?>
The text part of the link works fine, but the url is blank after the =, yet they are written the same. I tried every combination of esc characters and I couldn't get it. Any ideas?
Thanks!
Philip
Posted: Sun Nov 14, 2004 6:59 pm
by ol4pr0
Well u sure that cat_name actually has something ?, looks to me that row[cat_name] is empty. Cuase for as far i can see the code should work
Code: Select all
<?
echo $row['cat_name'] ; //emtpy ?
if($row[cat_name] !=NULL){
?>
<a href="product.php?category=<?php echo($row["cat_name"]); ?>"><?php echo($row["cat_name"]); ?></a> > <?php echo($row["item_name"]);
}
else
{
echo 'Sorry m8, nothing inthere';
}
?>
Posted: Sun Nov 14, 2004 7:01 pm
by patch2112
I'm sure it's got something, because it is used twice in this same snippet and one works and one doesn't it's wierd. NOW, I'm getting an extra character in all my outputs. Should I restart my apache or something?
Posted: Sun Nov 14, 2004 7:03 pm
by ol4pr0
Example link? of that output ? or a copy and paste?
Var working, but still extra character
Posted: Mon Nov 15, 2004 2:39 pm
by patch2112
That var started working (although I didn't change anything) but I'm still getting that extra character. Here's the code.
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
$_GETї'product'] = $product;
#Connect to MySQL
$conn = @mysql_connect ("198.66.222.95",philip,"daisey2112")
or die("Err: Connection Failed");
#select the specified database
$rs = mysql_select_db("jeap", $conn)
or die ("Err: Database Selection Failed");
#create the query
$sql="select * from products where item_number = "$product""
or die("Didn't select product");
#execute the queries
$rs = mysql_query($sql,$conn);
$row=mysql_fetch_array($rs);
#select the product record to be used
$rs_product = mysql_query("select * from products where item_number = "$product"",$conn)
or die ("Didn't select records");
#translate resource ID into row
$row_col = mysql_fetch_row($rs_product)
or die("Err, translate");
#get size of $row_col for loop
$size = count($row_col)
or die ("Didn't get size");
#loop through arrays to get values
for ($i=0; $i < $size; $i++)
{
#located columns with "Col_Y" as result
if ($row_colї$i] == "Col_Y")
{
$field_col = mysql_fetch_field($rs_product, $i)
or die("Didn't fetch field");
#Selects color info (gif url/name) based on having the same name as $field_col then creates the html to display
$rs_colors = mysql_query("select * from colors where color_name = "$field_col->name"")
or die("Didn't select colors based on field_co");
#translate resource ID into row
$row_col_colors = mysql_fetch_array($rs_colors)
or die("Err, translate #2");
#generate html
$color_selected .= "<img src="$row_col_colorsїcolor_img]" alt="$row_col_colorsїcolor_name]" width="30" height="13" border="1"> ";
}
}
#create the query for the side links
$cats=mysql_query("select * from products where cat_name = "$rowїcat_name]"",$conn);
#loop through result and generate html for side links
while ($cat_row = mysql_fetch_array($cats))
{
$cat_links .="<li><a href="product.php?product=$cat_rowїitem_number]">$cat_rowїitem_name]</a></li>";
}
?>
Bunch of html/js and then...
Code: Select all
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="mainrepeating">
<!--DWLayoutTable-->
<tr>
<td width="19" height="19"> </td>
<td width="168" rowspan="5" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="168" height="27" valign="top" class="catheader"> <? echo($rowї"cat_name"]); ?> </td>
</tr>
<tr>
<td height="114" valign="top" class="catbody">
<ul> <? echo ("$cat_links"); ?> </ul>
<p align="center"><a href="#">View Full Catalog</a></p></td>
</tr>
<tr>
<td height="98" valign="top"><a href="order_online.htm"><img src="images/order_panel.gif" width="168" height="98" border="0"></a></td>
</tr>
<tr>
<td height="107" valign="top"><a href="contact_us.htm"><img src="images/contact_panel.gif" width="168" height="98" border="0"></a></td>
</tr>
</table></td>
<td colspan="5" valign="top" class="crumbs"><a href="index.htm">Jeap</a>
> <a href="product.php?category=<?php echo($rowї"cat_name"]); ?>">
<?php echo($rowї"cat_name"]); ?></a> > <? echo($rowї"item_name"]); ?></td>
</tr>
<tr>
<td height="78"></td>
<td width="6"> </td>
<td colspan="4" valign="top" class="header1"> <?php echo($rowї"item_name"]); ?> </td>
</tr>
<tr>
<td height="280"></td>
<td> </td>
<td width="13"> </td>
<td width="24"> </td>
<td width="220" valign="top"> <?php echo("<img src="$rowїimg]" border="1">"); ?> </td>
<td width="313" valign="top" class="ProductContent"> <p> </p>
<? if ($rowї"material"] != NULL) {
echo ("<p><strong>MATERIAL</strong>: $rowїmaterial]</p> ");
} ?>
<? if ($rowї"weight"] != NULL) {
echo ("<p><strong>WEIGHT</strong>: $rowїweight] </p>");
} ?>
<ul>
<? if ($rowї"bullet_1"] !="NULL") {
echo ("<li>$rowїbullet_1]</li>"); }
if ($rowї"bullet_2"] !="NULL") {
echo ("<li>$rowїbullet_2]</li>"); }
if ($rowї"bullet_3"] !="NULL") {
echo ("<li>$rowїbullet_3]</li>"); }
if ($rowї"bullet_4"] !="NULL") {
echo ("<li>$rowїbullet_4]</li>"); }
if ($rowї"bullet_5"] !="NULL") {
echo ("<li>$rowїbullet_5]</li>"); }
if ($rowї"bullet_6"] !="NULL") {
echo ("<li>$rowїbullet_6]</li>"); }
?>
</ul>
<p><strong>COLORS</strong>:<br>
<?
#color stuff goes here
echo ("$color_selected <br>");
?>
</p></td>
</tr>
<tr>
<td height="157"></td>
<td> </td>
<td colspan="4" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td height="75"></td>
<td> </td>
<td> </td>
<td colspan="3" valign="top"><p><a href="tell_pop.htm" onClick="MM_openBrWindow('tell_pop.htm','','width=465,height=345'); return false">Tell a friend about us!</a></p>
<p><a href="specials_pop.htm" onClick="MM_openBrWindow('specials_pop.htm','','width=465,height=345'); return false">Sign up for our e-mail specials.</a></p></td>
</tr>
</table>
It appears soon after the crumbs section. I also sometimes get the "Err: Translate #2" die message.
Posted: Mon Nov 15, 2004 3:47 pm
by patch2112
ERRRR,
I just restarted apache and it is working fine now.
Philip
Posted: Mon Nov 15, 2004 4:14 pm
by patrikG
patch2112 wrote:ERRRR,
I just restarted apache and it is working fine now.
Philip
Solved.