Mutley Posted January 5, 2008 Share Posted January 5, 2008 Having an issue where I'm calling a function that contains an image and the image is showing outside of the table cell it is called into. Function is called "guidCheck"... Here is my function: <?php function guidCheck($guid_uid) { $sql = "SELECT game FROM pb_guid WHERE uid = '".$guid_uid."' AND guid_status = '1' ORDER BY game DESC"; $result = mysql_query($sql); if(mysql_num_rows($result)!=0) { //(1) while(list($game) = mysql_fetch_row($result)) { //(2) echo "<img src=\"NukeLadder/images/guid_games/$game.gif\" alt=\"GuID Approved\" /> "; } } ?> And the function where called: <?php $c .= " <tr> <td class='alt1'> <a href='".X1_publicgetfile."?".X1_linkactionoperator."=playerprofile&member=$row[name]'>$row[name]</a></td> <td class='alt2'>$maillink $msnlink $icqlink $aimlink $yimlink $weblink</td> <td class='alt1'>".date(X1_dateformat, $row['joindate'])."</td> <td class='alt2'>$extra1</td> <td class='alt2'>$extra2</td> <td class='alt2'>$extra3</td> <td class='alt2'>".guidCheck($rows_uid)."</td> </tr>"; ?> The function shows ABOVE the <table> tag, like it's not even in the <td> fields. The "$rows_uid" just calls a single mysql query result. Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/ Share on other sites More sharing options...
gerkintrigg Posted January 5, 2008 Share Posted January 5, 2008 it might be that one of the $extra variables has something in it which is ending the table code prematurely. I'd echo each variable without the table and see what they contain. Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431184 Share on other sites More sharing options...
Mutley Posted January 5, 2008 Author Share Posted January 5, 2008 They just echo fields from the database, no table formatting. I can replace my function to just text and the text shows where it should fine. Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431188 Share on other sites More sharing options...
Ken2k7 Posted January 5, 2008 Share Posted January 5, 2008 Try: <?php $c .= " <tr> <td class='alt1'> <a href='".X1_publicgetfile."?".X1_linkactionoperator."=playerprofile&member={$row['name']}>{$row['name']}</a></td> <td class='alt2'>$maillink $msnlink $icqlink $aimlink $yimlink $weblink</td> <td class='alt1'>".date(X1_dateformat, $row['joindate'])."</td> <td class='alt2'>$extra1</td> <td class='alt2'>$extra2</td> <td class='alt2'>$extra3</td> <td class='alt2'>".guidCheck($rows_uid)."</td> </tr>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431198 Share on other sites More sharing options...
Mutley Posted January 5, 2008 Author Share Posted January 5, 2008 Didn't work, I just looked again and realized the table field the function should show in isn't there. As if the <td></td> tags for the function aren't working. Is there another way I could do this without using a function maybe? Is there a way to pause the variable and insert the SQL query that's in the function into the $c variable? Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431259 Share on other sites More sharing options...
Ken2k7 Posted January 5, 2008 Share Posted January 5, 2008 Didn't work, I just looked again and realized the table field the function should show in isn't there. As if the <td></td> tags for the function aren't working. Is there another way I could do this without using a function maybe? Is there a way to pause the variable and insert the SQL query that's in the function into the $c variable? Could you post the entire code or more of it? Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431263 Share on other sites More sharing options...
Mutley Posted January 5, 2008 Author Share Posted January 5, 2008 Here's most of it: <?php $panstyle = ( $panel=="roster" ) ? '' : 'style="display:none"'; $c .=" <div class='panel' id='panel2' $panstyle> <table class='".X1plugin_teamprofiletable."' width='100%'> <thead class='".X1plugin_tablehead."'> <tr> <th>".XL_teamprofile_husername."</th> <th>".XL_teamprofile_hcontact."</th> <th>".XL_teamprofile_hjoindate."</th> <th>".X1_extraroster1."</th> <th>".X1_extraroster2."</th> <th>".X1_extraroster3."</th> <th>GuID Approved Games</th> </tr> </thead> <tbody class='".X1plugin_tablebody."'>"; $rows = $xdb->GetAll("SELECT * FROM ".X1_prefix.X1_DB_teamroster." WHERE team_id=".$xdb->qstr($row['team_id'])." ORDER BY ".X1_rostersort); if($rows){ foreach($rows As $row){ list ($maillink, $msnlink, $icqlink, $aimlink, $yimlink, $weblink, $avatar) = contacticons($row["name"]); $extra1 = (empty($row['extra1'])) ? "n/a" : $row['extra1']; $extra2 = (empty($row['extra2'])) ? "n/a" : $row['extra2']; $extra3 = (empty($row['extra3'])) ? "n/a" : $row['extra3']; $c .= " <tr> <td class='alt1'> <a href='".X1_publicgetfile."?".X1_linkactionoperator."=playerprofile&member={$row['name']}>{$row['name']}</a></td> <td class='alt2'>$maillink $msnlink $icqlink $aimlink $yimlink $weblink</td> <td class='alt1'>".date(X1_dateformat, $row['joindate'])."</td> <td class='alt2'>$extra1</td> <td class='alt2'>$extra2</td> <td class='alt2'>$extra3</td> <td class='alt2'>".guidCheck($row['uid'])."</td> </tr>"; } }else{ $c .= "<tr> <td colspan='6'>".XL_teamprofile_nomembers."</td> </tr>"; } $c .= " </tbody> <tfoot class='".X1plugin_tablefoot."'> <tr> <td colspan='6'> </td> </tr> </tfoot>"; $c .= "</table> </div>"; $panstyle = ( $panel=="events" ) ? '' : 'style="display:none"'; $c .=" <div class='panel' id='panel3' $panstyle> <table class='".X1plugin_teamprofiletable."' width='100%'> <thead class='".X1plugin_tablehead."'> <tr> <th>".XL_teamprofile_hid."</th> <th>".XL_teamprofile_hevent."</th> <th>".XL_teamprofile_tgp."</th> <th>".XL_teamprofile_tw."</th> <th>".XL_teamprofile_tl."</th> <th>".XL_teamprofile_td."</th> <th>".XL_teamprofile_tp."</th> <th>".XL_teamprofile_gp."</th> <th>".XL_teamprofile_w."</th> <th>".XL_teamprofile_l."</th> <th>".XL_teamprofile_d."</th> <th>".XL_teamprofile_p."</th> </tr> </thead> <tbody class='".X1plugin_tablebody."'>"; $rows= $xdb->GetAll("SELECT * FROM ".X1_prefix.X1_DB_teamsevents." WHERE team_id=".$xdb->qstr($row['team_id'])." ORDER BY ladder_id ASC"); if($rows) { foreach($rows AS $row){ $ladder=$xdb->GetRow("SELECT title FROM ".X1_prefix.X1_DB_events." WHERE sid=".$xdb->qstr($row['ladder_id'])); $c .=" <tr> <td class='alt1'><a href='".X1_publicgetfile."?".X1_linkactionoperator."=ladderhome&sid=$row[ladder_id]'> $row[ladder_id]</a></td> <td class='alt2'><a href='".X1_publicgetfile."?".X1_linkactionoperator."=ladderhome&sid=$row[ladder_id]'> $ladder[title]</a></td> <td class='alt2'>$row[totalgames]</td> <td class='alt1'>$row[totalwins]</td> <td class='alt2'>$row[totallosses]</td> <td class='alt2'>$row[totaldraws]</td> <td class='alt1'>$row[totalpoints]</td> <td class='alt1'>$row[games]</td> <td class='alt2'>$row[wins]</td> <td class='alt1'>$row[losses]</td> <td class='alt1'>$row[draws]</td> <td class='alt1'>$row[points]</td> </tr>"; } }else{ $c .= "<tr> <td colspan='13'>".XL_teamprofile_noevents."</td> </tr>"; } $c .= " </tbody> <tfoot class='".X1plugin_tablefoot."'> <tr> <td colspan='13'> </td> </tr> </tfoot>"; $c .= "</table> </div>"; $panstyle = ( $panel=="history" ) ? '' : 'style="display:none"'; $c .=" <div class='panel' id='panel4' $panstyle> <table class='".X1plugin_teamprofiletable."' width='100%'> <thead class='".X1plugin_tablehead."'> <tr> <th>".XL_teamprofile_hid."</th> <th>".XL_teamprofile_hevent."</th> <th>".XL_teamprofile_hwinner."</th> <th>".XL_teamprofile_hloser."</th> <th>".XL_teamprofile_hdate."</th> <th>".XL_teamprofile_hdetails."</th> </tr> </thead> <tbody class='".X1plugin_tablebody."'>"; $rows = $xdb->GetAll(" SELECT * FROM ".X1_prefix.X1_DB_teamhistory." WHERE winner=".$xdb->qstr($_GET['teamname'])." OR loser=".$xdb->qstr($_GET['teamname'])." ORDER BY game_id DESC"); if($rows){ foreach($rows AS $row) { $event = $xdb->GetRow("select * from ".X1_prefix.X1_DB_events." where sid=".$xdb->qstr($row['laddername'])); $c .= " <form method='post' action='".X1_publicpostfile."' style='".X1_formstyle."'> <tr> <td class='alt1'>$row[game_id]</td> <td class='alt2'>$event[title]</td> <td class='alt1'>$row[winner]</td> <td class='alt2'>$row[loser]</td> <td class='alt1'>".date(X1_dateformat, $row['date'])."</td> <td class='alt2'> <input name='".X1_actionoperator."' type='hidden' value='matchdetails'> <input name='game_id' type='hidden' value='$row[game_id]'> <input name='ladder' type='hidden' value='$row[laddername]'> <input type='Submit' name='Submit' value='".XL_teamprofile_details."' > </td> </tr> </form>"; } }else{ $c .="<tr> <td colspan='6'>".XL_teamprofile_nomatches."</td> </tr>"; } $c .= " </tbody> <tfoot class='".X1plugin_tablefoot."'> <tr> <td colspan='6'> </td> </tr> </tfoot> </table> </div>"; return X1plugin_output($c); } ?> I don't know why but the script (I didn't do just modifying it) puts everything in the $c variable then returns it at the end. Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431269 Share on other sites More sharing options...
Mutley Posted January 5, 2008 Author Share Posted January 5, 2008 Just reverted it back from the one Ken did, The table structure is actually fine. Just the image in wrong place. Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431271 Share on other sites More sharing options...
Ken2k7 Posted January 5, 2008 Share Posted January 5, 2008 You have to be careful when you insert a database field into a string. You need to use { } around it. Like {$row['something']}. Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431274 Share on other sites More sharing options...
Mutley Posted January 5, 2008 Author Share Posted January 5, 2008 I think the issue is with the function, is there no alternative way of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431430 Share on other sites More sharing options...
Mutley Posted January 6, 2008 Author Share Posted January 6, 2008 Friendly bump. Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431777 Share on other sites More sharing options...
sasa Posted January 6, 2008 Share Posted January 6, 2008 <?php function guidCheck($guid_uid) { $out = ''; $sql = "SELECT game FROM pb_guid WHERE uid = '".$guid_uid."' AND guid_status = '1' ORDER BY game DESC"; $result = mysql_query($sql); if(mysql_num_rows($result)!=0) { //(1) while(list($game) = mysql_fetch_row($result)) { //(2) $out .= "<img src=\"NukeLadder/images/guid_games/$game.gif\" alt=\"GuID Approved\" /> "; } } return $out; ?> Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431786 Share on other sites More sharing options...
Mutley Posted January 6, 2008 Author Share Posted January 6, 2008 I guess there's a closed curly bracket after the return $out; No image shows though and no errors. Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431890 Share on other sites More sharing options...
redarrow Posted January 6, 2008 Share Posted January 6, 2008 it your path or database colunm the function run's correctly as provided <?php $game="http://www.google.co.uk/intl/en_uk/images/logo"; $out= "<img src=\"$game.gif \" alt=\"GuID Approved\" /> "; echo $out; ?> echo the select out <?php function guidCheck($guid_uid) { $out = ''; $sql = "SELECT game FROM pb_guid WHERE uid = '".$guid_uid."' AND guid_status = '1' ORDER BY game DESC"; echo $sql;//debug mode........... $result = mysql_query($sql); if(mysql_num_rows($result)!=0) { //(1) while(list($game) = mysql_fetch_row($result)) { //(2) $out .= "<img src=\"NukeLadder/images/guid_games/$game.gif\" alt=\"GuID Approved\" /> "; } } return $out; ?> Quote Link to comment https://forums.phpfreaks.com/topic/84624-solved-php-function-showing-image-at-incorrect-location/#findComment-431903 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.