Shivski Posted January 16, 2009 Posted January 16, 2009 Hey Ii trying to set my shops into the explore.php file so that they show the actual shops in the file instead of having to click 'Shops'. I have the query if($ir['location'] == 2) { print " [url='shops.php?shop=4']Geoff's Gun Shop[/url] "; } print " But on entering it, it shows the explore as blank. Is there an error in the coding that anyone can see? Quote
gurpreet Posted January 16, 2009 Posted January 16, 2009 Re: "if location =" ... query Are you in Location 2? Quote
Shivski Posted January 16, 2009 Author Posted January 16, 2009 Re: "if location =" ... query It shouldnt matter. Ive been in location 1 and 2, but the explore doesn't show, its blank. Which is my limited experience means the code is wrong or theres some sort of bracket wrong. Iv attached more of the code to see where it sits within the page [b]<u>Shops and Market</u>[/b] [url='shops.php']All Shops[/url] if($ir['location'] == 2) { print " [url='shops.php?shop=4']Geoff's Gun Shop[/url] "; } print " [url='itemmarket.php']Item Market[/url] Quote
Eternal Posted January 16, 2009 Posted January 16, 2009 Re: "if location =" ... query * Note: This is only a base template take the query and Put is suited into your explore.... <?php include "globals.php"; $tresder=(int) rand(100,999); if($ir['jail'] or $ir['hospital']) { die("This page cannot be accessed while in jail or hospital."); } print "<center>[b] Below you will find many useful links.[/b] </br> <table> <table width=75% border='1'> <tr height=100 valign=top> <td valign=top width=33%><center>[b]Station Center[/b]</center><hr color='#2E8B57'> <center>[url='cbank.php']Crystal Bank[/url]</center> <center>[url='estate.php']Estate Agent[/url]</center> <center>[url='monorail.php']Travel Agency[/url]</center> <center>[url='bank.php']City Bank[/url]</center> "; $q=$db->query("SELECT * FROM shops WHERE shopLOCATION={$ir['location']}"); while($r=$db->fetch_row($q)) { print "[url='shops.php?shop={$r[']{$r['shopNAME']}[/url] "; } echo" <center>[url='cyberbank.php']Cyber Bank[/url] <td valign=top width=33%><center>[b]Market Place[/b]</center><hr color='#2E8B57'> //rest of explore here Quote
Shivski Posted January 16, 2009 Author Posted January 16, 2009 Re: "if location =" ... query I've copied and pasted it and still the explore.php is blank. This is how it sits in my code. [url='shops.php']All Shops[/url] $q=$db->query("SELECT * FROM shops WHERE shopLOCATION={$ir['location']}"); while($r=$db->fetch_row($q)) { print "[url='shops.php?shop={$r[']{$r['shopNAME']}[/url] "; } echo" [url='itemmarket.php']Item Market[/url] Quote
Eternal Posted January 16, 2009 Posted January 16, 2009 Re: "if location =" ... query Must be a problem with your explore page other than that query.... Quote
Shivski Posted January 16, 2009 Author Posted January 16, 2009 Re: "if location =" ... query But I take out the query and it comes back fine, so its the query? Im back to my normal shops (the click to view them) and everything is working fine. Quote
AlabamaHit Posted January 16, 2009 Posted January 16, 2009 Re: "if location =" ... query make sure your closing and prints or echos before.. the code you used First is right. echo "make sure this part is closed"; if($ir['location'] == 2) { echo "Show something here."; } echo "the rest of the page"; Thats right. It has to be something else on that page OR your not in location 2. That query says. IF "You" are in "location" "2" echo "Show something here" if your Not in location 2 it wont. Quote
Shivski Posted January 16, 2009 Author Posted January 16, 2009 Re: "if location =" ... query make sure your closing and prints or echos before.. the code you used First is right. echo "make sure this part is closed"; if($ir['location'] == 2) { echo "Show something here."; } echo "the rest of the page"; Thats right. It has to be something else on that page OR your not in location 2. That query says. IF "You" are in "location" "2" echo "Show something here" if your Not in location 2 it wont. SO how would that sit if my part of my code is this? [url='shops.php']All Shops[/url] $q=$db->query("SELECT * FROM shops WHERE shopLOCATION={$ir['location']}"); while($r=$db->fetch_row($q)) { print "[url='shops.php?shop={$r[']{$r['shopNAME']}[/url] "; } echo" [url='itemmarket.php']Item Market[/url] Quote
AlabamaHit Posted January 16, 2009 Posted January 16, 2009 Re: "if location =" ... query you have a pointless query. Thats how. why select the WHOLE shops table. when you already know the ID?? And your NOT closing the PRINT OR ECHOS nevermind...figure it out yourself.. Quote
Shivski Posted January 16, 2009 Author Posted January 16, 2009 Re: "if location =" ... query Right, so your attitude is not really helping. All I asked was how to correct my code. Im new to this (as u can no doubt tell) Can you amend my code with the correct echos and prints so I can see where I have gone wrong and so I can learn for future reference? Quote
AlabamaHit Posted January 16, 2009 Posted January 16, 2009 Re: "if location =" ... query [url='shops.php']All Shops[/url] $q=$db->query("SELECT * FROM shops WHERE shopLOCATION={$ir['location']}"); while($r=$db->fetch_row($q)) { print "[url='shops.php?shop={$r[']{$r['shopNAME']}[/url] "; } echo" [url='itemmarket.php']Item Market[/url] thats yours [url='shops.php']All Shops[/url] "; $q=$db->query("SELECT * FROM shops WHERE shopLOCATION={$ir['location']}"); while($r=$db->fetch_row($q)) { print "[url='shops.php?shop={$r[']{$r['shopNAME']}[/url] "; } echo" [url='itemmarket.php']Item Market[/url] Look at first Line... See the "; All Shops "; You didn't close a print or echo.Thats what I was meaning. And NO your statement to me was not obvious that you wanted me to help you current what you did. It sounded like you where getting smart saying it was not different from what You said before. Quote
Shivski Posted January 16, 2009 Author Posted January 16, 2009 Re: "if location =" ... query I apologise if it came across that way, btu i didnt mean it too. All im wanting is to add this query underneath other links. But the explore becomes blank and I for the life of me can not see why. I don't have echos on my original code. if($ir['location'] == 2) { print " [url='shops.php?shop=4']Geoff's Gun Shop[/url] "; } print " Quote
Tonka Posted January 16, 2009 Posted January 16, 2009 Re: "if location =" ... query if you take your original code [b]<u>Shops and Market</u>[/b] [url='shops.php']All Shops[/url] if($ir['location'] == 2) { print " [url='shops.php?shop=4']Geoff's Gun Shop[/url] "; } print " [url='itemmarket.php']Item Market[/url] you are missing a "; here it is fixed [b]<u>Shops and Market</u>[/b] [url='shops.php']All Shops[/url] "; //This is the line that you missed the "; on if($ir['location'] == 2) { print " [url='shops.php?shop=4']Geoff's Gun Shop[/url] "; } print " [url='itemmarket.php']Item Market[/url] Quote
Shivski Posted January 16, 2009 Author Posted January 16, 2009 Re: "if location =" ... query That worked for that 1, thanks :) But... I encore the same problem when putting 2 next to each other though. Is there anycode I need to put between them? Iv tired variations with "; to no avail. Sorry for my n00bish. And cheers for your patience. Quote
AlabamaHit Posted January 17, 2009 Posted January 17, 2009 Re: "if location =" ... query I'm not sure what you mean? Quote
Shivski Posted January 17, 2009 Author Posted January 17, 2009 Re: "if location =" ... query I need more then 1 location query next to eachother so it would look like a normal list of links, but everytime I try and add one straight after the , print ", it makes my explore blank again. Quote
BlueDevil23 Posted January 17, 2009 Posted January 17, 2009 Re: "if location =" ... query We can only help, and correct your code, if you show us what you tried. :) Quote
Shivski Posted January 17, 2009 Author Posted January 17, 2009 Re: "if location =" ... query Ooppss, Soryr bout that, thought i did in my last post. [b]<u>Shops and Market</u>[/b] [url='shops.php']All Shops[/url] "; if($ir['location'] == 2) { print " [url='shops.php?shop=4']Geoff's Gun Shop[/url] "; } print " if($ir['location'] == 2) { print " [url='shops.php?shop=5']Andy's Armour Shop[/url] "; } print " [url='itemmarket.php']Item Market[/url] Quote
BlueDevil23 Posted January 17, 2009 Posted January 17, 2009 Re: "if location =" ... query Ooppss, Soryr bout that, thought i did in my last post. [b]<u>Shops and Market</u>[/b] [url='shops.php']All Shops[/url] "; if($ir['location'] == 2) { print " [url='shops.php?shop=4']Geoff's Gun Shop[/url] "; } print " if($ir['location'] == 2) { print " [url='shops.php?shop=5']Andy's Armour Shop[/url] "; } print " [url='itemmarket.php']Item Market[/url] If your not changing location, you can simply add the next shops inside, the current if block. <strong style='text-decoration:underline;'> Shops and Market [/b] [url='shops.php'] All Shops [/url] "; if($ir['location'] == 2) { print " [url='shops.php?shop=4']Geoff's Gun Shop[/url] [url='shops.php?shop=5']Andy's Armour Shop[/url] [url='itemmarket.php']Item Market[/url] "; } Quote
Shivski Posted January 17, 2009 Author Posted January 17, 2009 Re: "if location =" ... query Wicked will give it a try. If I want to change the location after I put all those up. How would I add it? Quote
BlueDevil23 Posted January 17, 2009 Posted January 17, 2009 Re: "if location =" ... query Wicked will give it a try. If I want to change the location after I put all those up. How would I add it? Added comments in the code, check em out. <strong style='text-decoration:underline;'> Shops and Market [/b] [url='shops.php'] All Shops [/url] "; if($ir['location'] == 2) { print " [url='shops.php?shop=4']Geoff's Gun Shop[/url] [url='shops.php?shop=5']Andy's Armour Shop[/url] [url='itemmarket.php']Item Market[/url] "; } //You would add another if block, but make sure you have no other print() or echo() open if($ir['location'] == 3) //Does't necessarily have to be 3, you would change this number //to the locationyou want the links available in. { print "Link Link Link Link"; } //You would add as many if blocks, as you need, for each location. if($ir['location'] == 4) { print "Link Link Link Link"; } Quote
Shivski Posted January 17, 2009 Author Posted January 17, 2009 Re: "if location =" ... query Hey, that sorted the 1st issue out, cheers. But, when I try to add another location query, it once again goes blank. This is the way I have coded it. I can't see any prints or echos open, btu im possibly blind lol a href='shops.php'>All Shops</a> "; if($ir['location'] == 1) { print " [url='shops.php?shop=4']Geoff's Gun Shop[/url] [url='shops.php?shop=5']Andy Gun Shop[/url] [url='shops.php?shop=6']Steve's Shoe Shop[/url] [url='shops.php?shop=9']Owen's Odds & Sods[/url] "; } print " if($ir['location'] == 2) { print " [url='shops.php?shop=10']Shop[/url] [url='shops.php?shop=11']Shop[/url] [url='shops.php?shop=12']Shop[/url] [url='shops.php?shop=13']Shop[/url] "; } print " [url='itemmarket.php']Item Market[/url] Quote
BlueDevil23 Posted January 17, 2009 Posted January 17, 2009 Re: "if location =" ... query Hey, that sorted the 1st issue out, cheers. But, when I try to add another location query, it once again goes blank. This is the way I have coded it. I can't see any prints or echos open, btu im possibly blind lol a href='shops.php'>All Shops</a> "; if($ir['location'] == 1) { print " [url='shops.php?shop=4']Geoff's Gun Shop[/url] [url='shops.php?shop=5']Andy Gun Shop[/url] [url='shops.php?shop=6']Steve's Shoe Shop[/url] [url='shops.php?shop=9']Owen's Odds & Sods[/url] "; } print " if($ir['location'] == 2) { print " [url='shops.php?shop=10']Shop[/url] [url='shops.php?shop=11']Shop[/url] [url='shops.php?shop=12']Shop[/url] [url='shops.php?shop=13']Shop[/url] "; } print " [url='itemmarket.php']Item Market[/url] 1. You cannot put an if statement inside of a print. print " if($ir['location'] == 2) { 2. You forgot the opening bracket on the first anchor tag. a href='shops.php'>All Shops</a> "; 3. You didnt close the last print statement. print " [url='itemmarket.php']Item Market[/url] :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.