Jump to content
MakeWebGames

Recommended Posts

Posted

Re: Need help with simple sql please

A complete lack of detail will almost certainly be met with a complete lack of a solution for you.

You haven't provided any SQL details, like what tables you're talking about, or what the queries are that are the problem.

We have no idea what your "index" or your "profile" deal is.

Please note the (None Game related) title of the parent forum, and thus I assume this has nothing to do with MCCODES.

Although the content of your post belies my assumption...

Posted

Re: Need help with simple sql please

index.php

<?php

/*-----------------------------------------------------

-- Blown City

-- A product of GoldenZero.Net

-- Copyright held 2007 by GoldenZero

-- E-mail: joshisthebest1ca[AT]msn[DOT]com

-----------------------------------------------------*/

$housequery=1;

include "globals.php";

if($_GET['action'] == "stealth")

{

if($_POST['stelth'] == 1)

{

$db->query("UPDATE users SET lastip_login='$IP',last_login=unix_timestamp(),stelth=0 WHERE userid={$ir['userid']}");

print "Stealth Turned Off!";

}

else

{

$db->query("UPDATE users SET lastip_login='$IP',stelth=1 WHERE userid={$ir['userid']}");

print "Stealth Turned On!";

}

}

if($_GET['action'] == "statussubmit")

{

$db->query("UPDATE users SET status='{$_POST['status']}' WHERE userid={$ir['userid']}");

print "Your status has been changed. Redirect in 1 second

<META HTTP-EQUIV=Refresh CONTENT='1;url=index.php'>";

}

if($_GET['action'] == "1")

{

$db->query("UPDATE users SET bgcolor='FFFFFF', tcolor='black' WHERE userid={$ir['userid']}");

}

if($_GET['action'] == "2")

{

$db->query("UPDATE users SET bgcolor='0000000', tcolor='white' WHERE userid={$ir['userid']}");

}

 

if($ir['hospital'])

{

$db->query("UPDATE users SET status='{$_POST['status']}' WHERE userid={$ir['userid']}");

print "Your In Surgery.

<META HTTP-EQUIV=Refresh CONTENT='0;url=hospital.php'>";

}

$exp=(int)($ir['exp']/$ir['exp_needed']*100);

if ( !$ir['married'] )

{

$marital="<font color='red'>No</font> [<a href=marital.php>Marital</a>]";

}

else

{

$k=mysql_query("SELECT username FROM users WHERE userid={$ir['married']}", $c);

$marital="".mysql_result($k,0,0)." ";

$marital.="[Manage]";

$mair=mysql_query("SELECT u.*, h.* FROM users u LEFT JOIN houses h ON h.hWILL=u.maxwill WHERE userid={$ir['married']}",$c);

$ms=mysql_fetch_array($mair);

}

if($ir['bguard'] >0)

{

print "

<font color='yellow'>NOTE:</font> Your Bodyguard is protecting you for {$ir['bguard']} more minutes.

";

}

$fbm=money_formatter($ir['bankmoney']);

$fcm=money_formatter($ir['cybermoney']);

print "<table width=100% border=0 cellspacing=3>

<td class=h colspan=5>Player Info</td>

<tr>

<td>Name: {$ir['username']}</td>

<td>Points: {$cm}</td>

<td>Level: {$ir['level']}</td>

<td>Exp: {$exp}%</td>

</tr>

<tr>

<td>Money: $fm</td>

<td>HP: {$ir['hp']}/{$ir['maxhp']}</td>

<td>Bank Money: {$fbm}</td>

<td>Cyber Money: {$fcm}</td>

</tr>

<tr>

<td>Busts: {$ir['busts']} Users</td>

<td>Bails: {$ir['bails']} Users</td>

<td>Busted: {$ir['busted']} Times</td>

<td>Jailed: {$ir['jailed']} Times</td>

</tr>

<tr>

<td>Property: {$ir['hNAME']}</td>

<td>Tax: <font color='red'>-\${$ir['hTAX']}</font></td>

<td>Married: $marital</td>

<td>Crimes: {$ir['crimes']}</td>

</tr></table>

";

$ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['IQ'];

$ir['strank']=get_rank($ir['strength'],'strength');

$ir['agirank']=get_rank($ir['agility'],'agility');

