Reply
If else question regarding PHP/MySQL
Old 07-24-2004, 04:37 PM If else question regarding PHP/MySQL
Experienced Talker

Posts: 35
Hi there,

I'd like to do the following so that if no ID or an incorrect one is specified, then alternative pages are shown.

If database entry = present, include file.php, if database entry = non existent, include otherfile.php but if no id requested, include thisfile.php.

The database entry would need to be found via a variable defined by the URL. I have this code- thanks to members here. If the ID requested from the URL is not present in the database, I'd like it to include another file and if no ID is requested, then request another page. If an ID is found, then it includes another.

How might I do this?

Thanks

Sam
Sam Stockley is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-24-2004, 06:17 PM Hi
faisalzafar's Avatar
Experienced Talker

Posts: 41
Location: Pakistan
hi dear, i read ur problem , ur problem soluation is that when u r checking on the database for a particuallar page then make a if conditon that if condtion

e.g

if($ID==Null){
redirect to page0
}
else if $ID==$row1->ID){
redirec to page1
}
else{
msg=wrong id
or redirect another page
}
faisalzafar is offline
Reply With Quote
View Public Profile Visit faisalzafar's homepage!
 
Old 07-25-2004, 01:30 PM
Experienced Talker

Posts: 35
Thanks! I used the top one which is great but the second one needs to be able to find out from the database whether that ID exists and if not, then it should display a certain page. From what I can see, else if $ID==$row1->ID will only work if one ID equals another, not check if it exists.

Any help is appreciated.
Sam Stockley is offline
Reply With Quote
View Public Profile
 
Old 07-25-2004, 09:00 PM
Veter's Avatar
Super Talker

Posts: 136
if($ID==Null) could be if($ID)

for the second question.
PHP Code:
$sql"SELECT * FROM `yourtablehere` WHERE id=$ID";
$query mysql_query($sql);
$totalRows_Rec mysql_num_rows($query);
if(
$totalRows_Rec>0){
include 
this.php;
} else {
include 
that.php;

__________________
-= B2Netsolutions Inc. =-
-= Dedicated servers - Shoutcast hosting =-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Reply     « Reply to If else question regarding PHP/MySQL
 

Thread Tools

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 Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12034 seconds with 12 queries