Jump to content

[SOLVED] Need Help with Making a URL in PHP that has a MYSQL variable as part of the URL


XtacY

Recommended Posts

Okay so the title explains it all. I need some help as I am decent with HTML but clueless with PHP.

 

Please see

 

http://xtacygaming.com/index.php?p=profile&pid=10

 

Under the email address

 

[email protected]

 

you will see

 

Steam ID:     ASFUSION

 

I want the Steam ID (in this case for this user, ASFUSION) to be a clickable url that will open a new window to

 

http://steamcommunity.com/id/{ID OF THE SPECIFIC USER}

 

in this case I want it to be

 

http://steamcommunity.com/id/ASFusion

 

My problem is, the end of the URL has to change for every different member who has a profile in the roster (naturally)...and I have absolutely no idea how to do this.

 

Here is the line of code from the profile.inc.php file that I assume needs to be modified

 

<td><b>Steam ID:</b></td><td colspan="2"><? echo (empty($r['userid'])) ? "<i>none</i>" : $r['userid']; ?></td>

 

Should you need any additional information please email me at: [email protected]

 

THANK YOU SO MUCH FOR YOUR HELP! ;D

Maybe this'll help you...

 

Replace this line of code...

<td><b>Steam ID:</b></td><td colspan="2"><? echo (empty($r['userid'])) ? "<i>none</i>" : $r['userid']; ?></td>

with...

<td><b>Steam ID:</b></td><td colspan="2"><? if (empty($r['userid'])){ echo "<i>none</i>"; }else{ echo "<a href=\"http://steamcommunity.com/id/$r['userid']\">$r['userid']</a>"; } ?></td>

 

See what that does for you ;)

Unfortuantely I get the following error (and it makes half the site dissapear lmfao):

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /homepages/12/d238972922/htdocs/xtacyclan/incs/profile.inc.php on line 31

 

Have another go?

 

Thanks! ;D

admin_roster.inc.php

<?
if(!isset($_SESSION['admin'])) { include("incs/admin_login.inc.php"); exit; }
?>
<script language="Javascript" type="text/javascript">
function confirmDelete(url) {
if(confirm('Are you sure you want to delete this profile? After you delete it recovery will be impossible!')) {
	document.location = url;
	return true;
} else {
	return false;
}
}

