Jump to content

Function help


whiteboikyle

Recommended Posts

function GetMedals($username){
global $config;
$getNum = $config->query("SELECT * FROM `members` WHERE username = '$username'");
$getMedals = mysql_fetch_array($getNum);
$medals = $getMedals['award'];
$medalid = explode("[sep]", $medals);
foreach($medalid as $themedal) {
	die("--->".$themedal."<---");
	if($medal1 != "" AND ctype_digit($medal1)) {
		$getMedalInfo = $config->query("SELECT * FROM awards WHERE ID = '$medal'");
		$medalInfo = mysql_fetch_array($getMedalInfo);
		$medalname = $medalInfo['award_name'];
		$medaldesc = $medalInfo['description'];
		$dispmedals .= "<img src='image.php?id=$medal' onmouseover=\"return overlib('<br><br>\[".$medaldesc."\]', CAPTION,'".$medalname."', WIDTH, 400, BGCOLOR, '#1B428F', FGCOLOR, '#EEE9BF');\" onmouseout=\"return nd();\">&nbsp&nbsp";
	}

}
}

 

if i do that the die function comes out ----><---- so there is no values..

 

if i do

function GetMedals($username){
global $config;
$getNum = $config->query("SELECT * FROM `members` WHERE username = '$username'");
$getMedals = mysql_fetch_array($getNum);
$medals = $getMedals['award'];
die("--->".$medals."<---");
$medalid = explode("[sep]", $medals);
foreach($medalid as $themedal) {
	if($medal1 != "" AND ctype_digit($medal1)) {
		$getMedalInfo = $config->query("SELECT * FROM awards WHERE ID = '$medal'");
		$medalInfo = mysql_fetch_array($getMedalInfo);
		$medalname = $medalInfo['award_name'];
		$medaldesc = $medalInfo['description'];
		$dispmedals .= "<img src='image.php?id=$medal' onmouseover=\"return overlib('<br><br>\[".$medaldesc."\]', CAPTION,'".$medalname."', WIDTH, 400, BGCOLOR, '#1B428F', FGCOLOR, '#EEE9BF');\" onmouseout=\"return nd();\">&nbsp&nbsp";
	}

}
}

it echos ---->[sep]1[sep]<----

 

and if i do this

 

function GetMedals($username){
global $config;
$getNum = $config->query("SELECT * FROM `members` WHERE username = '$username'");
$getMedals = mysql_fetch_array($getNum);
$medals = $getMedals['award'];
$medalid = explode("[sep]", $medals);
die("--->".$medalid."<---");
foreach($medalid as $themedal) {
	if($medal1 != "" AND ctype_digit($medal1)) {
		$getMedalInfo = $config->query("SELECT * FROM awards WHERE ID = '$medal'");
		$medalInfo = mysql_fetch_array($getMedalInfo);
		$medalname = $medalInfo['award_name'];
		$medaldesc = $medalInfo['description'];
		$dispmedals .= "<img src='image.php?id=$medal' onmouseover=\"return overlib('<br><br>\[".$medaldesc."\]', CAPTION,'".$medalname."', WIDTH, 400, BGCOLOR, '#1B428F', FGCOLOR, '#EEE9BF');\" onmouseout=\"return nd();\">&nbsp&nbsp";
	}

}
}

 

it echos ----->Array<-----

 

of course

 

 

but what i dont understand is why the foreach function is not working and not letting me echo out the Array's

 

Any help?

Link to comment
https://forums.phpfreaks.com/topic/116338-function-help/
Share on other sites

die() STOPS PHP execution of a script completely and prints the argument given to it. It's usually used for certain errors. It's an alias of exit().

 

Also, I see you're checking for $medal1, but I can't figure out where you initialized that variable at all.

 

 

 

duhh lol?

 

after

 

$dispmedals

 

add:

<?php
return $dispmedals;

I dont need to do that it wont echo if $medalsid wont work?

Link to comment
https://forums.phpfreaks.com/topic/116338-function-help/#findComment-598256
Share on other sites

die() STOPS PHP execution of a script completely and prints the argument given to it. It's usually used for certain errors. It's an alias of exit().

 

Also, I see you're checking for $medal1, but I can't figure out where you initialized that variable at all.

 

 

That doesn;t matter right now i am testing the foreach and its still echoing nothing so atm that doesn't matter

Link to comment
https://forums.phpfreaks.com/topic/116338-function-help/#findComment-598295
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.