What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » MySQL and PHP - using 2 tables in one query?

MySQL and PHP - using 2 tables in one query?
Author: Message:
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
31 / Male / Flag
Joined: Jul 2006
O.P. MySQL and PHP - using 2 tables in one query?
Okay, first of all, I am not even sure if this is possible, but what I am trying to do is:

I have two tables, Table A that stores just SteamID, with some other fields, and then, another Table B that stores Player name, SteamID and then some other fields.

What I currently have setup is some PHP to query Table A with an entered SteamID, to output all the other fields.

What I am looking to do, is allow someone to enter a name, this then finds the SteamID corresponding to that name in Table B, then searches Table A using this steamid.

I use the following PHP to query Table A at the moment:

PHP code:
 
<?php echo '<table class="sortable2" id="reports" name="reports">
<tr>
<th><font face="Arial, Helvetica, sans-serif" size="3">SteamID</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="3">VIP</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="3">Upgrade 1</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="3">Upgrade 2</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="3">Upgrade 3</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="3">Upgrade 4</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="3">Upgrade Points</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="3">Zombie Upgrade Points</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="3">Bonus Upgrade Points</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="3">Player Model</font></th>
</tr>'
;
?>
 
<?
mysql_connect("censored","censored","censored");
mysql_select_db("servers");
$search=$_POST["search"];
$result = mysql_query("SELECT * FROM upgrades WHERE steamid LIKE '%$search%'");
while($r=mysql_fetch_array($result))
{      
   $steam=$r["steamid"];
   $dt=$r["vip"];
   $pn=$r["playerupgrade1"];
   $rs=$r["playerupgrade2"];
   $rp=$r["playerupgrade3"];
   $se=$r["playerupgrade4"];
   $sns=$r["upgradepoints"];
   $snr=$r["zombieupgradepoints"];
   $snp=$r["bonusupgradepoints"];
   $sn=$r["playermodel"];
   
   echo "<tr><td>$steam</td><td>$dt</td><td>$pn</td><td>$rs</td><td>$rp</td><td>$se</td><td>$sns</td><td>$snr</td><td>$snp</td></tr>";
}
 
?>
</table>

With the following html form:

HTML code:
<form method="post" action="search.php">
<input type="text" value="Enter SteamID" name="search" size=25 maxlength=25>
<input type="Submit" name="Search" value="Search">
</form>


This post was edited on 01-17-2010 at 01:38 AM by Jimbo.
01-17-2010 01:32 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
MySQL and PHP - using 2 tables in one query? - by Jimbo on 01-17-2010 at 01:32 AM
RE: MySQL and PHP - using 2 tables in one query? - by MeEtc on 01-17-2010 at 03:05 AM
RE: MySQL and PHP - using 2 tables in one query? - by Jimbo on 01-17-2010 at 01:51 PM
RE: MySQL and PHP - using 2 tables in one query? - by stoshrocket on 01-17-2010 at 04:41 PM
RE: MySQL and PHP - using 2 tables in one query? - by Jimbo on 01-17-2010 at 04:48 PM
RE: MySQL and PHP - using 2 tables in one query? - by stoshrocket on 01-17-2010 at 05:23 PM
RE: MySQL and PHP - using 2 tables in one query? - by Jimbo on 01-17-2010 at 05:33 PM
RE: MySQL and PHP - using 2 tables in one query? - by Adeptus on 01-17-2010 at 07:24 PM
RE: MySQL and PHP - using 2 tables in one query? - by Jimbo on 01-17-2010 at 07:33 PM
RE: MySQL and PHP - using 2 tables in one query? - by Chrissy on 01-17-2010 at 07:55 PM
RE: MySQL and PHP - using 2 tables in one query? - by Jimbo on 01-17-2010 at 07:57 PM
RE: MySQL and PHP - using 2 tables in one query? - by Chrissy on 01-17-2010 at 08:04 PM
RE: MySQL and PHP - using 2 tables in one query? - by Adeptus on 01-17-2010 at 08:13 PM
RE: MySQL and PHP - using 2 tables in one query? - by MeEtc on 01-17-2010 at 08:15 PM
RE: MySQL and PHP - using 2 tables in one query? - by Matti on 01-17-2010 at 08:19 PM
RE: MySQL and PHP - using 2 tables in one query? - by Jimbo on 01-17-2010 at 08:39 PM
RE: MySQL and PHP - using 2 tables in one query? - by Adeptus on 01-17-2010 at 08:55 PM
RE: MySQL and PHP - using 2 tables in one query? - by Jimbo on 01-17-2010 at 09:16 PM
RE: MySQL and PHP - using 2 tables in one query? - by Adeptus on 01-17-2010 at 09:22 PM
RE: MySQL and PHP - using 2 tables in one query? - by NanaFreak on 01-18-2010 at 01:49 AM
RE: MySQL and PHP - using 2 tables in one query? - by Jimbo on 01-18-2010 at 01:44 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On