Look at the following code :
<?php
function getmangainfo($teamname)
{
$rValue = "";
$lValue = "";
$query = ("SELECT pic, mn_title FROM table Where mn_team LIKE '%" . $teamname . "%' Limit 0,4 ");
$row_data = mysql_query($query);
while ($row_data = mysql_fetch_array($row_data)) {
$rValue = $row['pic'];
$lValue = $row['mn_title'];
return "<a class='linksrepeated' href='" . $ABSPATH . "/" . $lValue . "/'> <img src='" . $rValue . "'/></a>";
}
}
this function is not returning anything! I am thinking it is because that the return statement is inside the while loop. I tried many things hoping it will return the 4 results but nothing happened. the SQL query works 100%. the problem is with my function. please let me know what is wrong and how to fix it.
change the
$row_datato$rowin yourwhilestatementbecause as I see the codes inside the
whileyou get your data as
$rowbut your inwhilestatement is$row_datathe problem is not on the
whileloop as the execution reaches thereturnstatement, the execution pointer will exit the function(of course in thewhilestatement)but for me to make your code cleaner as i see you expect only one row in return pull out the
returnstatement on your whilebut as the others says that you expect 4 row returns you can create a variable that would store all the returns in a single string
reference:
http://php.net/manual/en/function.mysql-fetch-array.php