php - how to display other table data in $row = mysql_fetch_row -
i have 3 tables: te_event
, te_venue
, te_category
.
te_event
table has columns:categoryid
,venueid
,event description
,title
,date
,price
.te_venue
table has columns:venueid
,venuename
,location
.te_category
has columns:catid
,catdesc
.
and here sql query:
$sqlevent =" select * te_events inner join te_venue on te_events.venueid = te_venue.venueid inner join te_category on te_events.catid = te_category.catid eventid =" .$id;
if use row[]
retrieve data te_events
, row[ *number]
depends on te_events
column.
how retrieve other table data using row[*number]
?
note sure if answer question pretty confuse...
once fetch results in $row
, contains data 3 tables because that's sql query returns.
so data te_event
:
$categoryid = $row['categoryid']; $title= $row['title']; ...
and data te_venue
:
$categoryid = $row['venuename']; $location= $row['location']; ...
but ideally should retrieve columns need in code, , alias of them :
$sqlevent =" select * te_events.categoryid, te_events.venueid, te_events.`event description` eventdesc, te_events.title, te_events.date, te_events.price, te_venue.venuename , te_venue.location, te_category.catdesc te_events inner join te_venue on te_events.venueid = te_venue.venueid inner join te_category on te_events.catid = te_category.catid eventid =" .$id;
also should use parametrized query pass $id
, prevent sql injection.
Comments
Post a Comment