$ir['guarank']=get_rank($ir['guard'],'guard');

$ir['labrank']=get_rank($ir['labour'],'labour');

$ir['IQrank']=get_rank($ir['IQ'],'IQ');

$tsrank=get_rank($ts,'strength+agility+guard+labour+IQ');

$ir['strength']=number_format($ir['strength']);

$ir['agility']=number_format($ir['agility']);

$ir['guard']=number_format($ir['guard']);

$ir['labour']=number_format($ir['labour']);

$ir['IQ']=number_format($ir['IQ']);

$ts=number_format($ts);

print "

<table width=100% border=0 cellspacing=3>

<td class=h colspan=2>Stats Info</td></tr>

<tr>

<td>Strength: {$ir['strength']}

<td>speed: {$ir['agility']}

</tr>

<tr>

<td>defense: {$ir['guard']}

<td>Labour: {$ir['labour']}

</tr>

<tr>

<td>IQ: {$ir['IQ']}

<td>Total stats: {$ts}

</tr>

</table>

";

$awp=round($ir['attacks_won']/($ir['attacks_total'] > 0 ? $ir['attacks_total'] : 1)*100,2);

$alp=round($ir['attacks_lost']/($ir['attacks_total'] > 0 ? $ir['attacks_total'] : 1)*100,2);

$atp=round($ir['attacks_total']/($ir['total_total'] > 0 ? $ir['total_total'] : 1)*100,2);

$dwp=round($ir['defends_won']/($ir['defends_total'] > 0 ? $ir['defends_total'] : 1)*100,2);

$dlp=round($ir['defends_lost']/($ir['defends_total'] > 0 ? $ir['defends_total'] : 1)*100,2);

$dtp=round($ir['defends_total']/($ir['total_total'] > 0 ? $ir['total_total'] : 1)*100,2);

$twp=round($ir['total_won']/($ir['total_total'] > 0 ? $ir['total_total'] : 1)*100,2);

$tlp=round($ir['total_lost']/($ir['total_total'] > 0 ? $ir['total_total'] : 1)*100,2);

$bbb=$ir['attacks_won']+$ir['defends_won'];

print "

<table width=100% border=0 cellspacing=3>

<td class=h colspan=4>Attack Record [<u>VIEW ATTACK LOG</u>]</td></tr>

<tr>

<td>Attacking: </td>

<td>Won: <font color='green'>{$ir['attacks_won']}</font> ($awp%)</td>

<td>Lost: <font color='red'>{$ir['attacks_lost']}</font> ($alp%)</td>

<td>Total: <font color='green'>{$ir['attacks_total']}</font> ($atp%)</td> </tr>

<tr>

<td>Defending: </td>

<td>Won: <font color='green'>{$ir['defends_won']}</font> ($dwp%)</td>

<td>Lost: <font color='red'>{$ir['defends_lost']}</font> ($dlp%)</td>

<td>Total: <font color='green'>{$ir['defends_total']}</font> ($dtp%)</td>

</tr>

<tr>

<td>Both: </td>

<td>Won: <font color='green'>$bbb</font>($twp%)</td>

<td>Lost: <font color='red'>{$ir['total_lost']}</font> ($tlp%)</td>

<td>Grand Total: <font color='green'>{$ir['total_total']}</font> / Draw's: <font color='green'>{$ir['draws']}</font></td>

</tr>

</table>";

print "

<table width=100% border=0 cellspacing=3>

<td class=h colspan=4>Car Racing Record</td></tr>

<tr>

<td>Cars Owned: <font color='green'>{$ir['cars_owned']}</font></td>

<td>Cars Won: <font color='green'>{$ir['cars_won']}</font></td>

<td>Cars Lost: <font color='red'>{$ir['cars_lost']}</font></td>

<tr>

<td>Races Won: <font color='green'>{$ir['cars_races_won']}</font></td>

<td>Races Lost: <font color='red'>{$ir['cars_races_lost']}</font></td>

<td>Race Income: <font color='green'>{$ir['cars_races_income']}</font></td>

<tr>

<td>Races Sent Friendly: {$ir['cars_races_friendly']}</td>

<td>Races Sent Betted: {$ir['cars_races_betted']}</td>

