markspec87 Posted June 8, 2006 Share Posted June 8, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/11486-dynamic-links-database/ Share on other sites More sharing options...
glenelkins Posted June 8, 2006 Share Posted June 8, 2006 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) Quote Link to comment https://forums.phpfreaks.com/topic/11486-dynamic-links-database/#findComment-43156 Share on other sites More sharing options...
wisewood Posted June 8, 2006 Share Posted June 8, 2006 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 followsSELECT * 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 Link to comment https://forums.phpfreaks.com/topic/11486-dynamic-links-database/#findComment-43160 Share on other sites More sharing options...
markspec87 Posted June 8, 2006 Author Share Posted June 8, 2006 [!--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 followsSELECT * 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. Quote Link to comment https://forums.phpfreaks.com/topic/11486-dynamic-links-database/#findComment-43173 Share on other sites More sharing options...
wisewood Posted June 8, 2006 Share Posted June 8, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/11486-dynamic-links-database/#findComment-43190 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.