Jump to content

sailorsmokey

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Everything posted by sailorsmokey

  1. Gizmola, Thank you for all the help. This clarified some things for me, although I don't yet have that "aha moment" of fully grasping the joins. (Meaning I have to reread your comments in order to sort through things, and I couldn't yet explain this to someone else.....). Your comment on the two queries does make logical sense - I'm just a little behind the curve ball, in that the 2 queries are more clear to me. That being said, I think I need to do some more learning on queries again, as it would also be more efficient to have one query rather than two. I will work on studying up on queries some more. Meanwhile, we can mark this particular problem as solved! Thank you again!
  2. gizmola, Thanks for the input. I guess I don't really understand what's wrong with the way it is, with the two queries. Any expansion on that comment would be appreciated. But your comment did lead me to find the issue. So the pagination query is $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM prods_to_cats WHERE category_id=$showcategory"),0); Now, the table prods_to_cats has the following columns: id int(11) category_id int(11) sub_id int(11) sub_id_2nd int(11) I realized that I have it set up to list each product in there for any different combination of subcategories. So I have some products that are in two or more different subcategories of the same main category. One entry I found listed category_id as 4, sub_id 112 and then the same product in category_id 4, sub_id 103 The query would count this twice because it's only counting the category_id field...... I think I need some sort of DISTINCT command or something......not distinct category_id..... is there a way to select a distinct combination of id and category_id? If someone knows off the top of their head, please do share - meanwhile, I am googling...... *update* I think maybe I need an Inner Join? Could someone help me understand, as I only kind of understand an inner join...... Also, I think a mod may need to move this topic to the SQL forum, as the topic is shifting to SQL rather than PHP
  3. Hi Everyone, I have an ecommerce store that I have done some coding for, and each category has some coding to create pages to display items in that category. For some reason, I am getting a couple of "ghost" pages on the end of a couple categories. For example, look at this page: http://www.autismcommunitystore.com/view.php?category=4 Pages 5 & 6 are blank - page 4 has the last of the items in the category. I have a table called prods_to_cats which connects the products and the categories (a many to many relationship). I'm posting the code here - could someone just let me know if they spot something that looks like trouble? Thank you in advance for your time! <? $category=$_REQUEST['category']; $showcategory=$category; include 'connect.php'; $thiscategory = mysql_query("SELECT * FROM category WHERE category_id=$showcategory", $dbh); $thisrow = mysql_fetch_array($thiscategory); $this_des=$thisrow["category_description"]; $this_text=$thisrow["category_text"]; $titlekey="Products listed in $this_des at Autism Community Store 877-422-5932"; // 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 = 40; // Figure out the limit for the query based // on the current page number. $from = (($page * $max_results) - $max_results); echo '<div id="product">'; $result = mysql_query("SELECT DISTINCT product.id, product.* FROM prods_to_cats INNER JOIN product ON prods_to_cats.id=product.id WHERE prods_to_cats.category_id=$showcategory ORDER BY product.title ASC LIMIT $from, $max_results", $dbh); $numresult = mysql_num_rows($result); if($numresult==0) { echo "<p style='padding-left: 50px'>There are no products listed in this category.</p>\n"; } else { $thiscategory = mysql_query("SELECT * FROM category WHERE category_id=$showcategory", $dbh); $thisrow = mysql_fetch_array($thiscategory); $this_des=$thisrow["category_description"]; echo "<table width='100%'><tr>"; echo "<div style='position:relative; left:150px;'><font size='2'>Return To: <strong><a href='http://www.autismcommunitystore.com'>Home </a></strong></font></div><br/>"; echo "<div style='position:relative ; width:100%' align='center'>"; echo "<br />"; echo "<img src='http://www.watchesandthings.com/autism/images/suppliesHeader.gif'>"; echo "</div>"; echo "<h2>"; echo "<div style='padding-right:20px ; position:relative ; width;100%; text-align:right;'>"; echo "<div style='position:relative ; width;80%; text-align:center; left:20%;'>"; echo $this_des; echo "</div>"; echo "</div>"; echo "</h2>"; echo "<div style='position:relative ; padding-left:30px ; padding-right:30px ; '>"; echo "<p>"; echo "$this_text </p>"; echo "</div>"; echo "</tr>"; $count = 1; $column = 1; //initialize column 1 or 2 //-----------------------code for drop down menu---------------------------------------- include 'browserChecker.php'; /* echo $browser; echo "<br/>"; echo $browser_version; echo "<br/>"; $main_version=$browser_version[0]; echo $main_version; */ if ($browser=='IE' && $browser_version<7){ echo '<br />'; //make version 6 compatible select box if ($category==1 || $category==24){ }else{ ?> <center> <div id="hiddendiv" style="display:;"> <form method="get" enctype="multipart/form-data" action="http://www.autismcommunitystore.com/viewsubcategory.php"> <select id="myselectbox" name="subcategory" > <? $sql="SELECT * FROM subcategory ORDER BY sub_description ASC"; $result=mysql_query($sql, $dbh); while($myrow=mysql_fetch_array($result)) { if ($myrow['category_id']==$category){ $myrow['sub_description'] ?> <option name="subcategory" value="<? echo $myrow['sub_id'] ?>" ><? echo $myrow['sub_description'] ?> </option> <? }//close if for category check }//close drop down while loop ?> </select> </center> <div id="go_subcat"> <input type="submit" value=" GO " style="background-color: #E4DFF3; color: #6F5079; border: 2px solid #6F5079"> </div> </form> </div> <? }//end check category }else{ //make normal select box if ($category==1 || $category==24){ }else{ ?><div style="z-index:2"><br /><form method="get" enctype="multipart/form-data" action="http://www.autismcommunitystore.com/viewsubcategory.php"> <div align="center" style='z-index:5'> <select name="subcategory" size="1" style="background-color: #ffffff; color: #6F5079; border: 2px solid #6F5079"> <? $sql="SELECT * FROM subcategory ORDER BY sub_description ASC"; $result=mysql_query($sql, $dbh); while($myrow=mysql_fetch_array($result)) { if ($myrow['category_id']==$category){ ?> <option name="subcategory" value="<? echo $myrow['sub_id'] ?>" ><? echo $myrow['sub_description'] ?> </option> <? }//close if for category check }//close drop down while loop ?> </select> <input type="submit" value=" GO " style="background-color: #E4DFF3; color: #6F5079; border: 2px solid #6F5079"> </div> </form> </div> <? } }//end browser checker if //-----------------------end code for drop down menu---------------------------------------- //reste variables $result = mysql_query("SELECT DISTINCT product.id, product.* FROM prods_to_cats INNER JOIN product ON prods_to_cats.id=product.id WHERE prods_to_cats.category_id=$showcategory ORDER BY product.title ASC LIMIT $from, $max_results", $dbh); echo "<TABLE cellspacing='20'>"; while($myrow = mysql_fetch_array($result)) { extract($myrow); $location=$image; $price=$sale_price; $item=$myrow["id"]; $stockstatus=$stat; if($stat=='IN STOCK') { $stockstatus=""; } else { $stockstatus="--Item Coming Soon--"; } if($price>0) { $printout="<table border=0 height=70 width=250><tr><td width='100px' align='center' ><a href=http://www.autismcommunitystore.com/item/$item/><img src=http://www.watchesandthings.com/autism/files/thumbnails/$location border=0 alt=$product_id></a></td><td><a href=http://www.autismcommunitystore.com/item/$item/>$title</a><br><span class=prod-dollar>$$price</span><br>$stockstatus</td></tr></table>"; } else { $printout="<table border=0 height=70 width=250><tr><td width='100px' align='center' ><a href=http://www.autismcommunitystore.com/item/$item/><img src=http://www.watchesandthings.com/autism/files/thumbnails/$location border=0 alt=$product_id></a></td><td><a href=http://www.autismcommunitystore.com/item/$item/>$title<br /><span class=prod-dollar>Click for Pricing</span></a><br>$stockstatus</td></tr></table>"; } if ($column=="1") { echo "<tr><td>$printout</td>"; // first column } else { echo "<td>$printout</td></tr>"; // 2nd column } // end of columns $count += 1; // this is a modulus operator it gets the remainder of the equation $column = $count % 2; } // end of while loop echo "</table>"; ; // Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM prods_to_cats WHERE category_id=$showcategory"),0); //$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM product"),0); // Figure out the total number of pages. Always round up using ceil() $total_pages = ceil($total_results / $max_results); echo "<p><center>Pages<br />"; // Build Previous Link if($page > 1){ $prev = ($page - 1); echo "<a href='http://www.watchesandthings.com/autism/view.php?category=$showcategory&page=$prev'><<Previous</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href='http://www.watchesandthings.com/autism/view.php?category=$showcategory&page=$i'>$i</a> "; } } // Build Next Link if($page < $total_pages){ $next = ($page + 1); echo "<a href='http://www.watchesandthings.com/autism/view.php?category=$showcategory&page=$next'>Next>></a>"; } echo "</center>"; }//end of else> echo "</table>"; echo "</div>"; ?>
  4. cssfreakie, Thank you again for all the useful comments. I actually did look a little bit at your blog site some the other night, and it is very useful and helpful. I have gone through and changed the width tag to 960 as you suggested, but to no avail. Quite honestly, this code is far, far above me - I am only a grade school student when it comes to CSS. I think this thing is just really, really imbedded - and since I am at such a low knowledge level, and I didn't do the coding to begin with, it has been very difficult for me to jump up at this level without going through the prelminary steps. Part of my frustration stems from the fact that when I do change a width value, and reload the page, then I don't see the change reflected there. Which makes it even more difficult for me to figure out what, exactly, I have changed. I just may need to look for some real assistance from someone more knowledgeable than me on this one, and continue my education at a basic level so that eventually I CAN modify this code and know what I'm doing..... Thank you again, I do appreciate all comments, and I will check out your firebug video.
  5. Hi cssfreakie, Thank you for the tips. I understand how the div percentage could make the space bigger - what I'm having trouble figuring out, with all these containers, is how to make the entire layout bigger. I've not heard of firebug before - it sounds like this is a program that would help me wade through all the muck, then? Also, why is it that the center tag is not recommended for use - does it have browser compatibility issues, or does it drag down the load time? I've never been told not to use this tag. I mostly use it in my paragraph tags, like <p align="center"> but the person who created this layout used the tag <center> a lot. Is there a difference in these two usages, or are both usages not recommended? I'm going to take a renewed effort at trying to figure this out right...NOW. If anyone else has anything helpful to add, please do! It is very much appreciated as I'm wading through code that is really just too far advanced for my knowledge level. *Hug to cssfreakie for taking the time to look at all this, and to help me some!*
  6. Hi Everyone, I am trying to widen the content area on an existing layout that is CSS based. While I did all the PHP & MySQL stuff for this web site, I have to admit that my CSS skills are sorely, sorely lacking. I have spent about an hour trying to figure out how to fix the CSS to do what I want. I did get the header image to a larger size, but I can't get the layout to expand to match it. I think the CSS tag that needs changed has something to do with either "bodyshell" or "bodycontent," but I've tried changing some of the values on the style sheet to no avail. Here's my test page, so you can see what it looks like now, and what I'm trying to do. What I want is a larger space where the item is displayed, so I can add some additional content. http://www.autismcommunitystore.com/itemtest.php?item=826 There are several CSS files being used, but I think a couple of them only do the navigation menus. I'll post what I believe is the main CSS file here, along with the code for the page. Let me know if something appears to be missing. At this point, I'm lost in a jungle. This is a little bit beyond my current skills, but seems like it might be something I'm just not getting. Absolutely ANY advice, help, or comment that might help me would be fantastic and highly, highly appreciated! Here's the CSS file (named autismstyle-alttest.css): a { color: #697345;/*#ff8c38;*/ /* color: */ } a:visited { text-decoration: none; color:#697345; /* color: #003366;*/ } a:link { text-decoration: none; } * { padding:0; /*margin:0;*/ } h1, h2, h3 { margin:0; } body { background:url('http://www.watchesandthings.com/autism/images/BackgroundMain.jpg') repeat-x top #fffff8; font:normal 12px "Trebuchet MS", arial, sans-serif; color: #46203C; text-align:center; width:100%; margin:0; /*margin: 5px; */ } a:hover { text-decoration: none; color: #87935c;/*#ff8c38;*/ /* color: */ } * html a:hover {text-decoration: none; color: #FFFFFF; background-color: #E3DFF3;}/* IE specific hack...color defines store cart and checkout out on IE ONLY */ a:active { text-decoration: none; color: #003366; } #container { z-index:0; margin:0 auto; text-align:left; width:900px; border:solid thin #8D9F4D; background: url(http://www.watchesandthings.com/autism/images/productbackground.jpg) repeat-y left #ffffff; /*http://www.watchesandthings.com/autism/*/ } #home_container { z-index:0; margin:0 auto; text-align:left; width:900px; border:solid thin #8D9F4D; background: url(http://www.watchesandthings.com/autism/images/homebackground.jpg) repeat-y left #ffffff; /*http://www.watchesandthings.com/autism/*/ } #graphicMenu { z-index:1; position: relative; margin:10px; height: 380px; width:525px; border:solid thin #8D9F4D; background: #ffffff; /*featured products loaded into this layer*/ } #featured { z-index:1; position: relative; margin:10px; height: 230px; width:525px; border:solid thin #8D9F4D; background: #ffffff; /*featured products loaded into this layer*/ } #featuredproduct h5 { padding-left: 30px; font-size: 12pt; font-weight: 700; } #featuredproduct h4 { padding-left: 20px; font-size: 9pt; font-weight: 900; } #featuredproduct a:hover { font-color: #8D9F4D;/*#ff8c38;*/ /* color: */ } #artdisplay { z-index:1; position: relative; margin:0 auto; height: 300px; width:500px; border:solid thin #8D9F4D; background: #ffffff; /*images of artshare show up here*/ overflow:scroll; } #thumbs { z-index:1; overflow:scroll; position: relative; margin:0 auto; height: 140px; width:500px; border:solid thin #8D9F4D; background: #ffffff; /*Thumbs of community section loaded into this layer*/ } #thumbRestrict { overflow:visible; position: relative; margin:0 auto; height: 110px; width: 500%; }/*this div restricts the thumbs so that it will scroll only horizontally*/ /*product dropped in to get items view on front page well */ #product h5 { padding-left: 30px; font-size: 12pt; font-weight: 700; } #product h4 { padding-left: 20px; font-size: 9pt; font-weight: 900; } #product a:hover { font-color: #8D9F4D;/*#ff8c38;*/ /* color: */ } .prod-id { margin: 0; font-size: 9pt; } .prod-title { font-color: #50592D; font-size: 13pt; font-weight: 700; } .prod-price { font-size: 12pt; } .prod-dollar { font-color: #FF0033; font-size: 12pt; } } /* unedit import from Dano's sheet----------*/ /* Classes */ .breadcrumbs{ margin-top: 10px; margin-left: 30px; padding-bottom: 10px; color: #332d72; z-index: 10; } .breadcrumbs a { color: #332d72; } /*new breadcrumbs---------------------------------------------*/ #other-categories{ position:absolute; clear:both; width:205px; left:330px; top:50px; border:solid thin #8D9F4D; padding:10px 10px 10px 10px; } #other-categories h3{ font-size:1.2em; font-weight:700; } /*End new breadcrumbs---------------------------------------------*/ .clear { clear:both; display:block; font-size:1px; height:1px; line-height:-1; } .last { border:0 solid; } input.buttonsubmit { margin-left:4px !important; text-transform:uppercase; } /* IDs */ #bodycontent { float:right; width:545px; background: none; } *html #bodycontent { height: auto !important; height: 400px; min-height: 600px; } /* 150 + 610 = 760 original value */ /* 215 + 545 = 760 changed value to support wider menu*/ #bodyshell { z-index: 5; border-left:150px solid transparent; float:left; zoom:1; margin:0; } #bodyshell:after { clear:both; content:"."; display:block; height:0; visibility: hidden; } *:first-child+html #bodyshell { width:610px; } #brandmark { float: left; font: normal 26px Tahoma, Geneva, Verdana, sans-serif; width:500px; margin-top:10px; } /* 510 + 250 = 760 */ #brandmark a { color:#8895b8; display:block; padding:6px 0 5px 13px; text-decoration:none; } #captionarea, #info-div { /*margin:0px 0px 0px;*/ position:relative; top: -15px; left: 10px; width: 85%; background: transparent; /*border-bottom:1px #fff solid;*/ }/* 1px is used to prevent Margin Folding */ #messagearea { position:relative; top: -20px; background: transparent; padding-top:10px; } #itemtype #contentarea #captiontitle {margin:15px 0 10px; padding:0 2px;} #itemtype #captiontitle {background:none; color:#000000; font:bold 14px Tahoma, Geneva, Verdana, sans-serif; margin:0; padding:2px 2px 8px;} /*The Left/Right Padding is smaller because the Caption Title needs to be nested within the Caption on Item pages, but not on Section pages */ #contentarea {margin: 0 15px 10px;} #bodyContent { background-color:#697345; color:#ffffff; font:bold 14px Tahoma, Geneva, Verdana, sans-serif; margin:0; padding:4px 15px 6px; } /* ----------------------= footer -------------------------------- */ #copyright {background:transparent; color:#ffffff; display:block; font:normal xx-small/1.2 verdana, sans-serif; text-align:center;} #finaltext, #introtext {margin:10px;background: none;} #footer { background: #857CB7 url('http://www.watchesandthings.com/autism/images/footer_tile2.gif') repeat-y; height:65px; clear:both; zoom:1; width: 900px; border:solid thin #8D9F4D; border-top:none; } #footer-links { background:transparent; color:#ffffff; display:block; font-weight: 300; font-size:11px; padding:15px 0 15px; text-align:center; } #footer-links a { background:transparent; color:#ffffff; text-decoration:none; } #footer-links a:hover { background:transparent; padding-bottom: 1px; border-bottom: 1px solid #ffffff; } /* -----------------------end footer------------------------*/ /* ----------------------= header -------------------------*/ #header { background: url(http://www.watchesandthings.com/autism/images/acs_logotest.jpg) no-repeat #9392b4 -1px 0px; height: 215px; color: fff; } #logo { position: absolute; top: 0 px; left: auto; z-index: 1; /**/ } #header a { padding-top: 10px; } /* upper navigation ba */ #nav-general { position:relative; top:-2px; clear:both; float:right; display:block; list-style:none; margin:0 5px 0 0; color: #50592D; } #nav-general li { background: none; border:1px solid #ffffff; border-top:0; float:left; margin:0 2px; } /* General Link Colors */ #nav-general li a { color: #ffffff; display:block; font-size:10px; font-weight:bold; padding:4px 20px 6px; text-align:center; text-decoration:none; white-space:nowrap; } #nav-general li a:hover { background:transparent; background: url('http://www.bowleswatch.com/acs/66_per_background.png') repeat; color: #50592D; } /* */ /*#nav-product { _display:inline; float:left; margin-left:-150px; overflow:hidden; position:relative; width:150px; z-index:100; min-height: 550px; height: auto !important; height: 400px; background: url(http://www.bowleswatch.com/acs/66_per_background.png) repeat; }*/ /* IE Experiences the pixel doubling bug here. "display: inline;" fixes this. Position Relative and Z-Index are needed for IE in order to display the background colors */ /*#nav-product ul li a { border-bottom: 2px solid #ffffff; color:#332d72; display:block; font-weight:bold; font-size:11px; height:auto; margin:0; min-height:16px; padding:5px 10px 6px 10px; text-decoration: none; width:130px; }*/ /*#nav-product ul li a:hover { background-color: #ffffff; color:#332d72; }*/ /*#nav-product li { margin:0; }*/ /*#nav-product ul { list-style:/*url(http://us.st11.yimg.com/us.st.yimg.com/I/yhst-11545486226283_1937_535304) 0 0;} */ #htmltop, #htmlbottom{ padding:5px; } * html #nav-product ul li a{ width:123px; height:auto; overflow:hidden; } * html #nav-product ul li a:hover{ width:123px; } * html #nav-product { overflow:visible; width:150px; } /* ----------------------------= search area styles ------------------------------- */ #searcharea { position: relative; margin-top: 0; /* fixes IE bug */ /* position: absolute; z-index: 100; left: 300px; top: 300px;*/ } #searcharea input { /* Go button*/ background: #C8D791; color: #50592D; font-size:11px; font-weight: 100; margin:0 0 0 5px; border: solid 1px #50592D; position:relative; } #searcharea fieldset { background: url('http://www.watchesandthings.com/autism/images/searchTile.gif') repeat-x; display:block; border: 0px; width: 770px; height: 20px; margin: 0 0 0 0; padding: 3px 10px 3px 10px; } #searcharea label { color:#f2eff6; font-size:10px; font-weight:600; } #searchsubmit { border:solid 1px #fff; margin:1px 0px 2px 5px; padding: 0px 2px 2px 1px; background: #ffffff url('') repeat-x; color:#fff; font:11px Arial,verdana,sans-serif; text-align: center; cursor: pointer; height: 17px; } *html #searchsubmit{ padding:1px 2px 1px; } #searchpageHeader { background-color:#eba755; color:#ffffff; font:300 14px Tahoma, Geneva, Verdana, sans-serif; margin:0; padding:3px 15px 4px; } input#query { margin-top: 2px; margin-left:4px; padding:1px; background-color:#fff; color:#000; } #query {padding:1px;} /* -----------------------------= end search styles -------------------------------*/ #slogan {color:#50592D; display:block; float:right; font:normal 11px Tahoma, Geneva, Verdana, sans-serif; padding:2.7em 15px 10px 10px; width:225px; text-align:right;} /* 225 + 25= 250 */ *:first-child+html #info-div, *:first-child+html #specialtitle, *:first-child+html #messagearea { width:550px; } *:first-child+html #itemarea { width:570px; } #badge { margin: 0 auto; } * html #badge { width:136px; text-align:center; } /* ------this is all Dano's code up to here--------------------*/ /*---------------------changes up to here---------------------*/ #search {position: relative; margin-top: -15px; height: 20px; } .newlink:hover { background-color: #F3F8FD; } /*---------------------------=content---------------------------------------*/ #content { margin-left : 12em; } /*-----------------------------=menu styles begin here-------------------*/ #prodlist { _display:inline; float:left; margin-left:-150px; /* position:relative;*/ /* position: absolute; top: 2px; left: 100px;*/ width:215px; z-index:50; min-height: 550px; height: auto !important; height: 400px; background: url(http://www.watchesandthings.com/autism/images/66_per_background.png) repeat; } * html #prodlist {position: absolute; !important; left: -1em; background: none;} /* IE specific hack...positions menu to the left*/ #menu {position: relative; list-style-type:none; margin:0; padding:0; width:215px; z-index:10 /*keep menu's on top in IE and other browsers*/ } #menu li {padding:0.25em 0 0.25em 0.25em; ; margin:0; position:relative; width:220px; height: 1.7em; z-index:10;} #menu li dl {position:relative; top:0; left:0; padding-bottom:0;} #menu li a, #menu li a:visited {text-decoration:none; font-weight: 900;} #menu li dd {display:none; } #menu table {border-collapse:collapse; padding:0; margin:-1px; font-size:1em;} #menu dl {width: 220px; margin: 0; padding: 0; background: transparent; } #menu dt {margin:0; padding: 0; font-size: 1.17em; line-height: 1em; white-space: nowrap;} #menu dd {margin:0; padding:0; color: #fff; text-align:left; float:right;} #menu dt a, #menu dt a:visited {display:block; font-size: 1em; color: #50592D; text-align: left; background-color : none; padding:0.25em 0 0.25em 0.25em;} #menu li a:hover {border:0; } #menu li:hover dd, #menu li a:hover dd {display:block;} #menu li:hover dl, #menu li a:hover dl {width:500px;} #menu li:hover dt a, #menu a:hover dt a {background-color: #F1EFFA;/* rgb(251,248,239);*//*#FBF8EE;*/ /*#E3DFF3*/ color: #50592D; border:1px solid #50592D;} * html #menu li:hover dt a, #menu a:hover dt a {background-color: #E3DFF3 ; color: #50592D; border:1px solid #50592D; } /* IE specific hack...only difference is in the backgrnd-color */ #menu dd a, #menu dd a:visited {background-color: #E3DFF3; color: #50592D; padding:0.3em 0; text-decoration:none; display:block; text-align:center; border-left:1px solid #50592D; border-right:1px solid #50592D; border-bottom:1px solid #50592D; width:298px;} #menu dd a:hover {background-color: #F1EFFA;/*#E8D591*/; color:#50592D; border-left:1px solid #50592D; border-right:1px solid #50592D; border-bottom:1px solid #50592D;} #menu b {display:block; overflow:hidden;} /*---------------------------=menu styles end here------------------------*/ #store-info { padding-left: 20px; } /*---------------------------=store footer styles----------------------------*/ Now, here is the web page code: <? include 'connect.php'; $item=$_REQUEST['item']; $result = mysql_query("SELECT * FROM product WHERE id=$item", $dbh); $myrow = mysql_fetch_array($result); $titlekey=$myrow["title"]; header("Content-type: text/html; charset=utf-8"); ?> <!DOCTYPE HTML SYSTEM "http://www.watchesandthings.com/validator/HTML4plus.dtd"> <html> <head> <!--need to update the style shee so that autismstyle-alt can be first--> <link rel="stylesheet" type="text/css" href="http://www.watchesandthings.com/autism/css/autismstyle-alttest.css"> <link rel="stylesheet" type="text/css" href="http://www.watchesandthings.com/autism/css/autismstyle-sub.css"> <link rel="stylesheet" type="text/css" href="http://www.watchesandthings.com/autism/css/autism-sub.css"> <!--[if lte IE 6]> <link rel="stylesheet" type="text/css" href="http://www.watchesandthings.com/autism/css/autismstyle-sub-ie6.css"> <![endif]--> <title><? echo $titlekey; ?></title> </head> <body id="maintype"> <div id="container"> <? include 'headertest2.php'; ?> <div id="bodyshell"> <? include 'navtest2.php'; ?> <div id="bodycontent"> <div id="messagearea"> <div> <table width="450" border="0" cellspacing="0" cellpadding="0" style="font-size:1.1em; line-height: 20px; font-style: italic;"> <? include 'itemsourcetest.php'; //</table> don't add this back in w/out changing item-source.php or the layout will break ?> </div> </div> <br clear="all" /> <? include 'bottomtest2.php'; ?> Thank you so very much for taking the time to read my post, and maybe help me out a little!
  7. Thank you both for your help. samshel, you are correct - it doesn't make sure to use base64_decode if it wasn't inserted that way. I don't actually see any reason to encode the images at all. So I changed the code on my getimage.php using both of your suggestions, but I still don't get the image. Any other thoughts on what I've been doing wrong? I got this code from different tutorials, but none of the tutorials have explained in enough detail for me to really "get" this, so I'm still kind of muddling through this. here is the new code I tried on getimage.php: <? $id=$_GET["id"]; $result = mysql_query("select image from featured_prods where id='$id'"); $row = mysql_fetch_row($result); //$data = base64_decode($row[0]); $data=$row[0]; $im = imagecreatefromstring($row[0]); imagejpeg($im); header('Content-Type: image/jpeg'); // 'image/jpeg' for JPEG images echo $data; ?>
  8. Hi everyone, I've read lots of tutorials on this, but something is not clicking in my brain with it. I think my coding is close, but, as of right now, all I get is a red x for the image when I try to display the image. Let me share my code as a starting point - I would truly appreciate any helpful comments or blatant errors that are pointed out or shared with me. Here is the upload image form and code (so they clicked the item name and then go into this): if($_REQUEST['modifyfeatured']) { $id=$_REQUEST['modid']; $sqlid="SELECT * FROM product WHERE id='$id'"; $resultid=mysql_query($sqlid, $dbh); $idrow = mysql_fetch_array($resultid); echo "<p>"; echo "Fill out the form below to add a short text line (i.e. 20% Off!) and/or an image (like the new note).<br>"; echo "You are modifying the following item: <p><b>"; echo $idrow['product_id']; echo " "; echo $idrow['title']; echo "</b><p>"; ?> <table border="0" cellpadding="2" cellspacing="0"> <tr> <td> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="id" value="<? echo $id; ?>"> Short Text Message: </td><td> <input type="Text" name="message"></td></tr> <tr><td>Small Image:</td><td> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input name="userfile" type="file" id="userfile"></td></tr> <tr><td> </td><td> <input name="upload" type="submit" class="box" id="upload" value="Submit"> </td></tr></table> </form> <? } //then when the click the upload link, here is the code for that: if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $message=$_REQUEST['message']; $id=$_REQUEST['id']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } include 'library/config.php'; include 'library/opendb.php'; //$query = "INSERT INTO featured_prods (name, size, type, image, message ) ". //"VALUES ('$fileName', '$fileSize', '$fileType', '$content', '$message')"; $query="UPDATE featured_prods SET name='$fileName', size='$fileSize', type='$fileType', image='$content', message='$message' WHERE id='$id'"; //$sqldone="UPDATE product SET product_id='$product_id', title='$title', description='$description', regular_price='$regular_price', sale_price='$sale_price', stat='$stat', weight='$weight', close_out='$close', additional='$additional', additionalpix='$additionalpix_name' WHERE id='$id'"; //$resultdone=mysql_query($sqldone, $dbh); mysql_query($query) or die('Error, query failed'); include 'library/closedb.php'; echo "<br>File $fileName uploaded<br>"; } //end if upload is hit Okay, now here is the code trying to display the image: <? $featuredquery="SELECT * FROM featured_prods"; $featuredresult=mysql_query($featuredquery, $dbh); while($featuredrow=mysql_fetch_array($featuredresult)){ $id=$featuredrow['id']; $prodquery="SELECT * FROM product WHERE id='$id'"; $prodresult=mysql_query($prodquery, $dbh); $prodrow=mysql_fetch_array($prodresult); echo $prodrow['title']; echo "<br>"; echo $featuredrow['message']; echo "<br>"; ?> <img src="getimage.php?id=<?echo $id;?>" alt="cover" /> <? } And here is the code for getimage.php: <? $id=$_GET["id"]; $result = mysql_query("select image from featured_prods where id='$id'"); $row = mysql_fetch_row($result); $data = base64_decode($row[0]); $im = imagecreatefromstring($row[0]); imagejpeg($im); header('Content-type: ' . image/jpeg); // 'image/jpeg' for JPEG images echo $data; ?> Again, any help would be appreciated. I'm a real rookie here, and I appreciate everyone's time and effort to assist me very much.
  9. On php.net, someone said they added the following to their code: ini_set('sendmail_from', 'me@domain.com'); mail($to $subject, $body); I do remember setting something up on my server, but it's been years since I originally coded my email scripts, and I just don't remember what else I set up.
  10. Hi, Looks like you are missing a comma here, which I think might make a difference: mail($to, $subject, $body);
  11. Hi everyone, I'm trying to keep this so basic, and for some reason it's not working. (Okay, yes, we all know that it's not "some" reason - but really because sailorsmokey is not understanding the tutorials or the code she is trying to write.) All I want is the image from the HTML form to be loaded onto a directory on the site. Yes, I have changed permission on the directory to 777. I'm sure the problem is in the code I am trying to understand and duplicate from tutorials online. So, without being too brutal, could someone point out what I'm doing wrong? Here's the form code: <table border="0"> <form enctype="multipart/form-data" method="post" action="completemodify.php" > <tr><td valign="top"> UNDER CONSTRUCTION - NOT WORKING YET Additional Info Image (if you have one):</td><td colspan="2"> <input type="file" name="additionalpix" size="30" /> <tr colspan="2"> <input type="Submit" name="completemodify" value="Make the Above Changes"> </tr> </td></tr></table> Here's the processing code: <? $additionalpix=$_FILES['additionalpix']['tmp_name']; $additionalpix_name=$_FILES['additionalpix']['name']; $directory_addself=str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']); $adduploads_directory=$_SERVER['DOCUMENT_ROOT'] . $directory_addself . 'autism/additionalpix/'; $fieldname= 'additionalpix'; $adduploadfilename=$adduploads_directory.$_FILES[$fieldname]['name']; @move_uploaded_file($_FILES[$fieldname]['tmp_name'], $adduploadFilename); PS - Oh yes, just reading this it doesn't make sense to me. Again, I'm pretty sure I'm not understanding something key here. Any help/pointers/advice anyone could give would really give me something to go on here. Thank you in advance.
  12. This question is kind of vague, but wondering if anyone has experienced anything like this, or has any input of any kind (which would all be appreciated!!!). I have an HTML form I built to insert products into a MySQL database. It's all really very simple and basic. This script has been running fine (as far as I know) for about 2 years. However, today, one person who uses the form turned in a complaint to me on it. She said that "every once in a while, products stop going onto the site. Instead of the product I am trying to put on, it lists the last product I put on into the category I am trying to put the new one into." It seems as if somehow it sees old cached information in her form, and doesn't see the new product info she adds. However, it does see the new category she selects in the form, and adds the previous product to that category. It did this 4 times today with her, continuely adding the previous product instead of the new one she tried to enter. When I tried to add some test products, I had no problem whatsoever. Also, as I said, this script has been running for a while without problem. I know this is a vague description, but being as I can't get the symptoms to repeat, I have no idea where to start treatment. Again, I was hoping someone had experienced something similar, or had some ideas of things I needed to check out. Vague responses are okay (since I was vague myself....). Anything to start me going with ideas would be wonderful!!
  13. I think that function_to_write thing is part of the GD library, but I'm having trouble piecing this whole thing together. Here's a tutorial I found on resizing thumbnails with the GD library that uses function_to_write: http://www.sitepoint.com/article/php-gallery-system-minutes/5/ If anyone has any further input on this, I'd love to fix what I already have, but if no one has any other suggestions, I will go with Michael's suggestion of using imagejpeg(). I was just hoping not to have to start over, but again, will do what I have to. Thank you!
  14. No, I didn't have the function error_reporting(E_ALL) on, but I just turned it on and ran it. Again, no error pops up. And I thought I had the $function_to_write set up correctly, but by your above post, I get the hint that I don't, but I don't know what I did wrong. I have some examples in other areas of the Web site, and it looks correct compared to them. If you're feeling generous out there, pass me another hint, and I'll keep digging on this. Thanks!
  15. It has been approximately 5 years since I've last even looked at GD library scripts. And I don't remember them - at all. I've got this code going, but I can't figure out why it won't copy the image into the correct folder. I'm going to include the section where it's copying the image - maybe someone will see something in there. And if that all checks out, then I guess I'll keep searching the rest of the code for something that's out of place. Absolutely no errors pop up when I run this code. The folder has 777 permissions. But after I run the code, no image appears in the "additionalpix" folder. $dest="/PrivateInfo/additionalpix/$additionalpix_name"; $size = GetImageSize($additionalpix); $image_types = array( 'image/pjpeg' => '.jpg', 'image/jpeg' => '.jpg', 'image/jpg' => '.jpg', 'image/gif' => '.gif', ); $filetype = $_FILES['additionalpix']['type']; $extension = $image_types[$filetype]; //define size based on tall or wide // Wide Image if($size[0] > $size[1]) { if ($size[0]>250){//only modify it if it's larger $image_width = 250; $image_height = (int)(250 * $size[1] / $size[0]); }else{ $image_width = $size[0]; $image_height = $size[1]; } } // Tall Image else { if($size[1]>175){ $image_width = (int)(175 * $size[0] / $size[1]); $image_height = 175; }else{ $image_width = $size[0]; $image_height = $size[1]; } } $gd_function_suffix = array( '.jpg' => 'JPEG', '.gif' => 'GIF', ); $function_suffix = $gd_function_suffix[$extension]; $function_to_read = 'ImageCreateFrom'.$function_suffix; $function_to_write = 'Image' . $function_suffix; // Read the source file $source_handle = $function_to_read($additionalpix); if ($source_handle) { // Let's create a blank image $destination_handle = ImageCreateTrueColor($image_width, $image_height); // Now we resize it ImageCopyResampled($destination_handle, $source_handle, 0, 0, 0, 0, $image_width, $image_height, $size[0], $size[1]); } // Let's save $function_to_write($destination_handle, $dest);
  16. Thank you so much for not telling me to leave my head in the sand. I really appreciate it. This did work, and meanwhile, I will continue to study up and get my head back in the game.
  17. Now I feel a little ridiculous. I used to be pretty handy with this PHP stuff, and I haven't touched it for a while, so I'm obviously quite a bit rusty. $valid_date is a value from MySQL table, stored as YYYY-MM-DD, and in this case it is 2009-05-01. $exp_date is the same, and in this case it is 2009-12-31. Any other comments that could help me out would be appreciated - meanwhile, I'll start reading up on date() and var_dump() a bit.
  18. Hi everyone! I know my logic must be faulty somewhere here, because this if/else statement isn't returning the correct result. Could someone either correct me or at least give me enough direction to find my own mistake? I'm trying to take the current date, and check to see if it within the range of the date it becomes valid, and the expiration date. I thought this would be simple, and it probably is, but I'm missing something. Here's what I've got: $today=getdate(); if($today<$valid_date or $today>$exp_date) { echo "<p>Coupon has expired - discount not included in total.<br />"; }
  19. Does anyone have any ideas on this? I'm really stuck here. Any ideas would really, really be appreciated.
  20. Hi everyone. I'm a bit of a rookie, here. I have used ReWrite rules with my Web site successfully. However, I've started a second Web site that, until it grows, it residing in a subdirectory on my 1st Web site. The 2nd Web site has its own domain name pointed to that subdirectory (so www.autismcommunitystore.com points to www.watchesandthings.com/autism/). I initially set up a .htaccess file to work with the subdirectory. Now I want to get it so it works with the pointer domain (I want my links to be www.autismcommunitystore.com/view/17/ rather than www.watchesandthings.com/autism/view/17/). I've done some additional reading on the ReWrite rule, but I either don't understand what I'm reading, or haven't seen the answer to my question. Here's how my rewrite rule is set up: RewriteEngine on Options +FollowSymlinks RewriteBase /autism/ RewriteRule ^\.htaccess$ - [F] RewriteRule ^item/([0-9]+)$ item/$1/ [R] RewriteRule ^item/([0-9]+)/$ item.php?item=$1 RewriteRule ^view/([0-9]+)$ view/$1/ [R] RewriteRule ^view/([0-9]+)/$ view.php?category=$1 RewriteRule ^view/([0-9]+)/([0-9]+)$ view/$1/$2/ [R] RewriteRule ^view/([0-9]+)/([0-9]+)/$ view.php?page=$1&category=$2 RewriteRule ^viewsubcategory/([0-9]+)$ viewsubcategory/$1/ [R] RewriteRule ^viewsubcategory/([0-9]+)/$ viewsubcategory.php?subcategory=$1 RewriteRule ^viewsubcategory/([0-9]+)/([0-9]+)$ viewsubcategory/$1/$2/ [R] RewriteRule ^viewsubcategory/([0-9]+)/([0-9]+)/$ viewsubcategory.php?page=$1&subcategory=$2 RewriteRule ^viewsubcategory2nd/([0-9]+)$ viewsubcategory2nd/$1/ [R] RewriteRule ^viewsubcategory2nd/([0-9]+)/$ viewsubcategory2nd.php?category2nd=$1 RewriteRule ^viewsubcategory2nd/([0-9]+)/([0-9]+)$ viewsubcategory2nd/$1/$2/ [R] RewriteRule ^viewsubcategory2nd/([0-9]+)/([0-9]+)/$ viewsubcategory2nd.php?page=$1&category2nd=$2 RewriteRule ^/autism/feedback/([0-9]+)$ /autism/feedback/$1/ [R] RewriteRule ^/autism/feedback/([0-9]+)/$ /autism/feedback.php?page=$1 I tried a few logical guesses on how to make this work, but to no avail. Can anyone lead me to or show me how to get what I want? Of course, I am assuming that I can do this. Will the rewrite engine even work with a pointer domain? Thank you for helping me out.....I truly appreciate it!
  21. Barand, Thank you so much.  Changing the query really worked.  I believe you have helped me before on joins almost two years ago.  You've made my life a lot easier.  =) Does anyone have any links they might suggest regarding join statements?  I have looked at them on the Web quite a few times, but I have not found a "join statements for dummies" kind of explanation that I need.  I always seem to get confused by the descriptions I find.  So if anyone has any good suggestions, please let me know.  I would love to find something that has a good reference page that I could print out and study so I can understand this better. Thanks, Sarah
  22. Thanks for the idea, but this if the very first route I took one week ago.  It doesn't work because the query in the outer while loop simply checks to see if there are items in that category.  Then it moves to the inner while loop and checks to see if the item is a close out or not.  So I need to inner query in order to know if there will be results. I've tried using mysql_num_rows() inside the inner while loop, but that won't work because as it loops through each item, maybe the first two results are close outs, so they will display, but then the third item isn't, so it will exit the program and I won't get the other 30 items. So using the $count variable was my next idea which is acting really weird.  Again, for some reason, my final if clause is affecting what $count is equal to, but I can't see why. Any other ideas??
  23. Hi all, I have racked my brain over this for a week.  Let me start by showing my code: ______________________________________________________________ $count=1; //search for cat results only $querycategory="SELECT * FROM prods_to_cats WHERE category_id='$cat'"; $categoryresult=mysql_query($querycategory, $dbh); while ($categoryrow= mysql_fetch_array($categoryresult)) { $itemid=$categoryrow['id']; $querycat="SELECT * FROM product WHERE id='$itemid' AND close_out='1' ORDER BY product_id ASC"; $catresult = mysql_query($querycat, $dbh); // now you can display the results returned   while ($row= mysql_fetch_array($catresult)) {   $title = $row["product_id"];   $item = $row["id"];   $image = $row["image"];   $descrip = $row["title"];   $stockstatus = $row["stat"];   $msrp = $row["regular_price"];   $close = $row["close_out"];   if($stockstatus=='IN STOCK') { $stockstatus="<font color=#009933>IN STOCK</font>"; } else { $stockstatus="<font color=#FF0000>OUT OF STOCK</font>"; } if($close=='1') { $gooddeal="<font color=#FF0000><b>CLOSE OUT!!</b></font>"; } else { $gooddeal=""; }   echo "$count.)&nbsp;<table border=0><tr><td><a href='http://www.watchesandthings.com/files/$image'><img src='http://www.watchesandthings.com/files/thumbnails/$image' width=70 height=100 border=0></a></td><td><b>$title</b>  $descrip<br>MSRP $$msrp<br>$stockstatus    $gooddeal</td></tr></table>" ; ?> <br> <?   $count++ ;   echo $count;   }  //end of embedded while   if($count<2){   echo $count;   exit("<p>I'm sorry, your search returned zero (0) results.");   } }    //end of outer while _________________________________________________________________ Here's what's happening.  The search has been working great, but for the past week I've been trying to display a message when there are no results (or no items in that category that are also close-outs).  So I was staring at the code today, and I thought, why not use the $count variable?  This is working great except for when there is only one result to the search.  If I comment out the if statement at the bottom with the exit() function, and echo $count, and run the search on a query I know results in only one item, I will see that $count=2.  So my if statement SHOULD  work because $count is NOT less than two, so the script will not exit. So then I will un-comment that bottom if statement, still echoing count.  And when I run the query again, I will see that $count is not equal to 1, and then it displays the exit message.  Why would that if statement affect what $count equals.  $count has a value that is set in it's own while loop - I don't see any way it could affect it. Or maybe there is a better way for me to code this?  Please help me fellas (and gals)!  I've spent many hours torturing myself over this..... :(
×
×
  • 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.