Jump to content

[SOLVED] PHP Function showing image at incorrect location


Recommended Posts

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.

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>";

?>

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?

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?

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.

<?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;
?>

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;

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.