Jump to content

Recommended Posts

I didnt knwo what to put for the title because this is quite a range of things.

Basically im making a html form, that admins can fill in and when they click sumbit, php will create a new html page, save it with all the variables in, and then display the recently added article in the last 5 added.

Now vie got the form to put the information in the databse. Wisewood is hopefully sending me a script so i can learn how to create the html but my questio nis, how can i increment its name.

When it saves i wanted it to be called "report#.html" basically, ill use the autonumber from the table to create the number #.

my question is basically, is this do able? I can use the autonumber to reference the links on the main page?

I was also thinking it could be masked by a one of those dynamic links like "index.php?reportid=2" How exactly do those kinds of links work?

thanks.
Link to comment
https://forums.phpfreaks.com/topic/11486-dynamic-links-database/
Share on other sites

You can get the auto increment number after the insert satement:

[code]
$sql = "INSERT INTO tablename VALUES ('',value,value,value)";
$result = mysql_query($sql);
$id = mysql_insert_id();
[/code]

Now to create the filename:

[code]
$filename = "report" . $id . ".html";
[/code];

this should create the filename as: report1.html for example.

These links: index.php?reportid=2 work like this:

[code]
<a href="index.php?reportid=2">Click Here To Refresh</a>

<?
if ($_GET['reportid'] == 2) {
  $rep_id = $_GET['reportid'];
  echo "Report ID: " . $rep_id;
}
?>
[/code]

they are used in links, when the page is refreshed the variable "reportid" is send in the header with the "index.php" this can then be taken with $_GET['varname'] or in case of a form $_POST['varname'] (unless you use GET in the form of course)
Link to comment
https://forums.phpfreaks.com/topic/11486-dynamic-links-database/#findComment-43156
Share on other sites

When you get the script that i've emailed to you, you want to have that done after the database stuff.

Insert the info into your database, then query the database straight away and get the id of the last entry.

then just include that id into the part of the script i sent you that names the file you're creating.

Second part... if you want to use reports.php?id=2 as the page name to load the html documents, you'd be better off not using html at all.

Create reports.php to the layout etc that you want, and select your info from the database as follows

SELECT * FROM reports WHERE report_id = $_GET[id]

Obviously replacing reports with your table name, and report_id with the name of the field that you auto-increment.
Link to comment
https://forums.phpfreaks.com/topic/11486-dynamic-links-database/#findComment-43160
Share on other sites

[!--quoteo(post=381368:date=Jun 8 2006, 02:46 PM:name=wisewood)--][div class=\'quotetop\']QUOTE(wisewood @ Jun 8 2006, 02:46 PM) [snapback]381368[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Create reports.php to the layout etc that you want, and select your info from the database as follows

SELECT * FROM reports WHERE report_id = $_GET[id]

Obviously replacing reports with your table name, and report_id with the name of the field that you auto-increment.
[/quote]

Thanks for that, i think ill give that a try first, seems a lot simpler then what i had in mind.
Link to comment
https://forums.phpfreaks.com/topic/11486-dynamic-links-database/#findComment-43173
Share on other sites

much better & simpler way of doing it. Thats kinda the whole point of having the database there.

Database & one php file size is nothing in comparison to databse, php file AND several hundred html files containing data stored in the database anyway.
Link to comment
https://forums.phpfreaks.com/topic/11486-dynamic-links-database/#findComment-43190
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.