Re: from database to links

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






On Wed, August 24, 2005 11:40 am, George B wrote:
> Richard Lynch wrote:
>> On Tue, August 23, 2005 3:52 pm, George B wrote:
>>
>>>You know on forums when you make a topic right away it makes like a
>>>new
>>>link to your topic. How do you do that in PHP?
>>
>>
>> <?php
>> //Untested code:
>>   if (isset($_POST['new_topic'])){
>>     $new_topic = $_POST['new_topic'];
>>     $new_topic = mysql_escape_string($new_topic);
>>     $query = "insert into topics (topic) values ('$new_topic')";
>>     $insert = mysql_query($query) or die (mysql_error());
>>     $topic_id = mysql_insert_id();
>>     echo "<a
>> href=\"topics.php?topic_id=$topic_id\">$_POST[new_topic]</a>";
>>   }
>> ?>
>>
>> http://php.net/mysql_insert_id
>> is probably the piece of the puzzle you were missing.
>>
> How did you get this in your link?
>
> topics.php?topic_id=$topic_id
>
> I cant figure.

This assumes you have a script named "topics.php" and that script uses
GET parameter "topic_id" to determine which Topic to display in your
Forum.

It was only a WILD GUESS as to how your forum topics would be
displayed, really... Well, not totally a wild guess, since that's
pretty much how they all work, though they will use different names
for stuff:

forum.php?id=$topic_id
view.php?thread_id=$topic_id
show.php?subject_id=$topic_id
.
.
.

Perhaps you need to set this aside for a while, and work on showing a
list of topics, and the display page for something chosen from that
list.

After you've written that, the link to put in there gets a LOT easier
to figure out.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux