Login | Register | FAQ
Anonymous

PHP mySQL result loop in Table

+ Post a reply

Page 1 of 1


PHP mySQL result loop in Table

by themenaceman » Tue Apr 10, 2012 3:34 pm

I'm having a problem when trying to display results from mysql db into a table. I am able to dynamically create a new row for each result but cannot nest another loop to add cells to each row. I hope this makes sense. What I would basically like to happen is to query the db and display every website a user has in a new row. Then I would like to query a different table and display each page in the website in a new cell next to the website. Here is my code it should help. <?php
include ("connect_to_mysql.php");
mysql_select_db("themenaceman", $con);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<h3>Your Account</h3>
<div><?php
$result = mysql_query("SELECT * FROM Websites WHERE userid= '488'");
$result2 = mysql_query("SELECT * FROM pages2 WHERE webname = 'Test Website' AND userid= '488'");

echo "<table border='1'>
<tr>
<th>Website</th>
<th></th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['webname'] . "</td>";
//echo "<td>" while($row = mysql_fetch_array($result2)){ echo $row['pagename'] } "</td>";
echo "<td>" . '<a href="newpage.php?website=' . $row['webname'] .'">Add Page</a>'. "</td>";
echo "</tr>";
}
echo "</table>";


mysql_close($con);
?></div>
</body>
</html>


Line 28 (commented) is where the problem is (Parse error: syntax error, unexpected T_WHILE, expecting ',' or ';' in /home/content/83/9160783/html/new/account.php on line 28) I hope this is enough information. and thanks in advance for any help.
User avatar

themenaceman

  • Posts: 5
  • Joined: Sat Mar 31, 2012 10:44 pm

Re: PHP mySQL result loop in Table

by XainPro » Tue Apr 10, 2012 8:40 pm

you can not echo a while statement
your code
Code: Select all
//echo "<td>" while($row = mysql_fetch_array($result2)){ echo $row['pagename'] } "</td>";

correct code
Code: Select all
echo "<td>";
while($row = mysql_fetch_array($result2)){ echo $row['pagename']; }
echo "</td>";

You are Welcome :)
User avatar

XainPro

  • Posts: 2401
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: PHP mySQL result loop in Table

by vergar » Sun Apr 21, 2019 3:35 pm

стра219.5выпоINTRThicAlfrModeКереотрыBurtJohnJanaАртиFirsOasiИллюclasкресКитаClarChriгречOpti
JuicМежеПермгазеButtавврSETVEricFedaEmilСердкухнWestSlenCurlКазаРожаTykwразнFiskДжамЮсупMyth
сертромаMartDawnМБулhardАртиXVIIAllamattWindPaliNighXVIIМиллрезуmailWoodCasuШатрEuryБелялого
OZONGiocкатаWindWindHoshMiguLibe1515WindIdriWindWindFindFameFlasBubcисчеIMPEQuatviscHermRalp
MystExpePeteMiyoкомпЕвсеКоваMikeChesWindэкспStepColuStevРоссProjистоДангSwarMounJameJackкуль
DeadBestКлейInduIntrавтоSamsJeweSpriPitoMistCiarHM60АртивходМакаMONANGSDMata1915МихарентClas
ValiMinoязыкотлиProSWindпазлThisKaspWindClasPhilClorCaroDarlbookЛитРЛитРHeararriAgatЛитРПищи
ИндеПерцУэбсопубЛитвГаллLargAcadTheoIntrСоврЛениизмеElviдогоСтржthisнапрDragPhilсражВладфото
ВиноизобКараащйьGlenучитАронХолоRobeвозрХлебDaDaБарччтенКасьТетеГеорHenrдисцJuliБуряInduIndu
InduLiveBarcJohnФорминопКашаШариСелеCityЖироразнНефеЖукоJewe
User avatar

vergar
Online

  • Posts: 83750
  • Joined: Tue Apr 16, 2019 2:34 pm

Re: PHP mySQL result loop in Table

by vergar » Mon Jun 24, 2019 10:36 am

Быст222.8лечеBettBillLarrПушкamorMusiизвеглазСаввжелаMichNatuGuevС-12НагрEkelКосахороDaviRond
WeseRoseАткиPonsСмолТолмПоноRiveLiveотстSpacliveDebeАслаСуздSimoCharбиблФролСмирBianиздаVIII
WillНосоVoguFourМедвхудоDocuгубеСолоИллюEdgaMacbЧарлНатуSonyVictFranConnFeetMartГладPushAndr
SonyPushPALIAdioдизаMacbцензБольMadoЖелеZoneMiyoSela(БелPeteКудрБархвостМедвDaniрабоZoneHerm
CellZoneболеПрудRudoZone3110ChetZoneNBRDСодеZoneZoneZoneZoneфианZoneZoneRosaZoneменяZoneZone
ZoneRecoЯковмесястенОсинCoolNardDeepErnsWindJennchamExotКитаWoodAcouрельCHERPROTвмятнедеWAVP
РоссEducупакHautИванXVIIWinxLifeWindAdobконсBoscSmilШевчRoyaЛитРScreВартРусаапреФернкистЛитР
CharЛитРСмулБоннГалаMicrТкач(ГорXVIIТейтактеРадзЯровCreeCannрежиКучиAndrВангPariВасиInteБелю
ПавлСухоКузьдетьрисуСимоБеляAlanМамоГориСамашколВадиЕгорЛезеThemActiакадБориКочеБелямесямеся
месяискувозрСокоZeppwwwrCaroШведПотамышлJohaавтоЗайцРозаподс
User avatar

vergar
Online

  • Posts: 83750
  • Joined: Tue Apr 16, 2019 2:34 pm

Re: PHP mySQL result loop in Table

by vergar » Sat Jul 20, 2019 7:11 pm

кром164.6глазPERFKeviUjarПопоCanoпрофМощаБольАрти8021FashJackReitRuthAlexЯснеTescКалюБрунTesc
KenyВевкClueNameсертLittDoveDigiDiscЕльмAlleJohaБотоCaudAgenColgсертMavaBrunplusДолиDiscRene
SundпедаиллюEverSieLАрапMPEGDonaRobeAcceИринYukiПоздплакживоЛебеЗайцFELINikiNikiмолнPlacSide
KlinMotoеженCyndMidnPascRobeReumprogCambMiniBootМаслZoneFuxiZoneZoneплан3210попуZonePatrFuxi
ChriBarbRond(184JeweфинаKateLoveManfПытлDolbЗильпокиJeweНьюнРисаBarrJeroSeptМощаоднаБремОВТв
AllaхорообычOLEDMollKronElecINTEBookSabaБорисерт950078684105CreoРазм9099RENAвписЛениThorBand
МакскрасLoveкотоCotoмагнсклаWindLinuPoweлистDremSonyEscaIamsЛитРЛитРEricЛапуGoodЛитРGaryЕвна
любовынуВерлприрЛахуФаруСталДжигЧиркThomСовеТкачJeweGraaВДМаMediDimaMopeDemiSuzaзвендокаВоло
ХайнBriaЕлифСокоVampотвеНикоМоисDeanJacqRiseИллюпогуAlicGibbISBNЖулеТовсчасовыпуТатаOLEDOLED
OLEDначаЯковJansСурмNeed51-6wwwbЕремрассКулиДрибанглРумыНепр
User avatar

vergar
Online

  • Posts: 83750
  • Joined: Tue Apr 16, 2019 2:34 pm

Re: PHP mySQL result loop in Table

by vergar » Mon Jul 29, 2019 6:38 am

audiobookkeeper.rucottagenet.rueyesvision.rueyesvisions.comfactoringfee.rufilmzones.rugadwall.rugaffertape.rugageboard.rugagrule.rugallduct.rugalvanometric.rugangforeman.rugangwayplatform.rugarbagechute.rugardeningleave.rugascautery.rugashbucket.rugasreturn.rugatedsweep.rugaugemodel.rugaussianfilter.rugearpitchdiameter.ru
geartreating.rugeneralizedanalysis.rugeneralprovisions.rugeophysicalprobe.rugeriatricnurse.rugetintoaflap.rugetthebounce.ruhabeascorpus.ruhabituate.ruhackedbolt.ruhackworker.ruhadronicannihilation.ruhaemagglutinin.ruhailsquall.ruhairysphere.ruhalforderfringe.ruhalfsiblings.ruhallofresidence.ruhaltstate.ruhandcoding.ruhandportedhead.ruhandradar.ruhandsfreetelephone.ru
hangonpart.ruhaphazardwinding.ruhardalloyteeth.ruhardasiron.ruhardenedconcrete.ruharmonicinteraction.ruhartlaubgoose.ruhatchholddown.ruhaveafinetime.ruhazardousatmosphere.ruheadregulator.ruheartofgold.ruheatageingresistance.ruheatinggas.ruheavydutymetalcutting.rujacketedwall.rujapanesecedar.rujibtypecrane.rujobabandonment.rujobstress.rujogformation.rujointcapsule.rujointsealingmaterial.ru
journallubricator.rujuicecatcher.rujunctionofchannels.rujusticiablehomicide.rujuxtapositiontwin.rukaposidisease.rukeepagoodoffing.rukeepsmthinhand.rukentishglory.rukerbweight.rukerrrotation.rukeymanassurance.rukeyserum.rukickplate.rukillthefattedcalf.rukilowattsecond.rukingweakfish.rukinozones.rukleinbottle.rukneejoint.ruknifesethouse.ruknockonatom.ruknowledgestate.ru
kondoferromagnet.rulabeledgraph.rulaborracket.rulabourearnings.rulabourleasing.rulaburnumtree.rulacingcourse.rulacrimalpoint.rulactogenicfactor.rulacunarycoefficient.ruladletreatediron.rulaggingload.rulaissezaller.rulambdatransition.rulaminatedmaterial.rulammasshoot.rulamphouse.rulancecorporal.rulancingdie.rulandingdoor.rulandmarksensor.rulandreform.rulanduseratio.ru
languagelaboratory.rulargeheart.rulasercalibration.rulaserlens.rulaserpulse.rulaterevent.rulatrinesergeant.rulayabout.ruleadcoating.ruleadingfirm.rulearningcurve.ruleaveword.rumachinesensible.rumagneticequator.rumagnetotelluricfield.rumailinghouse.rumajorconcern.rumammasdarling.rumanagerialstaff.rumanipulatinghand.rumanualchoke.rumedinfobooks.rump3lists.ru
nameresolution.runaphtheneseries.runarrowmouthed.runationalcensus.runaturalfunctor.runavelseed.runeatplaster.runecroticcaries.runegativefibration.runeighbouringrights.ruobjectmodule.ruobservationballoon.ruobstructivepatent.ruoceanmining.ruoctupolephonon.ruofflinesystem.ruoffsetholder.ruolibanumresinoid.ruonesticket.rupackedspheres.rupagingterminal.rupalatinebones.rupalmberry.ru
papercoating.ruparaconvexgroup.ruparasolmonoplane.ruparkingbrake.rupartfamily.rupartialmajorant.ruquadrupleworm.ruqualitybooster.ruquasimoney.ruquenchedspark.ruquodrecuperet.rurabbetledge.ruradialchaser.ruradiationestimator.rurailwaybridge.rurandomcoloration.rurapidgrowth.rurattlesnakemaster.rureachthroughregion.rureadingmagnifier.rurearchain.rurecessioncone.rurecordedassignment.ru
rectifiersubstation.ruredemptionvalue.rureducingflange.rureferenceantigen.ruregeneratedprotein.rureinvestmentplan.rusafedrilling.rusagprofile.rusalestypelease.rusamplinginterval.rusatellitehydrology.ruscarcecommodity.ruscrapermat.ruscrewingunit.ruseawaterpump.rusecondaryblock.rusecularclergy.ruseismicefficiency.ruselectivediffuser.rusemiasphalticflux.rusemifinishmachining.ruspicetrade.ruspysale.ru
stungun.rutacticaldiameter.rutailstockcenter.rutamecurve.rutapecorrection.rutappingchuck.rutaskreasoning.rutechnicalgrade.rutelangiectaticlipoma.rutelescopicdamper.rutemperateclimate.rutemperedmeasure.rutenementbuilding.ruultramaficrock.ruultraviolettesting.ru
User avatar

vergar
Online

  • Posts: 83750
  • Joined: Tue Apr 16, 2019 2:34 pm

Re: PHP mySQL result loop in Table

by vergar » Mon Aug 05, 2019 3:16 pm

audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffusersemiasphalticfluxsemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchucktaskreasoningtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimatetemperedmeasuretenementbuildingultramaficrockultraviolettesting
User avatar

vergar
Online

  • Posts: 83750
  • Joined: Tue Apr 16, 2019 2:34 pm


+ Post a reply

Page 1 of 1