<td>Races Sent: {$ir['cars_challs_sent']}</td>

<tr>

<td>Races Accepted: <font color='green'>{$ir['cars_challs_accpt']}</font></td>

<td></td>

<td>Races Declined: <font color='red'>{$ir['cars_challs_decln']}</font></td>

</tr>

</table>

";

if(isset($_POST['pn_update']))

{

$db->query("UPDATE users SET user_notepad='{$_POST['pn_update']}' WHERE userid={$ir['userid']}");

$ir['user_notepad']=stripslashes($_POST['pn_update']);

print "<hr width=75%>Personal Notepad Updated!";

}

print "<hr width=75%>Your Personal Notepad:<form action='index.php' method='post'>

<textarea rows='10' cols='75%' name='pn_update' class=textbox>".htmlspecialchars($ir['user_notepad'])."</textarea>

<input class='textbox' type='submit' value='Update Notes' /></form>";

 

/*

//merits

 

//stats

$ab=$db->query("SELECT * FROM userstats WHERE userid={$ir['userid']}");

$ab=$db->fetch_row($ab);

$ai=$db->query("SELECT * FROM merits WHERE mHAVE='strength10000' AND mUSERID={$ir['userid']}");

if($db->num_rows($ai)==0 && $ab['strength']>10000)

{

$db->query("UPDATE users SET merits=merits+1");

$mtext="Congratulations you recieved 1 merit for having more then 10,000 Strength!";

$db->query("INSERT INTO merits VALUES('','{$ir['userid']}','strength10000')");

$db->query("INSERT INTO events VALUES('',{$ir['userid']},UNIX_TIMESTAMP(),0,'$mtext')");

$db->query("UPDATE users SET new_events=new_events+1 WHERE userid={$ir['userid']}");

}

else

{

}

$bi=$db->query("SELECT * FROM merits WHERE mHAVE='agility10000' AND mUSERID={$ir['userid']}");

if($db->num_rows($bi)==0 && $ab['agility']>10000)

{

$db->query("UPDATE users SET merits=merits+1");

$mtext="Congratulations you recieved 1 merit for having more then 10,000 Speed!";

$db->query("INSERT INTO merits VALUES('','{$ir['userid']}','speed10000')");

$db->query("INSERT INTO events VALUES('',{$ir['userid']},UNIX_TIMESTAMP(),0,'$mtext')");

$db->query("UPDATE users SET new_events=new_events+1 WHERE userid={$ir['userid']}");

}

else

{

}

$ci=$db->query("SELECT * FROM merits WHERE mHAVE='guard10000' AND mUSERID={$ir['userid']}");

if($db->num_rows($ci)==0 && $ab['guard']>10000)

{

$db->query("UPDATE users SET merits=merits+1");

$mtext="Congratulations you recieved 1 merit for having more then 10,000 Defense!";

$db->query("INSERT INTO merits VALUES('','{$ir['userid']}','Defense10000')");

$db->query("INSERT INTO events VALUES('',{$ir['userid']},UNIX_TIMESTAMP(),0,'$mtext')");

$db->query("UPDATE users SET new_events=new_events+1 WHERE userid={$ir['userid']}");

}

else

{

}

$di=$db->query("SELECT * FROM merits WHERE mHAVE='labour10000' AND mUSERID={$ir['userid']}");

if($db->num_rows($di)==0 && $ab['labour']>10000)

{

$db->query("UPDATE users SET merits=merits+1");

$mtext="Congratulations you recieved 1 merit for having more then 10,000 Labour!";

$db->query("INSERT INTO merits VALUES('','{$ir['userid']}','labour10000')");

$db->query("INSERT INTO events VALUES('',{$ir['userid']},UNIX_TIMESTAMP(),0,'$mtext')");

$db->query("UPDATE users SET new_events=new_events+1 WHERE userid={$ir['userid']}");

}

else

{

}

//level

$ei=$db->query("SELECT * FROM merits WHERE mHAVE='level5' AND mUSERID={$ir['userid']}");

if($db->num_rows($ei)==0 && $ir['level']>4)

{

$db->query("UPDATE users SET merits=merits+1");

$mtext="Congratulations you recieved 1 merit for reaching level 5!!";

$db->query("INSERT INTO merits VALUES('','{$ir['userid']}','level5')");

$db->query("INSERT INTO events VALUES('',{$ir['userid']},UNIX_TIMESTAMP(),0,'$mtext')");

$db->query("UPDATE users SET new_events=new_events+1 WHERE userid={$ir['userid']}");

}

else

{

}

$ei=$db->query("SELECT * FROM merits WHERE mHAVE='level10' AND mUSERID={$ir['userid']}");

if($db->num_rows($ei)==0 && $ir['level']>9)

{

$db->query("UPDATE users SET merits=merits+1");

$mtext="Congratulations you recieved 1 merit for reaching level 10!!";

$db->query("INSERT INTO merits VALUES('','{$ir['userid']}','level10')");

$db->query("INSERT INTO events VALUES('',{$ir['userid']},UNIX_TIMESTAMP(),0,'$mtext')");

$db->query("UPDATE users SET new_events=new_events+1 WHERE userid={$ir['userid']}");

}

else

{

}

$fi=$db->query("SELECT * FROM merits WHERE mHAVE='level15' AND mUSERID={$ir['userid']}");

if($db->num_rows($fi)==0 && $ir['level']>14)

{

$db->query("UPDATE users SET merits=merits+1");

$mtext="Congratulations you recieved 1 merit for reaching level 15!!";

$db->query("INSERT INTO merits VALUES('','{$ir['userid']}','level15')");

$db->query("INSERT INTO events VALUES('',{$ir['userid']},UNIX_TIMESTAMP(),0,'$mtext')");

$db->query("UPDATE users SET new_events=new_events+1 WHERE userid={$ir['userid']}");

}

else

{

}

$gi=$db->query("SELECT * FROM merits WHERE mHAVE='level20' AND mUSERID={$ir['userid']}");

if($db->num_rows($gi)==0 && $ir['level']>19)

{

$db->query("UPDATE users SET merits=merits+1");

$mtext="Congratulations you recieved 1 merit for reaching level 20!!";

$db->query("INSERT INTO merits VALUES('','{$ir['userid']}','level20')");

$db->query("INSERT INTO events VALUES('',{$ir['userid']},UNIX_TIMESTAMP(),0,'$mtext')");

$db->query("UPDATE users SET new_events=new_events+1 WHERE userid={$ir['userid']}");

}

else

{

}

$hi=$db->query("SELECT * FROM merits WHERE mHAVE='level25' AND mUSERID={$ir['userid']}");

if($db->num_rows($hi)==0 && $ir['level']>24)

{

$db->query("UPDATE users SET merits=merits+1");

$mtext="Congratulations you recieved 1 merit for reaching level 25!!";

$db->query("INSERT INTO merits VALUES('','{$ir['userid']}','level25')");

$db->query("INSERT INTO events VALUES('',{$ir['userid']},UNIX_TIMESTAMP(),0,'$mtext')");

$db->query("UPDATE users SET new_events=new_events+1 WHERE userid={$ir['userid']}");

}

*/

