Jump to content

Simple $_GET['id'];


dean7

Recommended Posts

Hey all, I'm working on a Market script for my game site but I've came across an Error..

 

Market.php:

 

<?php
session_start();

include ("includes/config.php");
include ("includes/functions.php");
logincheck();

// Grab the Users information.
$userinfo = "SELECT * FROM users WHERE username = '$username' LIMIT 1";
$userinfos = mysql_query($userinfo) or die ("Error in Query: Line 11" . mysql_error());
$fetchuser = mysql_fetch_object($userinfos);

// Grab the users Garage so they can add Cars onto the Market..
$usergarage = "SELECT * FROM garage WHERE owner = '$username' LIMIT 1";
$usergarages = mysql_query($usergarage) or die ("Error in Query: Line 17" . mysql_error());
$garageuser = mysql_fetch_object($usergarages);

// If they want to view the Cars stats:
if (strip_tags($_GET['vcstats'])){
$vcstats = strip_tags($_GET['vcstats']);

$marketqu = "SELECT * FROM market WHERE type = 'car'";
	$doqut = mysql_query($marketqu) or die ("Error in Query: Line 186: " . mysql_error());
		$objmarket = mysql_fetch_object($doqut);

				$caridfrommarket = $objmarket->carid;

$getthecar = "SELECT * FROM garage WHERE id='$caridfrommarket' LIMIT 1";
$carinfo = mysql_query($getthecar) or die ("Error in Query: Line 192 " . mysql_error());
	$carstats = mysql_fetch_object($carinfo);

$cid = $carstats->id;
$mph = $carstats->mph;
$fuel = $carstats->fuel;
$value = $carstats->value;
$currentowner = $carstats->owner;
$nameofcar = $carstats->car;
$miles = $carstats->miles;
$pic = $carstats->pic;
// Lets show the Stats
$nos = $carstats->nos;
$engine = $carstats->engine;
$transmission = $carstats->transmission;
$exhaust = $carstats->exhaust;
$breaks = $carstats->brakes;
$suspension = $carstats->suspension;
// Accessiours side
$body = $carstats->body;
$interior = $carstats->interior;
$amp = $carstats->amp;
$alloys = $carstats->alloys;
$neons = $carstats->neons;
$taillights = $carstats->taillights;

// Showing the Table in which it will display the Car Information on.

echo ("<table width='50%' cellpadding='0' cellspacing='0' border='1' align='center' class='table'>
	<tr>
		<td class='header' align='center' colspan='4'>".$nameofcar." (".$cid.")</td>
	</tr>
	<tr>
		<td colspan='4' align='center'><img src='".$pic."'></img> </td>
	</tr>
	<tr>
		<td class='omg' colspan='4'>Performance</td>
	</tr>
	<tr>
		<td>Nos:</td><td>".$nos."</td><td>Engine:</td><td>".$engine."</td>
	</tr>
	<tr>
		<td>Transmission:</td><td>".$transmission."</td><td>Exhaust:</td><td>".$exhaust."</td>
	</tr>
		<td>Breaks:</td><td>".$breaks."</td><td>Suspension:</td><td>".$suspension."</td>
	</tr>
	<tr>
		<td colspan='4' class='omg'>Accessorys:</td>
	</tr>
	<tr>
		<td>Body:</td><td>".$body."</td><td>Interior:</td><td>".$interior."</td>
	</tr>
	<tr>
		<td>Amp:</td><td>".$amp."</td><td>Alloys:</td><td>".$alloys."</td>
	</tr>	
	<tr>
		<td>Neons:</td><td>".$neons."</td><td>Taillights:</td><td>".$taillights."</td>
	</tr>			
	<tr>
		<td>Miles:</td><td>".number_format($miles)."</td><td>Value:</td><td>".$value."</td>
	</tr>
	<tr>
		<td>Fuel:</td><td>".$fuel."</td><td>MPH:</td><td>".$mph."</td>
	</tr>
	<tr>
		<td class='omg'>Owner:</td><td class='omg'><a href='profile.php?viewuser=".$currentowner."'>".$currentowner."</a></td><td class='omg'>Worth:</td><td class='omg'>£".number_format($value)."</td>
	</tr>
	</table>
	<br />");

// Continue soon, lets get the things showing like the Table first!		
}
?>
<form action="" method="GET" name="TheForm">
				<table width="50%" cellpadding="0" cellspacing="0" border="1" align="center" class="table">
				<tr>
					<td class="header" align="center" colspan="5">Cars For Sale</td>
				</tr>
				<tr>
					<td>Car Name:</td><td>View Stats:</td><td>Price:</td><td>Buy It Now:</td><td>Cancle</td>
				<tr>
<?php
$carsforsale = mysql_query ("SELECT * FROM market WHERE type = 'car'") or trigger_error ("Error in Query: 329 Line " . mysql_error());
while ($cfs = mysql_fetch_object($carsforsale)){
$number = mysql_num_rows($carsforsale);
$priceofauc = $cfs->startingprice;
	// An seller of the car:
		if ($username == $cfs->owner){
			$calowner = "<a href='?cauction=$cfs->id'>Cancle Auction</a>";

		}
$newid = $cfs->carid;
// Lets attempt to get the Cars name rather than the ID.
	$carnameis = "SELECT * FROM garage WHERE id = '$newid'";
		$namecar = mysql_query($carnameis) or die ("Error in Query: Line 255 " . mysql_error());
			$aye = mysql_fetch_object($namecar);		

		$Testingthis = $cfs->carid;
echo ('<td>'.$aye->car.'</td><td><a href="?vcstats='.$aye->id.'">View Stats</a></td><td>£'.number_format($priceofauc).'</td><td><a href="?buyitnow='.$cfs->id.'">Buy It Now</a></td><td>'.$calowner.'</td></tr><tr>');
}
?>
    					</td>
				</tr>
			</table>
			</form>
			<br />

 

In that part of the code, I've tried coding it so when the click the link displaying the Car for sale it will show them the car stats , although... When they do click on the "View Stats" link it only displays the car stats which is on top of the list.

 

For Example:

 

Car Name: || View Stats: || Buy it now: || ID: || Cancle

----------------------------------------------------------------

Evo        : || ViewStats  || Buy it now  ||  1  ||  Cancle

Mini        : || ViewStats  || Buy it now  ||  2  ||  Cancle

 

So on that example with my code working how it is now it would only show the Stats for the Evo which has the ID of 1 even if the Mini (ID 2) is clicked.

 

Is there something I've done wrong in my code which is making it only show the top cars stats?

 

Thanks for any help given :)

Link to comment
Share on other sites

open php my admin then click on your table then export the table as SQL then open the .sql and copy and paste it in your reply (this way i can run the code and get the error).

Not being funny or nothing , but If I give you the Tables to the code and you find the Error it isn't really helping me learn what Error I have and how you found it.

Link to comment
Share on other sites

What exactly have you done to troubleshoot the problem? Is the link being produced correctly with the correct id value? If so, then the only relevant code would be the code that is executed when the link is clicked and operates on the get parameter from the link. Posting hundreds of lines of code that isn't even relevant to the problem isn't going to get many replies.

 

Also, you posted the code using the


bbcode tags. That messes up the white-space in the code (every tab gets a new-line added to it, resulting in multi-hundreds of lines of code), so no one will likely copy/paste it to even search through it to try and find the relevant code. Use the


bbcode tags when posting code.

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.