function togglePic() {
st = document.roster.picture.disabled;
if(st == false) {
	document.roster.picture.disabled = true;
} else {
	document.roster.picture.disabled = false;
}
}
</script>
<? if(isset($_GET['e'])) { ?>
<h2 class="blank"><span>!</span></h2>
<div class="cbox" style="text-align: center;">
<div>
	<?
	switch($_GET['e']) {
		case 1: echo "Error: No existing table found. Did you try to mess with the code?"; break;
		case 2: echo "Error: Invalid table specified. Did you try to mess with the code?"; break;
		case 3: echo "Profile successfully added!"; break;
		case 4: echo "Profile successfully edited!"; break;
		case 5: echo "Profile successfully deleted!"; break;
		case 6: echo "Invalid file-type! The uploader supports the following file extensions: jpg, jpeg, gif, and png. Please convert your file to one of these extensions and re-upload to continue!"; break;
		case 7: echo "There was an error uploading the image. Please try again. If the problem persits, make sure that the permissions for the <I>roster</I> folder (located in the images folder) and the <I>thumbs</I> folder are set to 777."; break;
	}
	?>
</div>
</div>
<? } ?>
<h2 class="main"><span>Admin</span></h2>
<div class="cbox">
<div>
	<? if(!isset($_GET['action'])) { ?>

		<table style="margin: auto;">
		<tr>
			<td><a href="index.php?p=admin_roster&action=add"><img src="images/icons/add.gif" alt="Add Profile" border="0" /></a></td><td><a href="index.php?p=admin_roster&action=add">Add Profile</a></td>
		</tr>
		<tr>
			<td><a href="index.php?p=admin"><img src="images/icons/homepage.gif" alt="Back" border="0" /></a></td><td><a href="index.php?p=admin">Go back</a></td>
		</tr>
		<tr>
			<td><a href="actions/logout.php"><img src="images/icons/logoutmini.gif" alt="Logout" border="0" /></a></td><td><a href="actions/logout.php">Logout</a></td>
		</tr>
		</table>
		<br />
		<table border="0" width="100%" cellspacing="0">
		<tr>
			<td class="listTitle">Pic</td><td class="listTitle">Nick</td><td class="listTitle" width="25">Age</td><td class="listTitle" style="text-align: left;">Team</td><td class="listTitle" style="text-align: center;">action</td>
		</tr>
		<?
		$q = mysql_query("SELECT * FROM `roster` ORDER BY id DESC");
		$entries = mysql_num_rows($q);
		if($entries) {
			$altr = " class='row2'";
			while($r = mysql_fetch_array($q)) {
				if($altr == " class='row2'") { $altr = " class='row1'"; } else { $altr = " class='row2'"; }
				if(file_exists("images/roster/thumbs/".$r['id'].$r['filetype'])) {
					$pic = "images/roster/thumbs/".$r['id'].$r['filetype'];
				} else {
					$pic = "images/roster/thumbs/blankpic.jpg";
				} 
				?>
				<tr<?=$altr?>>
					<td><img src="<?=$pic?>" width="64" height="64" alt="" /></td><td><?=$r['nickname']?></td><td><?=$r['age']?></td><td><?=$r['team']?></td><td style="text-align: center;"><a href="index.php?p=admin_roster&action=edit&id=<?=$r['id']?>"><img src="images/icons/edit.gif" alt="Edit" border="0" /></a> <a href="javascript:;" onclick="confirmDelete('actions/delete.php?id=<?=$r['id']?>&table=roster');"><img src="images/icons/delete.gif" alt="Delete" border="0" /></a></td>
				</tr>
				<?
			}
		} else {
			?>
			<tr>
				<td colspan="4">There are no players on the roster yet! Please <a href="index.php?p=admin_roster&action=add">add</a> a profile!</td>
			</tr>
			<?			
		}
		?>
		</table>
	<? } else if($_GET['action'] == "add") { ?>
		Use the form below to add a profile to the roster:<br /><br />
		<form name="roster" enctype="multipart/form-data" action="actions/add.php" method="post">
		<input type="hidden" name="table" value="roster" />
		<table cellspacing="0" cellpadding="5">
		<tr>
			<td width="120" style="text-align: right;">Team:</td><td><input type="text" name="team" maxlength="25" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Name:</td><td><input type="text" name="name" maxlength="30" size="30" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Nickname:</td><td><input type="text" name="nickname" maxlength="25" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Age:</td><td><input type="text" name="age" maxlength="2" size="2" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Email:</td><td><input type="text" name="email" maxlength="200" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Steam ID:</td><td><input type="text" name="userid" maxlength="25" size="20" /></td>
		</tr>	
		<tr>
			<td style="text-align: right;">Location:</td><td><input type="text" name="location" maxlength="25" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Favorite Weapon:</td><td><input type="text" name="favweapon" maxlength="15" size="15" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Favorite Map:</td><td><input type="text" name="favmap" maxlength="15" size="15" /></td>
		</tr>
		<tr>
			<td colspan="2"><h3>Computer Specs:</h3></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Brand:</td><td><input type="text" name="brand" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">CPU:</td><td><input type="text" name="cpu" maxlength="50" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Motherboard:</td><td><input type="text" name="motherboard" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">RAM:</td><td><input type="text" name="ram" maxlength="50" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Video Card:</td><td><input type="text" name="videocard" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Sound Card:</td><td><input type="text" name="soundcard" maxlength="50" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Hard Drive:</td><td><input type="text" name="harddrive"  maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Case:</td><td><input type="text" name="case" maxlength="50" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Monitor:</td><td><input type="text" name="monitor" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Keyboard:</td><td><input type="text" name="keyboard" maxlength="50" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Mouse:</td><td><input type="text" name="mouse" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Mousepad:</td><td><input type="text" name="mousepad" maxlength="50" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Headphones:</td><td><input type="text" name="headphones" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td valign="top" style="text-align: right;">Picture:</td>
			<td style="text-align: center;">
				The uploader supports the following extensions: jpg, jpeg, gif, and png. Please keep your image around 150x150px, it will be resized!<br /><br />
				<input type="file" name="picture" size="25" /><br />
			</td>
		</tr>

		<tr class="row1">
			<td colspan="2" style="text-align:center"><input type="submit" value="Add Profile" /> <input type="reset" /> <input type="button" value="Cancel" onclick="history.go(-1);" /></td>
		</tr>
		</table>
		</form>
	<? } else if($_GET['action'] == "edit") {
		$q = mysql_query("SELECT * FROM `roster` WHERE id = '".$_GET['id']."';");
		$r = mysql_fetch_array($q);
		if($r['id'] != "") { 
		?>
		Use the form below to edit this profile:<br /><br />
		<form name="roster" enctype="multipart/form-data" action="actions/edit.php" method="post">
		<input type="hidden" name="table" value="roster" />
		<input type="hidden" name="id" value="<?=$_GET['id']?>" />
		<table cellspacing="0" cellpadding="5" style="margin: auto;">
		<tr>
			<td width="120" style="text-align: right;">Team:</td><td><input type="text" name="team" value="<?=str_replace('"','"',$r['team'])?>" maxlength="25" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Name:</td><td><input type="text" name="name" value="<?=str_replace('"','"',$r['name'])?>" maxlength="30" size="30" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Nickname:</td><td><input type="text" name="nickname" value="<?=str_replace('"','"',$r['nickname'])?>" maxlength="25" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Age:</td><td><input type="text" name="age" value="<?=str_replace('"','"',$r['age'])?>" maxlength="2" size="2" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Email:</td><td><input type="text" name="email" value="<?=str_replace('"','"',$r['email'])?>" maxlength="200" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Steam ID:</td><td><input type="text" name="userid" value="<?=str_replace('"','"',$r['userid'])?>" maxlength="20" size="20" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Location:</td><td><input type="text" name="location" value="<?=str_replace('"','"',$r['location'])?>" maxlength="25" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Favorite Weapon:</td><td><input type="text" name="favweapon" value="<?=str_replace('"','"',$r['favweapon'])?>" maxlength="15" size="15" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Favorite Map:</td><td><input type="text" name="favmap" value="<?=str_replace('"','"',$r['favmap'])?>" maxlength="15" size="15" /></td>
		</tr>
		<tr>
			<td colspan="2"><h3>Computer Specs:</h3></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Brand:</td><td><input type="text" name="brand" value="<?=str_replace('"','"',$r['brand'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">CPU:</td><td><input type="text" name="cpu" value="<?=str_replace('"','"',$r['cpu'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Motherboard:</td><td><input type="text" name="motherboard" value="<?=str_replace('"','"',$r['motherboard'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">RAM:</td><td><input type="text" name="ram" value="<?=str_replace('"','"',$r['ram'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Video Card:</td><td><input type="text" name="videocard" value="<?=str_replace('"','"',$r['videocard'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Sound Card:</td><td><input type="text" name="soundcard" value="<?=str_replace('"','"',$r['soundcard'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Hard Drive:</td><td><input type="text" name="harddrive" value="<?=str_replace('"','"',$r['harddrive'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Case:</td><td><input type="text" name="case" value="<?=str_replace('"','"',$r['ccase'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Monitor:</td><td><input type="text" name="monitor" value="<?=str_replace('"','"',$r['monitor'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Keyboard:</td><td><input type="text" name="keyboard" value="<?=str_replace('"','"',$r['keyboard'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Mouse:</td><td><input type="text" name="mouse" value="<?=str_replace('"','"',$r['mouse'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td style="text-align: right;">Mousepad:</td><td><input type="text" name="mousepad" value="<?=str_replace('"','"',$r['mousepad'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr class="row1">
			<td style="text-align: right;">Headphones:</td><td><input type="text" name="headphones" value="<?=str_replace('"','"',$r['headphones'])?>" maxlength="50" size="25" /></td>
		</tr>
		<tr>
			<td valign="top" style="text-align: right;">Picture:</td>
			<td style="text-align: center;">
				<? if(file_exists("images/roster/".$r['id'].$r['filetype'])) {
					$pic = "images/roster/".$r['id'].$r['filetype'];
				} else {
					$pic = "images/roster/blankpic.jpg";
				} ?>
				The uploader supports the following extensions: jpg, jpeg, gif, and png. Please keep your image around 150x150px, it will be resized!<br /><br />
				<img src="<?=$pic?>" width="150" height="150" alt="" /><br />
				<input type="file" name="picture" size="25" /><br /><br />
				<? if($pic != "images/roster/blankpic.jpg") { ?><input type="checkbox" id="nopic" name="nopic" onclick="togglePic();" /> <label for="nopic">Reset to default picture</label><? } ?>
			</td>
		</tr>

		<tr class="row1">
			<td colspan="2" style="text-align: center;"><input type="submit" value="Edit Profile" /> <input type="reset" /> <input type="button" value="Cancel" onclick="history.go(-1);" /></td>
		</tr>
		</table>
		</form>
		<? } else { ?>
		Invalid id!<br /><br />
		<table style="margin: auto;">
		<tr>
			<td><a href="index.php?p=admin_roster&action=add"><img src="images/icons/add.gif" alt="Add" border="0" /></a></td><td><a href="index.php?p=admin_roster&action=add">Add Profile</a></td>
		</tr>
		<tr>
			<td><a href="index.php?p=admin_roster"><img src="images/icons/homepage.gif" alt="Go Back" border="0" /></a></td><td><a href="index.php?p=admin_roster">Maintain Roster</a></td>
		</tr>
		<tr>
			<td><a href="index.php?p=admin"><img src="images/icons/homepage.gif" alt="Go Back" border="0" /></a></td><td><a href="index.php?p=admin">Back to ACP Home</a></td>
		</tr>
		<tr>
			<td><a href="actions/logout.php"><img src="images/icons/logoutmini.gif" alt="Logout" border="0" /></a></td><td><a href="actions/logout.php">Logout</a></td>
		</tr>
		</table>
		<? } ?>
	<? } ?>
</div>
</div>

 

Thanks for your help! ;D

Yep, totally WRONG script...

 

<----- Idiot... ::)

 

Here's the CORRECT ONE... :P

 

profile.inc.php

<h2 class="main"><span>Roster</span></h2>
<div class="cbox roster">
<div>
	<?
	$error = 0;
	$id = $_GET['pid'];
	if(is_numeric($id)) {
		$q = mysql_query("SELECT * FROM `roster` WHERE id = '$id';");
		$r = mysql_fetch_array($q);
		if($r['id'] != "") {
			if(file_exists("images/roster/".$id.$r['filetype'])) {
				$pic = "images/roster/".$id.$r['filetype'];
			} else {
				$pic = "images/roster/blankpic.jpg";
			}
			?>
			<table cellspacing="0" class="profile">
			<tr>
				<td rowspan="6" width="150"><img src="<?=$pic?>" alt="<?=$id?>" width="150" height="145" /></td>
			</tr>
			<tr class="row1">
				<td><b>Name:</b></td><td colspan="2"><?=$r['name']?> a.k.a. "<?=$r['nickname']?>"</td>
			</tr>
			<tr>
				<td><b>Age:</b></td><td colspan="2"><?=$r['age']?></td>
			</tr>
			<tr class="row1">
				<td><b>Email:</b></td><td colspan="2"><a href="mailto:<?=$r['email']?>"><?=$r['email']?></a></td>
			</tr>
			<tr>
				<td><b>Steam ID:</b></td><td colspan="2"><? echo (empty($r['userid'])) ? "<i>none</i>" : $r['userid']; ?></td>
			</tr>
			<tr class="row1">
				<td><b>Location:</b></td><td colspan="2"><?=$r['location']?></td>
			</tr>
			<tr>
				<td><b>Favorite Weapon:</b></td><td colspan="2"><?=$r['favweapon']?></td>
			</tr>
			<tr class="row1">
				<td><b>Favorite Map:</b></td><td colspan="2"><?=$r['favmap']?></td>
			</tr>
			</table>
			<table cellspacing="0" class="profile">
			<tr>
				<td colspan="2"><h3>Computer Specs:</h3></td>
			</tr>
			<tr class="row1">
				<td width="100"><b>Brand:</b></td><td colspan="2"><?=$r['brand']?></td>
			</tr>
			<tr>
				<td><b>CPU:</b></td><td colspan="2"><?=$r['cpu']?></td>
			</tr>
			<tr class="row1">
				<td><b>Motherboard:</b></td><td colspan="2"><?=$r['motherboard']?></td>
			</tr>
			<tr>
				<td><b>RAM:</b></td><td colspan="2"><?=$r['ram']?></td>
			</tr>
			<tr class="row1">
				<td><b>Video Card:</b></td><td colspan="2"><?=$r['videocard']?></td>
			</tr>
			<tr>
				<td><b>Sound Card:</b></td><td colspan="2"><?=$r['soundcard']?></td>
			</tr>
			<tr class="row1">
				<td><b>Hard Drive:</b></td><td colspan="2"><?=$r['harddrive']?></td>
			</tr>
			<tr>
				<td><b>Case:</b></td><td colspan="2"><?=$r['ccase']?></td>
			</tr>
			<tr class="row1">
				<td><b>Monitor:</b></td><td colspan="2"><?=$r['monitor']?></td>
			</tr>
			<tr>
				<td><b>Keyboard:</b></td><td colspan="2"><?=$r['keyboard']?></td>
			</tr>
			<tr class="row1">
				<td><b>Mouse:</b></td><td colspan="2"><?=$r['mouse']?></td>
			</tr>
			<tr>
				<td><b>Mousepad:</b></td><td colspan="2"><?=$r['mousepad']?></td>
			</tr>
			<tr class="row1">
				<td><b>Headphones:</b></td><td colspan="2"><?=$r['headphones']?></td>
			</tr>
			</table>
			<?
		} else { $error = 1; }
	} else { $error = 1; }
	if($error == 1) {
	?>
		<p>Invalid ID!</p>
	<? 
	}
	?>

	<p><a href="index.php?p=roster">Back to Roster</a></p>

</div>
</div>

 

Thanks for your help! ;D

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.