Jump to content

HDFilmMaker2112

Members
  • Posts

    547
  • Joined

  • Last visited

    Never

Everything posted by HDFilmMaker2112

  1. Looks like you have extra closing brackets for an if/elseif/else statement somewhere.... Can't really help without seeing code.
  2. $product_id=$_GET['product']; $sql500="SELECT * FROM $tbl_name3 WHERE product_id='$product_id'"; $result500=mysql_query($sql500); $num_rows500=mysql_num_rows($result500); while($row500=mysql_fetch_array($result500)){ extract($row500); $review_product_rating_total=$review_product_rating; //What do I do here? } $average_rating=$review_product_rating_total/$num_rows500; I need a way to take a column of product ratings (0-5 in 1/2 increments), add them together, and divide by the number of rows taken from the database. I know how to get the number of rows with mysql_num_rows. But how would I add together the data from database?
  3. Need to see your connection to the DB and DB Select statement.
  4. Works perfectly, thanks a ton. Never used JOIN before, definitely helps to see in application that I'm actually working on to understand how it works.
  5. Just finished a search script. However, when type two keywords it will return duplicate entries: elseif(isset($_GET['search'])){ $search=$_POST['search']; $search=str_replace(" ", ".", $search); header("Location: ./index.php?q=".$search); } elseif(isset($_GET['q'])){ $search=$_GET['q']; $keywords=explode(".",$search); $sql10000="SELECT product_id FROM $tbl_name2 WHERE keyword LIKE '%" . implode("%' OR keyword LIKE '%",$keywords) . "%'"; $result10000=mysql_query($sql10000); if(mysql_num_rows($result10000)==0){ $content='<div class="center">Search found no results.</div>'; } else{ while($row10000=mysql_fetch_array($result10000)){ $product_id3=$row10000['product_id']; $sql15000="SELECT * FROM $tbl_name WHERE product_id=".$product_id3; $result15000=mysql_query($sql15000); while($row15000=mysql_fetch_array($result15000)){ extract($row15000); $content.=$product_name; } } } } I have 3 products: Test2 - microphone Test3 - audio, microphone Test123 - audio When you search "audio" you get: Test3, Test123 When you search "microphone" you get: Test2, Test3 When you search "audio microphone" you get: Test2, Test3, Test3, Test123 with Test3 being a duplicate. Is there anyway to correct this? I tried SELECT DISTINCT * FROM, but there's no difference in the results returned, from what I have now.
  6. Nope, that would be way, the first query is what actually does the search look-up so.... Moved it outside the first while and working perfectly now. Thanks.
  7. Well turned on error reporting and all I'm getting is notices that I have an Undefined Index and that the Content variable is undefined (because it's being called but nothing's a signed to it, for whatever reason. The page is actually displayed properly when the keyword exists, just when there are no results returned does it not show anything.
  8. That's what I figured... was just to lazy to change it to try it myself. EDIT: Just tried it, still a blank page. while($row10000=mysql_fetch_array($result10000)){ $product_id3=$row10000['product_id']; $sql15000="SELECT * FROM $tbl_name WHERE product_id=".$product_id3; $result15000=mysql_query($sql15000); if(mysql_num_rows($result15000)==0){ $content='<div class="center">Search found no results.</div>'; } else{ while($row15000=mysql_fetch_array($result15000)){ extract($row15000); $content.=$product_name; } } }
  9. while($row10000=mysql_fetch_array($result10000)){ $product_id3=$row10000['product_id']; $sql15000="SELECT * FROM $tbl_name WHERE product_id=".$product_id3; $result15000=mysql_query($sql15000); while($row15000=mysql_fetch_array($result15000)){ extract($row15000); if(mysql_num_rows($result15000)==0){ $content='<div class="center">Search found no results.</div>'; } else{ $content.=$product_name; } } } The above does not display the $content variable when there are no rows returned, just comes up with a blank page. Works fine when there are results returned.
  10. Well, anyway I changed it to "." Working now. Thanks for the help. Curious to know how Google, Bing, and a lot of other major retailers manage to use "+" in their search queries to hold together the string.
  11. The reason I was trying to use "+" is because I see it all the time in search engine URLs, and a lot of other stores.
  12. tried this and get the '%test test2 %' problem as well. The URL of the page has q=test+test2. Meaning it should be pulled into the explode and be placed into an array of $keywords("test","test2")... if I'm not mistaken. echo '<pre>' . print_r($keywords,true) . '</pre>'; That returns: Array ( [0] => test test2 ) On my computer running Windows XP with FireFox on my windows 7 comp with FireFox it returns something different (weird since the computer shouldn't be doing any processing): Array ( [0] => test )
  13. Alright, that got rid of the "Array" and placed it with the data, but it's now come up as '%test test2%'... Don't get why, I've had this problem all day with it not add the closing % after test with the closing single quote and then opening % and single quote for test2.
  14. elseif(isset($_GET['search'])){ $search=$_POST['search']; $search=str_replace(" ", "+", $search); header("Location: ./index.php?q=".$search); } elseif(isset($_GET['q'])){ $search=$_GET['q']; $keywords=explode("+",$search); $sql10000="SELECT product_id FROM $tbl_name2 WHERE "; while($query10000=each($keywords)){ $sql10000.="keyword LIKE '%".$query10000."%' OR"; } $sql10000=substr($sql10000,0,(strLen($sql10000)-3)); $content=$sql10000; That is returning this: SELECT product_id FROM keywords WHERE keyword LIKE %Array% For some reason it's showing "Array", it should be looping through the keywords array.
  15. You have a bit of a security hole by doing that... If the actual user steps away from their computer, and somebody else comes along, they can click into the admin panel then without need to validate they are indeed that person.
  16. Create another form with separate SESSION variable, and populate the Username field (if there is one) with the Username set from the original form. So all they need to do is re-type in their password. That's what most sites do when you go in to edit account settings. And then you can kill the second session when they log-out of the admin panel, but they stay logged in to general area.
  17. Thanks I did not know such a simple function existed. This was exactly what I was looking for. -mme Neither did I. Much simpler than my method.
  18. $strings=explode("&","string here") Gets you: $strings array("api=somerandomkey", "user=someuser", "ect.") foreach($strings as $string){ $string=explode("=",$string); } $string array("api","somerandomkey", "user", "someuser", "ect.") $string[0]=$string[1]; $string[0] could also be $string["api"]
  19. The below is returning: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/zyquo/public_html/ghosthuntersportal.com/pages.php on line 39 Line 39 is, while($row10000=mysql_fetch_array($result10000)){ elseif(isset($_GET['q'])){ $search=$_GET['q']; $keyword=explode("+",$search); $keywords=implode(",",$keyword); $sql10000="SELECT product_id FROM $tbl_name2 WHERE keyword IN($keywords)"; $result10000=mysql_query($sql10000); while($row10000=mysql_fetch_array($result10000)){ $product_id3=$row10000['product_id']; $sql15000="SELECT * FROM $tbl_name WHERE product_id=".$product_id3; $result15000=mysql_query($sql15000); while($row15000=mysql_fetch_array($result15000)){ extract($row1500); $content=$product_id; } } }
  20. alright, just making sure I'm on the right track here: elseif(isset($_GET['search'])){ $search=$_GET['search']; $keyword=explode(" ",$search); $keywords=implode(",",$keyword); $sql10000="SELECT product_id FROM $tbl_name2 WHERE keyword IN($keywords)"; $result10000=mysql($sql10000); while($row10000=mysql_fetch_array($result10000)){ $product_id3=$row10000['product_id']; $sql15000="SELECT * FROM $tbl_name WHERE product_id=".$product_id3; mysql($sql15000); } }
  21. I'm looking to know the best way to process a search query that has multiple words in the search: elseif(isset($_GET['search'])){ $search=$_GET['search']; $keyword=explode(" ",$search); //database query } Should I do a while loop query the database for each keyword?
  22. Never mind... <a href="./admincp.php?do=delete&id='.$product_id.'">Delete Product</a> should have been: <a href="./product_process.php?do=delete&id='.$product_id.'">Delete Product</a> Basically I was trying to process the product_id with the wrong file. Too early to be coding...
  23. I'm trying to pass a product_id through a URL, to delete the product from the database: <a href="./admincp.php?do=delete&id='.$product_id.'">Delete Product</a> My issue is the code below is not getting the product_id from the URL. elseif($_GET['do']=="delete"){ if(isset($_GET['id'])){ $product_id=$_GET['id']; $sql5000="DELETE FROM $tbl_name WHERE product_id=".$product_id.""; mysql_query($sql5000); $sql5500="DELETE FROM $tbl_name2 WHERE product_id=".$product_id.""; mysql_query($sql5500); header("Location: ./admincp.php?deleted=yes"); } }
  24. Alright, the only thing I can think of is concatenate the $cart variable at the beginning of the script and see what happens. $cart .= $_SESSION['cart']; It seems like since you're getting session data into $cart, basically after looping through each time, it's overwriting stuff.
×
×
  • 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.