PHP - Gathering Data Together Via Mulitple Tables And Find Sum
Hi
I am trying to find out the total value of dontations raised per email address but in order to find this information I have to do a few queries in order to find out the email address by using there ID and also need to see what percentage of each donation and which cause this donation went to. Find out donation amount Code: [Select] SELECT wp_supporters_donations.SFMemberNumber, wp_supporters_donations.KickbackAmount FROM supporter_2_cause RIGHT JOIN wp_supporters_donations ON supporter_2_cause.supp_id=wp_supporters_donations.SFMemberNumber GROUP BY wp_supporters_donations.SFMemberNumber Find out percentage here Code: [Select] function getdonationperc($supp_id, $causeid, $ProcessDate){ global $wpdb; $fu=0; $ProcessDate = substr($ProcessDate, 0, 6); //echo $ProcessDate; //echo $supp_id." "; //echo $causeid; $new = $wpdb->get_results("SELECT * FROM dp_log WHERE sid=$supp_id AND cid=$causeid AND date=$ProcessDate AND fp != 'yes' ORDER BY id LIMIT 0, 1"); foreach ($new as $new){ $fu = $new->perc; //echo $fu; } //echo " RESULT11 ".$fu; if($fu=="0" || $fu==NULL){ $newresult = $wpdb->get_results("SELECT * FROM supporter_2_cause WHERE supp_id=$supp_id AND caus_id=$causeid AND deleted!='1' AND fp!='yes' ORDER BY id LIMIT 0, 1"); foreach ($newresult as $newresult){ $fu = $newresult->donation; //echo "wtf"; } //echo $fu; if($newresult == NULL) { $fu="0"; } }else{ //$fu="0"; } //echo $supp_id." - ".$causeid." - ".$ProcessDate." - ".$fu."<br/>"; //echo " RESULT ".$fu; return $fu; } Find out email address attached to each donation Code: [Select] SELECT email FROM supporters WHERE id='SFMemberNumber' Then I need to add all donations up for each email address per each cause and output these / insert into a new table. Similar TutorialsThis portion is kind of stumping me. Basically, I have a two tables in this DB: users and users_access_level (Separated for DB normalization) users: id / username / password / realname / access_level users_access_level: access_level / access_name What I'm trying to do, is echo the data onto an HTML table that displays users.username in one table data and then uses the users.access_level to find users_access_level.access_name and echo into the following table data, I would prefer not to use multiple queries if possible or nested queries. Example row for users: 1234 / tmac / password / tmac / 99 Example row for users_access_level: 99 / Admin Using the examples above, I would want the output to appear as such: Username: Access Name: Tmac Admin I am not 100% sure where to start with this, but I pick up quickly, I just need a nudge in the right direction. The code I attempted to create just shows my lack of knowledge of joining tables, but I'll post it if you want to see that I did at least make an effort to code this myself. Thanks for reading! Code: [Select] foreach($html->find('a') as $element) echo $element->href . '<br>'; I understand that the code above results in printing out all links on the page in text. I want the same but only in a <div> I choose. See below: Code: [Select] <div id=web> <A href = myweb.com/url1>home</a> <A href = myweb.com/url2>about</a> <A href = myweb.com/url3>contact</a> </div> I want for example <div id=web> to print out onto page the urls in plain text from within that <div> or put into an array so I can create variables out of each url to do different actions. I'm using simple html dom I've tried different ways but I either get an error, a blank white page, or a print out of the word array? Either direct me to some web sources or write a code out for me, thanks Hi everyone! I'm on a mission to make a simple (I hope :/ ) script that takes some files from a folder and sends them off to a snippet of javascript. I have a folder creatively named 'files' that is full of Google Earth .kml files. I want to get some PHP code to grab those files, and pass them to the javascript that handles the Google Earth plugin, which looks like this: Code: [Select] var link = ge.createLink(''); var href = '<?php echo($testvar); ?>' link.setHref(href); var networkLink = ge.createNetworkLink(''); networkLink.set(link, true, true); The php in there is me testing out php-to-javascript variables, which seems to be working fine for a single file. My plan for the code was to: 1) Detect all the files in the folder 2) Make the paths for each file into string variables 4) Loop the above javascript once for each file The end result would be the kml files, which are all building models, populating the earth. The files in the folder will be added and removed all the time, so It has to check it every time. Unfortunately this had to be my first experience with php and so this is as far as I got: foreach(glob("files/"."*.kml") as $file){ echo $file." - "; } So, it lists out the files in the directory with a ' - ' between each one, but from there I've been lost for days Does anyone have some pointers on what to do with this? Thanks, Love ya! I have this code reads the xml runs with no errors but will not input the data from the array in the <catparent> The script Code: [Select] <?php // isbn => pages $page_numbers = array( '1234' => 'hello parent', // insert data into catparent node '5678' => 'hello parent', // insert data into catparent node ); $dom = new DOMDocument(); $dom->load('edtest1.xml'); $xpath = new DOMXPath($dom); $items = $xpath->query('item'); foreach($items as $item) { $catcode = $item->getElementsByTagName['catcode']; $parent_code = $page_numbers[ $catcode[0] ]; $item->appendChild( $dom->createElement('catparent', $parent_code) ); } $dom->save('edtest_stack.xml'); ?> My XML file looks like Code: [Select] <?xml version="1.0" encoding="UTF-8"?> <items> <item> <catcode>1234</catcode> <catdesc>Systems - System Bundles</catdesc> </item> <item> <catcode>5678</catcode> <catdesc>Hard Drives - SATA</catdesc> </item> </items> Output XML looks like this as you can see it has created the <catparent> but will not insert the data from the array. Code: [Select] <?xml version="1.0" encoding="UTF-8"?> <items> <item> <catcode>1234</catcode> <catdesc>Systems - System Bundles</catdesc> <catparent></catparent></item> <item> <catcode>5678</catcode> <catdesc>Hard Drives - SATA</catdesc> <catparent></catparent></item> </items> Any ideas pointers as to where I'm going wrong would be most helpful hi i am trying to create a drop down menu where for example the 1st menu has 2 items and the 2nd menu has 4 items. So when you pick the 1st drop down you get first 2 choices from menu 2 and when you select the 2nd choice in menu 1 you get the other 2 choices from menu 2. so drop down New York would have Queens , Brooklyn etc... <form name="region" onClick="this.form.submit()" default="ny" method="POST"> <select name="dropdown"> <option value="ny">New York</option> <option value="to">Toronto</option> <option value="ln">London</option> <option value="hk">Hong Kong</option> </select> <noscript><input type="submit" value="Submit"></noscript> </form> Hi Guys, Here a bit of a stupid question, I have a set of Submit Buttons that need to have different values. This is because I do a If(isset($_POST['VALUE'])). So what I have is buttons that represent a User, when the user clicks the button next to the user name it posts the value back to the page and then loads a new function. Does anyone know if this is possible. Am I able to use the <input name="user[$value]" type="submit" value="View Profile" />. Regards Thomas pARK Hi, I'm trying to query my database using codeigniter's active record class. I have a number of blog posts stored in a table. The query is for a search function, which will pull out all the posts that have certain categories assigned to them. So the 'category' column of the table will have a list of all the categories for that post in no particular order, separated by commas, like so: Politics,History,Sociology.. etc. If a user selects, say, Politics and History, The titles of all the posts that have BOTH these categories should be returned. Right? So, the list of categories queried will be the array $cats. I thought this would work- foreach ($cats as $cat){ $this->db->like('categories',$cat); } By Producing this- $this->db->like('categories','Politics'); $this->db->like('categories','History'); (Which would produce- 'WHERE categories LIKE '%Politics%' AND categories LIKE '%History%') But it doesn't work, it seems to only produce the first statement. The problem I guess is that the column name is the same for each of the chained queries. There doesn't seem to be anything in the CI user guide about this (http://codeigniter.com/user_guide/database/active_record.html) as they seem to assume that each chained statement is going to be for a different column name. Of course it is not possible to use an associative array in one statement as it would have to contain duplicate keys- in this case every key would have to be 'categories'... Does anyone know how I could do this? Thanks! Hi Forum I have this script below which i thought would update multiple rows in my database, but all it does is refresh and revert back to its original data. Im guessing my problem is in my update script but I cant seem to find where I have gone wrong. Any help would be greatly appreciated. <?php $host="*****"; $username="*****"; $password="*****"; $db_name="*****"; $tbl_name="*****"; // Connect to server and select databse. $db = new PDO('mysql:host=' . $host . ';dbname=' . $db_name, $username, $password); // If there is an update, process it. if (isset($_POST['submit'], $_POST['pageorder']) && is_array($_POST['pageorder'])) { $stmt = $db->prepare("UPDATE `$tbl_name` SET `pageorder`=:pageorder WHERE id=:id"); $stmt->bindParam(':id', $id, PDO::PARAM_INT); $stmt->bindParam(':pageorder', $pageorder, PDO::PARAM_STR); foreach ($_POST['pageorder'] as $id => $pageorder) { $stmt->execute(); } echo '<h1>Updated the records.</h1>'; } // Print the form. echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '" method="post">'; foreach ($db->query("SELECT `id`, `pageorder`, `pagetitle`, `linklabel` FROM `$tbl_name` ORDER BY `pageorder`") as $row) { echo '<input type="text" pageorder="pageorder[' . (int)$row['id'] . ']" value="'. htmlspecialchars($row['pageorder']) . '" />'; echo '<input type="text" pagetitle="pagetitle[' . (int)$row['id'] . ']" value="'. htmlspecialchars($row['pagetitle']) . '" />'; echo '<input type="text" linklabel="linklabel[' . (int)$row['id'] . ']" value="'. htmlspecialchars($row['linklabel']) . '" /><br />'; } echo '<input type="submit" name="submit" value="Update" /></form>'; ?> Hey everyone. I have some experience with PHP and can easily modify existing code, but seem to have trouble writing the logic from scratch. Situation: I'm using this Jquery slider ( http://mine.tuxfamily.org/?p=74#more-74 ) and would like to populate the slides with data coming from an XML file. The data will be text, images(URIs), and links to buy. The thing is, each slide will hold 4 items, and then I want to somehow using PHP logic, allow the code to generate the next slide... In other words, how would I code it so that after 4 entries, it creates a new slide? I'm imagining a For loop + SimpleXML functions... but just kind of fumbling in the dark here. Any direction or guidance is greatly appreciated! Kind regards, Dey Ok, so I'm not quite sure how to explain this, but here it goes: I have table A that contains stats for all players in the NHL, and then I have table B with just a few players. These few players in table B are also in table A, but table B has more information on them. I want to take the stats for these players out of table A and put into table B, and I want table B to update along with table A every time those numbers change. How would I do this? Hi all, I am lost again in this PHP world. I am trying to set up a grade book for my reporting system. I have got totally lost in the code and I am need of some help. Many Thanks F Code: [Select] <?php function doquery($query) { $db = "prs"; $link = mysql_connect("localhost","gandalf","A3tti2ca") or die("Could not connect to server! Error: ".mysql_error()); mysql_select_db($db,$link) or die("Could not select $db! Error: ".mysql_error()); $result = mysql_query($query,$link) or $result = "Query Error!<p>Query: $query<p>Error: ".mysql_error(); mysql_close($link); return($result); } function parseresults($result) { if ($line = mysql_fetch_array('$result', MYSQL_ASSOC)) { displayform($line); } else { print "A database problem has occurred. Contact the database administrator<p>"; } } function displayform($line) { <<<HTML <form action="gradebook2.php" method="post"> <H4>Thank You, <p> HTML; print $line['firstname']." ".$line['surname']." (#".$line['upn'].") in set ".$line['class_set']; print ' has been sucessfully added to the system.<p>'; echo"<form id=\"Gradebook\" name=\"gradebook\" method=\"post\" action=\"gradebook2.php\"> <table width=\"77%\" border=\"1\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\" bordercolor=\"#de6057\"> <tr> <td width=\"45%\" class=\"footer\"> <label class=\"form_labels\">Coursework Mark</label> </td> <td width=\"55%\"> <input name=\"cw_mark\" type=\"text\" id=\"cw_mark\" value=".$line['english_cw_mark']." tabindex=\"1\" size=\"6\" maxlength=\"4\" /> <input type=\"hidden\" name=\"upn\" value=".$line['upn']."> </td> </tr> <tr> <td class=\"footer\">Coursework Comment </td> <td> <label> <textarea name=\"cw_comment\" id=\"cw_comment\" cols=\"35\" rows=\"7\" value=".$line['english_cw_commnents']."></textarea> </label> </td> </tr> <tr> <td class=\"footer\"><label class=\"form_labels\">Exam Mark</label></td> <td> <input name=\"exam_mark\" type=\"text\" id=\"exam_mark\" value=".$line['english_exam_mark']." tabindex=\"3\" size=\"6\" maxlength=\"4\"> </td> </tr> <tr> <td class=\"form_labels\">Exam Comment </td> <td> <label> <textarea name=\"exam_comment\" id=\"exam_comment\" cols=\"35\" rows=\"7\" value=".$line['english_exam_comments']."></textarea> </label> </td> </tr> <tr> <td class=\"form_labels\"><label>Commendation in Poetry</label></td> <td> <select name=\"com_poetry\" id=\"com_poetry\" value=".$line['com_poetry']."> <option value=\"No Commendation\" selected=\"selected\">No Commendation</option> <option value=\"Commendation Awarded\">Commendation Awarded</option> </select> </td> </tr> <tr> <td class=\"form_labels\"><label>Commendation in Creative Writing</label></td> <td> <select name=\"com_creative\" id=\"com_creative\" value=".$line['com_creative']."> <option selected=\"selected\">No Commendation</option> <option value=\"Commendation Awarded\">Commendation Awarded</option> </select> </td> </tr> <tr> <td class=\"form_labels\">Commendation in Literary Interpretation</td> <td> <select name=\"com_lit_int\" id=\"com_lit_int\" value=".$line['com_lit_int']."> <option value=\"No Commendation\" selected=\"selected\">No Commendation</option> <option value=\"Commendation Awarded\">Commendation Awarded</option> </select> </td> </tr> <tr> <td class=\"form_labels\"><label>Overall Comments</label></td> <td> <textarea name=\"overall_comments\" id=\"overall_comments\" cols=\"35\" rows=\"7\" value=".$line['english_overall_commnents'].'"></textarea> </td> </tr> <tr> <td> </td> <td> <input type=\"reset\" name=\"Reset\" id=\"Reset\" value=\"Reset Form\" tabindex=\"12\" /> <input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Submit Form\" tabindex=\"11\" /> </td> </tr> </table> </form>"; } $student_upn = (integer) $_POST["stu_upn"]; $query = "select count(*) as numberRecords from english where upn = ".$student_upn.""; $result = doquery($query); $row = mysql_fetch_array($result); if ($row['numberRecords'] == 0) { $query = "select students.upn from students where students.upn = '".$student_upn."'"; $result = doquery($query); $row = mysql_fetch_array($result); $cw_mark = $row['english_cw_mark']; $cw_comment = $row['english_cw_comments']; $exam_mark = $row['english_exam_mark']; $exam_comment = $row['english_exam_comments']; $com_poetry = $row['com_poetry']; $com_creative = $row['com_creative']; $com_lit_int = $row['com_lit_int']; $overall_comment = $row['english_overall_comments']; $insert = "insert into english (upn, english_cw_mark, english_cw_comments, english_exam_mark, english_exam_comments, com_poetry, com_creative, com_lit_int, english_overall_ comments) values (".$student_upn.",'".$cw_mark."','".$cw_comment."', '".$exam_mark.",'".$exam_comment."','".$com_poetry."','".$com_creative."','".$com_lit_int."','".$overall_comment."',0); print $insert; doquery($insert); } $query = select students.upn as upn, firstname, surname, class_set, from customers left join english on students.upn = english.upn where students.upn = ".$student_upn."; $result = doquery($query); if (is_resource($result)) { parseresults($result); } else { print "$result"; } print "<a href=\"gradebook.php\"><h4>Grade Another Student</h4></a>"; ?> <?php $con = mysql_connect("localhost","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("contact", $con); $sql="INSERT INTO contact_info (FirstName, LastName, Phone, Email, ContactMethod, City, State, zip, TimeFrame, Agent, AgentInfo) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[phone]','$_POST[email]','$_POST[contactmethod]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[timeframe]','$_POST[agent]','$_POST[agentinfo]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> That's my code everything seem's to be working fine script runs and says 1 record added however when I go to view the entry phpMyAdmin the entry show's up without the data? Hi guys, This is my first time posting here - im just getting into PHP - i got a question; I have two databases: profile(id, name, interests, dob, gender, join_date, email) interests(id, profile_id, interests) id being the primary key, and profile_id being the foreign key from profile. I want to script that returns profile information and all the matching interests (one user can have multiple interests). This is what i have so far, though it does not work, and i knew it wouldnt; function get_profile($id) { $connection = mysql_open(); $query = "SELECT * "; $query .= "FROM profiles, interests "; $query .= "WHERE profile.id=" . $id; $query .= " AND interests.profile_id=" . $id; $result = @ mysql_query($query, $connection); // Transform the result set to an array (for Smarty) $entries = array(); while ($row = mysql_fetch_array($result)) { $entries[] = $row; } mysql_close($connection) or show_error();; return $entries; } Can someone please advise on how this can be done? or do i need to have two query's one for each table ? Thank you in advance!! Hey,
I have am creating a web app to hold customer and job details.. I have the following table structures to hold the data:
CREATE TABLE Customers ( customerID int(5) NOT NULL auto_increment, customer varchar(25) default NULL, contact varchar(25) default NULL, phone varchar(25) default NULL, email varchar(25) default NULL, address varchar(25) default NULL, PRIMARY KEY (customerid) ) ENGINE = INNODB; CREATE TABLE Jobs ( jobID int(5) NOT NULL auto_increment, customerID int(5) NOT NULL default '0', invoiceNumber varchar(25) default NULL, purchasOrder varchar(25) default NULL, orderDate datetime NOT NULL default '0000-00-00', dateRequired datetime NOT NULL default '0000-00-00', jobStatus varchar(25) default NULL, PRIMARY KEY (jobID) ) ENGINE = INNODB; CREATE TABLE vinyl ( vinylID int(5) NOT NULL auto_increment, jobID int(5) NOT NULL default '0', colour varchar(25) default NULL, font varchar(25) default NULL, size varchar(25) default NULL, fileLocation varchar(25) default NULL, PRIMARY KEY (vinylID) ) ENGINE = INNODB; CREATE TABLE screenprint ( screenprintID int(5) NOT NULL auto_increment, jobID int(5) NOT NULL default '0', colour varchar(25) default NULL, font varchar(25) default NULL, size varchar(25) default NULL, fileLocation varchar(25) default NULL, PRIMARY KEY (screenprintID) ) ENGINE = INNODB; CREATE TABLE items ( itemID int(5) NOT NULL auto_increment, jobID int(5) NOT NULL default '0', supplier varchar(25) default NULL, code varchar(25) default NULL, colour varchar(25) default NULL, style varchar(25) default NULL, total varchar(25) default NULL, dateOrdered varchar(25) default NULL, PRIMARY KEY (itemID) ) ENGINE = INNODB; CREATE TABLE itemsqty ( itemqtyID int(5) NOT NULL auto_increment, itemID int(5) NOT NULL default '0', jobID int(5) NOT NULL default '0', size varchar(25) default NULL, quanity int(5) NOT NULL default '0', PRIMARY KEY (itemqtyID) ) ENGINE = INNODB; CREATE TABLE embroidery ( embroideryID int(5) NOT NULL auto_increment, jobID int(5) NOT NULL default '0', code varchar(25) default NULL, stitchCount varchar(25) default NULL, quanity int(5) NOT NULL default '0', PRIMARY KEY (embroideryID) ) ENGINE = INNODB;Are these tables set out correctly for the collection of data needed. Also.. am I best to use Foreign Keys? My understanding of using foreign keys is not in place for queries as such, more to keep the tables clean of miss matched records etc? Thanks so I'm trying to change some specific columns in a row in a table of a MySQL database by calling the Doctrine_Query when an option is selected inside an admin panel of my website. Here are the details: Table name: chatUsers I need to find all rows with the person who has a username of: $chatUsers->username (The column inside chatUsers is called username) Once all those rows are found, change the value of all the row's column "type" to "user" Is this even possible? So far I have: [/list] Code: [Select] <?php function userChatReset(){ $query = Doctrine_Query::create()->update('db_chatUsers')->set('type', 'user')->where('username = '.$chatUsers->username); //execute query $rows = $query->execute(); echo $rows.' rows updated'; } ?> ...And I'm not sure where to go from there, or if that's even correct. Sorry in advance, I'm not very good with PHP yet. Hi, My name is stefan and I've been trying to develop a php/mysql based CRM for private use. I've stumbled upon a problem a few days ago and I just can't figure it out, so if you could help me, I'd really appreciate it. The problem is the following: I have 1 database which contains 5 tables. Each table has info in it but the primary key always is 'ID' 4 Tables are named; Zendingen | Klanten | Manden | Bestemmeling The last table, named 'Combination' has the unique ID of each of those 4 in it. The example will be given below. What I want to do now is create a page that shows all stored rows in 'Combination'-table, but gets the proper client_name or product_info out of the corresponding table. I have searched for it myself but I have no clue where to begin and how to define my searches so they all stranded. This is the piece of code. Code: (php) [Select] $Shipm1 = mysql_query("SELECT * FROM Shipments where Zending_ID = 9") or die(mysql_error()); while($row = mysql_fetch_assoc($Shipm1)) { echo "<br />"; echo $row["ID"]; echo "<br />"; echo $row["Zending_ID"]; echo "<br />"; echo $row["Klant_ID"]; echo "<br />"; echo $row["Mand_ID"]; echo "<br />"; echo $row["Bestemmeling_ID"]; echo "<br />"; }This code returns: Quote 3 ---- the ID of the 'combination' table and thus primary key 9 ---- Zending_ID 47 --- Klant_ID 17 --- Mand_ID 2 ---- Bestemmeling_ID 4 This is another row from the combinations table, 9 notice that it only returns the Zending_ID = 9. 49 21 4 Now this gives me the info I want, but it doesn't displays them how I need it to. I want it to search up each ID in the proper table and return me the product name, client name etc... Anyone who can help or point me in the right direction? Kind regards Stefan I have been playing around with this. Thought I had it nailed, and then found that It was fubar when I started to add more entries to the database. I basically want to display 2 tables from my database on the page. One is called "players" the other is called "editlog". The output with my current script came out as this: and here is the dreaded code: <html> <body> <u><h3>Performance Point Monitor (PPM): Knights of Shadow WoW Officers.</h3></u> <?php include('/home/a3269923/public_html/ppm/admin/config.php'); include('/home/a3269923/public_html/ppm/admin/dbopen.php'); $query="SELECT * FROM players"; $result=mysql_query($query); $num=mysql_numrows($result); ?> <table border="1" style="position:absolute;width:500;height:10;left:0;top:70"> <tr> <th><font face="Arial, Helvetica, sans-serif">PLAYER</font></th> <th><font face="Arial, Helvetica, sans-serif">POINTS</font></th> <th><font face="Arial, Helvetica, sans-serif">DATE</font></th> </tr> <?php $i=0; while ($i < $num) { $f2=mysql_result($result,$i,"PLAYER_NAME"); $f3=mysql_result($result,$i,"ND_POINTS"); $f4=mysql_result($result,$i,"DATE ADDED"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> </tr> </table> <?php $i++; } ?> <?php include('/home/a3269923/public_html/ppm/admin/config.php'); include('/home/a3269923/public_html/ppm/admin/dbopen.php'); //USER LOG $query="SELECT * FROM editlog"; $result=mysql_query($query); $num=mysql_numrows($result); ?> <table border="1" style="position:absolute;width:600;height:10;left:510;top:70"> <tr> <th><font face="Arial, Helvetica, sans-serif">USER</font></th> <th><font face="Arial, Helvetica, sans-serif">TYPE</font></th> <th><font face="Arial, Helvetica, sans-serif">POINTS</font></th> <th><font face="Arial, Helvetica, sans-serif">NOTES</font></th> <th><font face="Arial, Helvetica, sans-serif">DATE</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"USER"); $f2=mysql_result($result,$i,"TYPE"); $f3=mysql_result($result,$i,"POINTS"); $f4=mysql_result($result,$i,"NOTE"); $f5=mysql_result($result,$i,"TIMESTAMP"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td> </tr> </table> <?php $i++; } ?> What am I doing wrong? Halp! Hi, I have multiple table Table -1 order_no name 1 raj table -2 order_no name 1 raj table 3 order_no name 1 raj table 4 order_no name 1 raj table 5 order_no name 1 raj I want a query to check if the id (one) is present in all tables or not, i create this. select order_no from prepress, press, postpress, qc, binding, dispatch where order_no=prepress.order_no AND order_no=press.order_no AND order_no=postpress.order_no AND order_no=qc.order_no AND order_no=binding.order_no AND order_no=dispatch.order_no but the ambiguous error for order_no. how to achieve this can anyone suggest me? thanks Hey 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! I have two tables 'book' and 'category'. They look like the following in phpmyadmin;
book
id title author category isbn ---- ------- ---------- ---------- ------- 1 Treasure Chest Jim Jones 1 14252637 2 Pirates Boat Sue Smith 2 88447737 3 Adventure Land Harry Jo 3 01918273 4 Winter Week Sam Dill 3 00999337 5 The Twite Roald Dahl Fiction 87873366 category id cat_name ---- ------- 1 Horror 2 Kids 3 Fiction 4 Science Users have the option of adding books into the library via an online form, or via a Google Booka api method (user enters isbn, searches, is presented with book info and then clicks 'add to library', done.). This is handled via ajax. The online form works fine, and successfully adds the book info. However my problem is with the Google Books method, it successfully adds the data to the db however the category column is in text format (i.e 'Juvenile Science' or 'Scary Fiction') as opposed to the manual form which adds categories as 1, 2 or 3 (1 =Horror, 2 = Kids, 3 = Fiction). Is there any way I can add the Google Book category data to my table and convert it to an integer or similar? Not sure what I need to do. Suggestions appreciated! Should I add the Google entries to another table (i.e googleCategory)? My HTML only outputs the numbered category entries and ignored the text format entries. my php $sql = "SELECT b.id, b.title, b.author, b.isbn, b.publicationYear, c.cat_name FROM book AS b INNER JOIN category AS c ON b.category = c.id WHERE status != 'Archive' ORDER BY id DESC LIMIT $startrow, 15 "; $res = $conn->query($sql) or trigger_error($conn->error."[$sql]"); while($row = $res->fetch_array()) { echo '<tbody>'; echo '<tr>'; echo '<td>' . $row['id'] . '</td>'; echo '<td>' . $row['title'] . '</td>'; echo '<td>' . $row['author'] . '</td>'; echo '<td>' . $row['cat_name'] . '</td>'; echo '<td>' . $row['isbn'] . '</td>'; echo '<td>' . $row['publicationYear'] . '</td>'; echo '</tr>'; echo '</tbody>'; };Apologies if this is all a bit confusing I am very new to php and mysql. Thanks, J |