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

 

 

Link to comment
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
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
Share on other sites

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.