Re: extract() help

From: Date: Sun, 25 Feb 2001 07:22:43 +0000
Subject: Re: extract() help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41553@lists.php.net to get a copy of this message
In article <B6BE1922.294E%jaxon@salamander.net>, jaxon@salamander.net (Jaxon) wrote: > the following function is supposed to build an html table, creating a > content row for every row in a database table. It is creating a table with > the correct number of rows, but NO content is being echoed... <snip> > $sql="select i.nID, i.date, i.headline, i.subtitle, i.blurb from > news_items i, news_box b where i.nID = b.nID and b.dID = $i"; > > $result = mysql_query($sql, $link_id); > $row = mysql_fetch_row($result); > > extract($row); //the variables below match field names in this row > > echo " > <tr><td><h1>$headline</h1></td></tr> > <tr><td><h4>$subtitle</h4></td></tr> > <tr><td > align=\"right\"><h6>$date</h6></td></tr> > <tr><td>$blurb</td></tr> > <tr><td><a > href=\"news.php?#$nID\"><h5>...more</h5></a></td></tr> The elements in $row will have indexes like $row['i.headline'], rather than $row['headline'], just as the columns would have those names if you ran the query at the command line. (BTW, I find that doing a var_dump() or print_r() on variables--such as $row, in this case--to be very helpful when data isn't coming out in the way I expected it to...) -- CC

« previous php.general (#41553) next »