OnePHPscriptisessentiallyjustgoingtobe a standardupdatescriptlikewe'veusedpreviously.
Thefirstscriptisgoingbe a PHPscript, butbasicallywhat's goingtodoisisgoingtodynamicallybuildonHTMLWebpageforyouandprepopulatethatformwithwhatisalreadyintherecord.
Sowhen I wasgoingand I wasdoingthislaband I wasplayingaroundwithdifferentsettings, oneoftheissuesthat I ranintoisthatbasicallytheWebbrowser, Firefoxwouldcashsomeofthefieldswhere I hadenteredinformation.
Andthenwhen I hitrefreshinsteadofpullinginthenewinformationlikeitwassupposedtogo, itjustusedthecachedinformationthatitalreadyhadcashed.
Soonethingifyou'replayingaroundwiththescriptsandyou'regettinglike, weirdoutputfromtheform, oneofthingsyoumaywanttodoisinsteadof a refreshingtheformrefreshingthescriptactuallyclosethattab a reopenthatthatscriptPHPscriptthat I'm goingtoshowingyouin a differenttab, andthenthatshouldpullinallnewinformation.
SothefirstthingtobedoingthewarningwarningabouttodayisDobecarefulofyourWebbrowsercashing a datathatmaygiveyousomesomeweirdoutput.
Ififyou'renot, ifyoudon't knowthatthatmayhappen.
Theotherwarningwarningthat I willgiveyouismycodemaylookgnarlytoday.
Look, I'llbehonestwithyou.
I'm showingyoufolkshowallthisstuffkindofworks.
Thecodethat I actuallywritecanlook a littlemessy.
Mightnotalwaysbeuptothestandardsofthoseprofessionalsoutthere s o doJustkeepusinmindwhen I'm goingthroughthecode.
When I amshowingyouthingsagain, I amtrying.
Thioteachyouin a waythatyouunderstandwhatisgoingonwiththehopethatlateronceyoudograspthatconcept, you'lllearnhowtobeable, dopropersyntaxandwriteallofitallprettyfortheprofessionals.
Uh, butjustkeepthatinmindtoday.
Somethingcodethat I'm I'm writingforyoudoeslook a littlebitgnarly.
Thereasonthat I'm writingitinthewaythat I amisbecause I thinkitiseasiertounderstand.
Soanyways, withthat, let's gooverthecomputerand I willshowyouhowthiscodeworks.
Day.
Sohereweare, atmylabenvironmentagain, I'm usingtobunttodesktop 18.4 Lt s thisisrunningwithin a virtualmachineonvirtualbox.
And I'm using a Macbookpro.
Inordertocreatethelampstackonthisdemonstrationmachine, I usesomethingcalledtasks L t A s K S E L.
It's a toolthatallowsyoutoinstalltheentirelampstackpackingmysequelPHPalldefaultconfigurations.
I havenotmodifiedPHP.
Donnaand I havenotmodified V hostsoranythinglikethat.
Theonlymodificationitallis I didn't put a PHPfolderintherootdirectoryofApacheagain, so I hadsomeplacetodumpthePHPscriptsbeyondthatinordertoactuallywritethescriptsthat I'm showingyoutoday.
I amusing G edit.
Sothisistheequivalentofnopatortextedit.
AndeithertheWindowsortheMacworld, justbasically a crappylittletexteditor.
Becausewhen I'm writingrelativelysmallscripts, I dolikeshowingyoufolksthatyoucouldjustuse a crappytexteditorinordertodothat.
Theversionthatweneedtodoisweneedtogooverandtake a lookatourmysequeldatabaseandunderstandHowaremysecretdatabaseworksbeforeweactuallystartgettingintothescriptstodaytogodowntothewholeshowapplicationsthey'reuptogoterminal, they'regoingtoenteratthecommand.
Proud.
Ofcourseyoudo.
Mysequelspacehyphenyouoffwhateveryourusernameis, Bobhasalways a spaceSiphonPeedaskedforthepassword.
Thatsortof 123456 andwe'renowinmysequelfromhereWe'regoingtogoshowedat a basisbasisbecausewealwayswanttomakesureweunderstandtheenvironmentwe'redealingwith, especiallybeforedomodificationstoourdatabasesortables.
Thisshowsus.
Thedatabasesthatwehaveintheserverofthedatabasethatwecareabouttodayandthatwe'vebeenusingisclass D.
Now, I willhighlyrecommendthatyoucreate a backupofyourstudentstable, especiallywhenyou'replayingaround.
Sincewe'redoinganupdatetoday, right?
Ifyouscrewupanupdatein a script, youcanyoucanreallyHo's yourtablereallyquick.
So I wouldhighlyrecommendyoutakethethreeand 1/2 secondsrequiredinordertocreate a backupyourstudentstablesothatifyoudosomethingstupid, youcouldrecoverrelativelyquickly.
Fromthatwe'regoingtododescribethe E S C studentssemicolon.
Yes.
Sowecanseewhatthistablelookslike.
Thistablehasfourfield a student i d.
A nameandage, a tenderand a uniformstudent.
I D Fieldisanimportantfield.
It's aninteger, andit's anautoincrement.
Sothestudent I d.
Isgoingtobeimportanttodaywhenwewereup.
Basically, whenwe'researchingandwe'reupdatingrecordsbecausewithin a mysequeldatabasetable, youneedsomefeelthatisabsolutelyuniqueforallrecords.
Butifwedo a refreshbasicallygonnaselectallfromstudentsandwehitinnerWecanseenowSeethatstudent i d fiveisTimmyisnoweightandis a boy, sothat's whatwe'regoingtobedoingtoday.
Andthenthisiswhatwillactuallyputallofthedataintothemysecretdatabasetablesothatlet's take a look, eh?
Sowecomeuphereandthefirstthingwe'regoingtodo, ofcourse, isgoingtoopenupthePhbescriptthenextthingthatwe'regoingtodoiswe'regoingtocreate a variablecalledDollarSignunderscoresstudentdollardollarsignsstudentunderscoreideeandwe'regoingtosetittofive.
So I am a hardcoating.
Thestudent i d n here.
Butdoyourealizeagainwhen I amdoingclasses, there's a wholequestionofwheredoyoustarttheclassandwheredoyouendtheclass?
Andso I amhardcoatingthisendJustsojustsowecancompartmentalizewhat I'm tryingtoshowyoutoday.
Butdoyourealizethatthisvariablecouldbesetby a valuethatcomesinfrom a postfromanotherform?
Youcanhaveanotherformthathas a littletextboxthatsays, Whatstudent I didyouwanttomodify?
Youcouldplugin a numbertherehitsubmitthatcouldsendthevaluetothisPHPscript.
Thiscouldn't havetheothersidestudentunderscore i d equaldollarsign, underscorepostandactuallypullpullthevaluethat's beingsentfromtheotherformagain.
I amhardcoatingthisjustsowehave a placetostartfrompastthatover, thenjustgottogettothenormalcrappyconnectionstuffthatwe'realwaysdealingwith.
Thenextthingthatwe'regoingtodoiswe'regoingtocreatein a ravedollarsignRoseat a dollarsignRowisgonnabeanarray, and a raveis a variablethatstoresofmultiplevalueswithinit.
AndthenherewhatyoudoisyoudoupdateSoupdateisthecommandandsequeltoupdate a recordupdatestudentsandthenyousaysetnameequalsandthensinglequotationmarkdollarsignnamesandoneofthevaluethatyouputinthat a camelboxesItwillnowbethatcommaeightequalswhateverthevalueisinthe H e mailboxthatwillnowbetheagecommaGenderequalsbeginsinglequotationmarks, thendollarsigngenderWheneverthatvalueiswherestudent i d equalsondollarsignsstudent i d.
Sobasically, ifthisworks, thenall I needtoprintoutis I justneedsomevisualcuethatitworkedandthatitdidwhatitwassupposedto D'oh s.
Soforme, I justdidrecordsupdatedcabinetwithstudent I d cancatchmewith a hyphencancatchmewiththenamebeganwith a hyphenagainwithin a daycanbewithout a hyphenAndgetmewiththegenderSobasically, that's wherewhenyougetthatreallyuglyassitsaysrecordsupdateitsstudent i d name a gender.
Butthisis a basicwaythatyoucancreatetheyformthatwillbedynamicallybewritten.
Thedefaultvalueswillbe, um, youknow, whateveriscurrentlyintherecord, andthenyoucangoontogoinandmodifyandedit, andthenyousimplyhithits a bitqueryandthenthatwilledititforyou.
Sothereyougo.
Nowyouknowhowtoupdateyourrecordswithinyourmysequeldatabasetablesusing a dynamicallycreatedHTMLform.
Yeah, s.
Sonow, Nowyou'reactuallylearninghowtodoquite a fewthingsusing a basicPHPhtmlandyou'remysequeldatabaseyou'renowabletocreaterecordsarenowabletosearch.
Therecordswerenowabletolistrecords, andnowyou'reabletoupdaterecords, whichagainarethecorecomponentsofwhenyouthinkaboutitalmostissingle a mapthatyouuseagain?
Attheendoftheday, yourealize a lotoftheapplicationtouse, especially a lotoftheWebapplicationsairbasicallytheirtables, theirtableswithsomekindofinputform, withsomekindofoutputreportingon, andreally, that's aboutit.
OhmyGod, it's I wouldnotputthatinto a productionenvironment, but I thinkit's relativelyeasyforyoufolkstounderstandwhatyou'relookingatagain.
Tobeclear, itishorriblyinsecure.
I wouldhave I said I wouldnotputthison.
A productionenvironmentishorribleandsecure.
Usingwhat I'm showingyoutoDiowouldjustgetmassacredifyouputthisontheInternetbutisgiveyouanideaofhowthisstuffworks s sothatyoucouldthatinthefuturestartedactuallylockingeverythingdownandmakingmakingsomethingthatisvaluableforyou.
I alsowantyoutounderstandunderstandingwhereagain, when I starttalkingaboutyou'regonnabeusingmultipleprogramminglanguagesordecreeanyappthatthatyoureallydohavetousemultipleprogramminglanguagesagain, likewe'reusingmysequel.
Becausesomeone, because I mean, thinkaboutwhat a messitwouldbeifyoucouldupdaterecords, butyoucouldn't seewhat's currentlyintherecord, right?
Youjusthadtextboxes, justtypestuffinandsubmitteditlikethatwouldbe a besthavehavingthedefaultentryinthosetextboxesbepulledfromthetablethatactuallymakesomethinguseful.
You'regonnabegoingoutthereandcreatinganykindofWebappattheminimum, theminimumyou'relookingat, likefivelanguages, plus a fewothertechnologiessuchasApacheandtheLennoxandthattypeofthingtomakethethingwork.
Sosay, thereyougo.
Youknow, now, knowhowdoupdateyouryourrecordsusing a dynamicallycreatedHTMLformwithPHP.
Asalways, I enjoydoingthisvideoandlookforwardtoseeingthenextone.
ApparentlythetypeofcontentyoujustsawisnotwhatSusan W.
WantsforthefutureofYouTube.
ThismeansthatrecommendationsbyYouTubetothischannelhavedroppedmassively, andviewsarebecoming a comicallysmall I hatetoask.
I usedtosay I wouldneverask, butifyoucouldsubscribelikecommonandmostimportantly, sharethevideosthatyouappreciate, thatmayhelpslowthedeathofthischannel.