$h->endpage();

?>

job.php

<?php

$jobquery=1;

include "globals.php";

$_GET['interview'] = abs((int) $_GET['interview']);

if(!$ir['job'])

{

if(!$_GET['interview'])

{

print "You do not yet have a job. A list of jobs is available below.

";

$q=$db->query("SELECT * FROM jobs");

while($r=$db->fetch_row($q))

{

print "<table width='500' cellspacing=1 class='table'><tr style='background:gray;'><th><center>{$r['jNAME']}</th></table><table width='500' cellspacing=1 class='table'><tr style='background:gray;'><td><center>{$r['jDESC']}</td></table><table width='500' cellspacing=1 class='table'><tr style='background:gray;'><td><center>Go to interview</td></table>

";

}

}

else

{

$q=$db->query("SELECT j.*,jr.* FROM jobs j LEFT JOIN jobranks jr ON j.jFIRST = jr.jrID WHERE j.jID={$_GET['interview']}");

$r=$db->fetch_row($q);

print "{$r['jOWNER']}: So {$ir['username']}, you were looking for a job with us?

{$ir['username']}: Yes please!

";

if($ir['strength'] >= $r['jrSTRN'] && $ir['labour'] >= $r['jrLABOURN'] && $ir['IQ'] >= $r['jrIQN'])

{

$db->query("UPDATE users SET job={$_GET['interview']},jobrank={$r['jrID']} WHERE userid=$userid;");

print "{$r['jOWNER']}: Okay {$ir['username']}, we're good to go, see you tomorrow.

{$ir['username']}: Thanks!

:)";

}

else

{

print "{$r['jOWNER']}: Sorry {$ir['username']}, you're not far enough in the game to work in this job. You'll need:";

if($ir['strength'] < $r['jrSTRN'])

{

$s=$r['jrSTRN']-$ir['strength'];

print " $s more strength, ";

}

if($ir['labour'] < $r['jrLABOURN'])

{

$s=$r['jrLABOURN']-$ir['labour'];

print " $s more labour, ";

}

if($ir['IQ'] < $r['jrIQN'])

{

$s=$r['jrIQN']-$ir['IQ'];

print " $s more IQ, ";

}

print "before you'll be able to work here!

:'(";

}

}

}

