Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Directory Submission Service   I Sell Pagerank   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 04-30-2005, 05:41 AM   #1 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
no ?id= show something else

Hi i'm using PHP and currently my code does this:-

gets the id and displays the article i.e articles.php?id=4

how can i get is so that if articles.php is entered instead of saying no article it will show the categories. I have the categories mostly done already but on a different page.
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 04-30-2005, 06:47 AM   #2 (permalink)
v7n Mentor
 
Sketch's Avatar
 
Join Date: 05-06-04
Location: London, UK
Posts: 1,453
iTrader: 0 / 0%
Latest Blog:
None

Sketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web pro
Code:
if($_GET['id'] == '') { include"categories.php" } else { include"article4.php" }
I'm not sure if thats what you mean but something like that would work if ID isn't entered.
Sketch is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-30-2005, 06:51 AM   #3 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
k instead of that would it be possible to use one file like this:-

articles.php runs the query to the DB to show all the categories (if no id is present do the category query)

and

articles.php?id=2 runs a separate query to get the article (if id is present do the article find query)
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-30-2005, 07:32 AM   #4 (permalink)
Inactive
 
Join Date: 04-07-05
Posts: 42
iTrader: 0 / 0%
Latest Blog:
None

adrenalinepcs is liked by many
PHP Code:
if($_GET['id'])
{
   
article query
}
else
{
    include(
"categories.php");

adrenalinepcs is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-30-2005, 07:35 AM   #5 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
k does it have to have categories.php as i'm hoping to delete that file and use just articles.php.
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-30-2005, 09:54 AM   #6 (permalink)
v7n Mentor
 
hatchet's Avatar
 
Join Date: 10-11-03
Posts: 1,137
iTrader: 0 / 0%
Latest Blog:
None

hatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nice
Just have 2 functions.. one for listing articles and one for categories.. then do as adrenaline said - except change article query to article($id); where article is the function name... and change include('categories.php'); to categories(); where categories is the function name.
hatchet is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-30-2005, 10:18 AM   #7 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
k but there is no categories anymore.

is it possible to have 1 file called articles.php and when there is the ?id= present it will look for the article with that id and when there is no ?id= present it will display the catergories using my sql query not an include.

ie:

IF id is present {
find article with that id
}
else {
category sql query
}
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-30-2005, 11:31 AM   #8 (permalink)
Inactive
 
Join Date: 04-07-05
Posts: 42
iTrader: 0 / 0%
Latest Blog:
None

adrenalinepcs is liked by many
post all your current queries and i'll write a the file for you.
adrenalinepcs is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-30-2005, 05:00 PM   #9 (permalink)
v7n Mentor
 
hatchet's Avatar
 
Join Date: 10-11-03
Posts: 1,137
iTrader: 0 / 0%
Latest Blog:
None

hatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nice
Limit - that's exactly what adrenalinepcs code does.

If id is set then show article with id else show categories.
hatchet is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-01-2005, 03:25 AM   #10 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
k thanxs i have now done that. I got confused earlier. Anyway i modified it to this:-

Code:
if(@(int) $_GET['id'])
the @ stopped the error about undefined index and the int makes sure only numbers can be entered, so no ' " i think.
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
TV Show Website ParLawGod Domain Name Forum 5 04-18-2007 07:31 AM
Friday Night Lights (tv show), and House (tv show) sim Forum Lobby 0 10-31-2006 05:13 PM
Feed doesn't show up? Pimpen 2010 Coding Forum 11 02-03-2005 05:27 PM
Getting URL to show up stwillia SEO Forum 4 05-20-2004 01:17 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 09:09 PM.
© Copyright 2008 V7 Inc