PDA

View Full Version : jeez, i feel like I just jumped into the deep end without a lifeguard on duty


IanMFT
Wed 23rd May '01, 8:02pm
Ok, so I'm having problems with where to put something...what that something is, i have no clue...but I can tell you what I need this script to do:

$result = mysql_query( "SELECT * FROM articles WHERE pageid=1 AND articleid=$id" );
$result2 = mysql_query( "SELECT * FROM articles WHERE pageid=$page AND articleid=$id" );

//begin code to display articles
if (isset($id)) {
while( $row = mysql_fetch_array($result) ) {
if (!$result) {
print("<p>The article you requested is not available</p>");
} else {
print( $row[pagetext] );
// display the pagetext column for the selected article and firstpage
// used for displaying first page of article
}
}
} elseif ( isset($page) ) {
print( "You need to specify an article to request a page" );
} elseif ( isset($id) and isset($page) ) {
// display the pagetext column for the selected article and selected page
// used for displaying pages other then the first page and/or first page
while( $row = mysql_fetch_array($result2) ) {
print( $row[pagetext] );
}
} else {
print( "Please go to the article index to select an article" );
}
I have almost all grounds covered (this is a script to display articles in a database and the articles are defined through the link). BUT I am having trouble with defining where the message that would be displayed if someone requested an aricle that diddnt exist would be defined.

ie: content.php?id=7
and the article ID 7 diddnt exist in the database I would like it to display a message taht says something likethe article you requested doesn't exist)Can anyone help?

IanMFT
Wed 23rd May '01, 8:03pm
sorry, double post

Genotoxin
Thu 24th May '01, 2:25am
Hmm, pardon me if I give you an improper answer, but I had a little bit of trouble reading your question..

try adding this:

if (!mysql_num_rows($result))
{
echo "<P>The article you specified does not exist.</P>";
}


put that directly after the if (isset($id)) thing.