else

{

switch($_GET['action'])

{

case 'quit':

quit_job();

break;

case 'promote':

job_promote();

break;

default:

job_index();

break;

}

}

function job_index()

{

global $db, $ir,$c,$userid,$h;

print "<h3>Your Job</h3>

You currently work in the {$ir['jNAME']}! You receive \${$ir['jrPAY']} each day at 5pm!

You also receive {$ir['jrIQG']} IQ, {$ir['jrSTRG']} strength, and {$ir['jrLABOURG']} labour!

<table width=50% cellspacing=1 class='table'><tr><td>Strength: {$ir['strength']}</td><td>IQ: {$ir['IQ']}</td></tr><tr><td>Labour: {$ir['labour']}</td><td>Job Rank: {$ir['jrNAME']}</td></tr></table>

Job Ranks

<table width=75% cellspacing=1 class='table'><tr style='background:gray'><th>Title</th><th>Pay</th><th>Strength Reqd</th><th>IQ Reqd</th><th>Labour Reqd</th></tr>";

$q=$db->query("SELECT * FROM jobranks WHERE jrJOB={$ir['job']} ORDER BY jrPAY ASC;");

while($r=$db->fetch_row($q))

{

print "<tr><td>{$r['jrNAME']}</td><td>\${$r['jrPAY']}</td><td>{$r['jrSTRN']}</td><td>{$r['jrIQN']}</td><td>{$r['jrLABOURN']}</td></tr>";

}

print "</table>

> Try To Get Promoted

> Quit";

}

function job_promote()

{

global $db,$ir,$c,$userid,$h;

$q=$db->query("SELECT * FROM jobranks WHERE jrPAY > {$ir['jrPAY']} AND jrSTRN <= {$ir['strength']} AND jrLABOURN <= {$ir['labour']} AND jrIQN <= {$ir['IQ']} AND jrJOB = {$ir['job']} ORDER BY jrPAY DESC LIMIT 1");

if($db->num_rows($q) == 0)

{

print "Sorry, you cannot be promoted at this time.

> Back";

}

else

{

$r=$db->fetch_row($q);

$db->query("UPDATE users SET jobrank={$r['jrID']} WHERE userid=$userid");

print "Congrats, you have been promoted to {$r['jrNAME']}

> Back";

}

}

function quit_job()

{

global $db,$ir,$c,$userid,$h;

$db->query("UPDATE users SET job=0,jobrank=0 WHERE userid=$userid");

print "You have quit your job!

> Back";

}

$h->endpage();

?>

Posted

Re: Need help with simple sql please

no its cos in the syql db i put something and i need to change it but dunno wat to put so people arwent on my profile anymore

Posted

Re: Need help with simple sql please

OMFG, firecamp use CODE tags, to many people have allready said in diffrent topic's use damn code tags? dont know how to use?

Its simple..

[code ]

Some code here done! but without no spaces at the ends like i have done!

[/code ]

Posted

Re: Need help with simple sql please

 

LOL this is why I stay out of the MCCODES section.

Can't ya'll keep your crap over there?

LOL, im not trying to be nasty or anything i was saying use code tags i had to scroll all the way down of the page lol.

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.   Paste as plain text instead

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