Jump to content


news script nav problem.


2 replies to this topic

#1 nygorn

    Young Padawan

  • Members
  • Pip
  • 53 posts
  • Gender:Male
  • Location:Sweden

Posted 07 January 2009 - 07:33 AM

<?php
include "config.php";
include "connect_database.php";

function shortenText($input,$size){
if(strlen($input) > $size){
return substr($input,0,$size).'...';
} else {
return $input;
}
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
}
else{
$result = mysql_query("SELECT * FROM communitynews") or die(mysql_error());
while($row = mysql_fetch_array( $result ))
{

	echo "This shows just a part of the news. (click to read more)";
}
}

$result = mysql_query("SELECT * FROM communitynews WHERE id='$id' ") or die(mysql_error());
while($row = mysql_fetch_array( $result ))

{

	echo "This shows the whole news.";
}
if (strlen(intval($_GET['edit'])) > 0) {
$id = (integer) $_GET['edit'];
}else{ 
echo "This is edit part. // This part never shows.";
}
?>

Cant get this to work. Everything works fine but not the navigation part for ?edit=id-goes-here.
I've just learned some basic php but i need the edit function -.-
I changed the echo's instead of mysql query's to text to display what i've gotten.

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 07 January 2009 - 01:01 PM

That part should always show provided $_GET['edit'] is not set or has a string length > 0 (so a character count of 1 would work, not a literal integer value). Do you mean for it to show when $_GET['edit'] is set?

Edited by rc69, 07 January 2009 - 01:02 PM.


#3 nygorn

    Young Padawan

  • Members
  • Pip
  • 53 posts
  • Gender:Male
  • Location:Sweden

Posted 07 January 2009 - 03:45 PM

yea, when i enter the link ?edit=id-goes-here





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users