PHP - Moved: Multiplying Different Tables
This topic has been moved to MySQL Help.
http://www.phpfreaks.com/forums/index.php?topic=356714.0 Similar TutorialsHey guys, Not sure how to do this. The basic principle of what I want to do is: ounit1 number (members table) * ounit1 power (ounit table) ounit2 number (members table) * ounit2 power (ounit table) etc to unit12. The members table has the fields: username ounit1 ounit2 ounit3 ounit4 etc for the number of units. The Ounit table has the fields: Ounit (primary auto increase) opower and a few more that are not needed for this. So basically, it it possible to call data from two different tables and multiply it? So far I've got: Code: [Select] <?php $result = mysql_query("SELECT * FROM members WHERE Username='$_SESSION[Username]'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo '<b>Power</b><br />'; echo 'Offence: ' . $row[''] . ' <br />'; echo 'Defence: ' . $row[''] . ' <br />'; echo 'Power: ' . $row[''] . ' <br />'; } ?> I'm not sure how to call two tables at once. Any help would be great! Hello All, I'm working on this project, and everything was great but the last part is screwed. The procedure is supposed to be, you choose a hotel ---> book a room ---> confirm the booking and enter your details --> get redirected to paypal Everything is fine except for the confirmation part, where you're supposed to confirm the room you booked, number of nights and so on, all the info is right, except for the booked room, where it should show you the price for the room multiplied by the number of night... instead it gives "Total Price = 0" So anyone can give me an example on how can I make it show the result of multiplying 2 inputs by a user? Variables are $nrooms $newdate Here is the code I wrote Code: [Select] <?php $dbo = new DB(); $hotelObj = new hotelManager(); $hotelID = $_POST['hotelid']; $datein = $_POST['datein']; $dateout = $_POST['dateout']; $roomid = $_POST['roomid']; $roonsNo = $_POST['roomsNo']; $pr = $_POST['pr']; $_SESSION['hotelID'] = isset($_POST['hotelid']) ? $_POST['hotelid'] : $_SESSION['hotelID']; $_SESSION['datein'] = isset($_POST['datein']) ? $_POST['datein'] : $_SESSION['datein']; $_SESSION['dateout'] = isset($_POST['dateout']) ? $_POST['dateout'] : $_SESSION['dateout']; $_SESSION['roomid'] = isset($_POST['roomid']) ? $_POST['roomid'] : $_SESSION['roomid']; $_SESSION['nrooms'] = $_POST['nrooms']; $roomsarray = explode(",",$_POST['roomid']); $_SESSION['roomsarray'] = isset($_POST['roomid']) ? explode(",",$_POST['roomid']) : $_SESSION['roomsarray']; $roonsNo = $_POST['nrooms']; $_SESSION['nrooms'] = isset($_POST['roomnum']) ? explode(",",$_POST['roomnum']) : $_SESSION['nrooms']; /********************** hotels ************************/ /******************************************************/ echo "<table width=95% border=0 align=\"center\" cellpadding=\"0\" cellspacing=\"0\"> <tr><td valign=\"top\">"; echo "<table>"; echo "<tr>"; echo "<td valign=top>"; $imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='".$_SESSION['hotelID']."' LIMIT 1"); $image=mysql_fetch_array($imageqry); $imagename=$image['attachmentName']; echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>"; echo "</td>"; echo "<td>"; $result=$hotelObj->getHotelbyID($_SESSION['hotelID']); $row = mysql_fetch_array($result); echo "<table>"; echo "<tr><td valign=top><strong class=subtitle3>".$row['name']."</strong></td></tr>"; echo "<tr><td class=text valign=top>".$row['location']."</td></tr>"; echo "<tr><td class=text valign=top>check-in Date: ".$_SESSION['datein']."</td></tr>"; echo "<tr><td class=text valign=top>check-out Date: ".$_SESSION['dateout']."</td></tr>"; echo "<tr><td class=text valign=top>"; $newdate = $_SESSION['dateout'] - $_SESSION['datein']; $totalprice = $nrooms * $newdate; echo "</td></tr>"; echo "<tr><td class=text valign=top>Total Price: ".$totalprice."</td></tr>"; echo "</table>"; ?> hello, what I made is, each user joins in, he enters a recruitment ID of another user who recruited him, so I can calculate the commission of each. and It's working great but now what I want to do, is to make each user take comission of the people he recruited, and the people they recruited and so on here is my code for the first, don't know how to make the second Code: [Select] <?php $result = mysql_query("select * from users where id = '{$_GET['id']}'"); $row = @mysql_fetch_array($result); $rid = $row['id']; $sql = mysql_query("select * from users where recruiteris = $rid"); $num_rows = mysql_num_rows($sql); $var3 = '10'; $commission = $num_rows * $var3; ?> Is there any function in php lib that does the following $a = 1238; $n = 48; // 1*2*3*8 or I will have to create one for my script? (I want to do it for both client and server sides based on request sent by user. I actually want it in php that is why i asked it here, but if the solution (as function) is available in javascript (not jQuery) please share or guide me.) Edited January 5 by 684425This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=308889.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=342956.0 This topic is now in MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=357554.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=330205.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=352310.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=312429.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=331758.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=353621.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=306274.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=345725.0 This topic has been escorted to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=354341.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=334481.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=322398.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=348013.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=354388.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=305902.0 |