Current location: Hot Scripts Forums » Programming Languages » PHP » Calling pages with the .php?id="#" link


Calling pages with the .php?id="#" link

Reply
  #1 (permalink)  
Old 08-10-03, 09:44 PM
Soulidified Soulidified is offline
Newbie Coder
 
Join Date: Jul 2003
Location: West Side
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Calling pages with the .php?id="#" link

Hello everyone,

I am a novice user, but have managed to figure out basic coding that will insert pictures, and text into databases and outputting them based on an id. (e.g. www.website.php?id=2). but i was wondering...

Is there an ?id=" " link that will call the highest ID in a table, so I dont have to change the link on the page when ever I add a new record?

Thanks everyone,

Jaesoul
__________________
"Go Bigger"
Reply With Quote
  #2 (permalink)  
Old 08-11-03, 07:01 AM
kickinhard007's Avatar
kickinhard007 kickinhard007 is offline
Newbie Coder
 
Join Date: Aug 2003
Location: Manchester, UK
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb here we go...

i'm no expert, but here's my idea...

have your link like:-
http://www.yourdomain.com/website.php?id=latest

then enter use this code on website.php

PHP Code:



if ($id == "latest") { 

mysql_connect($host,$username,$password) or die("Unable to connect to database");

@
mysql_select_db("$database") or die("Unable to select database $database");

$sqlquery "SELECT page_content FROM your_table LIMIT 1 ORDER BY id DESC";

$result mysql_query($sqlquery) or die("Unable to perform query");
    
mysql_close();

print 
$result;


so basically you are selecting the content from that particular table, only pulling it out of one record, which is the latest addition to the table, the 'DESC' puts them in order of last -->first.

the table in question will need an 'id' field with auto_increment.

hope this helps!

kickinhard007
Reply With Quote
Reply

Bookmarks


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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SEO Expert Available nakulgoyal Job Offers & Assistance 2 08-14-04 12:38 PM
Different type of link counter mdhall Script Requests 2 10-10-03 01:19 PM
[Needed] Basic link module for upcomming portal script MikeXP PHP 0 09-21-03 04:18 AM
carry logging state across pages superman PHP 1 06-30-03 09:55 AM


All times are GMT -5. The time now is 05:16 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.