Jump to content
Larry Ullman's Book Forums

Quick Query Re: Custom Function


Recommended Posts

Hiya,

 

Does anyone have any idea why this works fine:

 

$heading = 1;

 

$q = "SELECT * FROM btc_links WHERE heading = $heading";
$r = @mysqli_query($dbc, $q);
echo '<br/><p><ul>';
while ($row = mysqli_fetch_array($r, MYSQLI_NUM)){
echo '<li><a href="'.$row[2].'" target="blank">'.$row[3].'</a></li>';
}
echo '</ul></p><br/>';

 

YET... When I try to implement the same code with a function, I get no returns:

 

 

function get_link($heading){

$q = "SELECT * FROM btc_links WHERE heading = $heading";
$r = mysqli_query($dbc, $q);
echo '<br/><p><ul>';
while ($row = mysqli_fetch_array($r, MYSQLI_NUM)){
echo '<li><a href="'.$row[2].'" target="blank">'.$row[3].'</a></li>';
}
echo '</ul></p><br/>';

}// end of function

 

$heading = 1;

get_link($heading);

 

Hope someone can help, I've been trying to get it to work now for 3 hours!! grr!!!

 

p.s. very excited to be getting Larry's advanced php book through the post tomorrow!!

 

Nick

Link to comment
Share on other sites

 Share

×
×
  • Create New...