PHP - [mysql] Newbie Php Help Needed
Code: [Select]
<?php $verificate = $_GET["ver"]; $username = $_GET["user"]; $password = $_GET["pass"]; $dbh = mysql_connect("localhost","XXXXXX_dtbusre","my database password here") or die(mysql_error()); mysql_select_db("databasename_zxq_dtb") or die(mysql_error()); $sql = "SELECT loggedin FROM entityTable WHERE username=$username"; $result = mysql_query($sql) or die(mysql_error()); while ($line = mysql_fetch_array($result)){ echo $line[0]."\t".$line[1]."\n"; } mysql_close($dbh); if($verificate === "144356455343"){ echo "SURE"; } else{ echo "NOPE"; } ?> I get this: Code: [Select] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Similar TutorialsI am creating a site to display some products. For ease of updating I want it to run off a MySQL database. I have created the database and php scripts to output and input data etc. I know want to show that data in my web pages. My question is.... Is it best to insert HTML into the php output script to display the information and make the site look how I want....OR ....... should I create a template of the site in HTML and then somehow call the php output script (and the particular row of the database...) Basically... should I put the html code into the php - OR - put the php into the HTML?? I hope this make sense...... thanks Hello all, i have been looking around the net but i am to be honest not 100% sure of what i should be searching for. I am trying to create a script that can generate a random list of players for a men of war event we have planned. I have managed to generate a list of random names but i have no idea how to sort them. Quote $sql = "select * from players ORDER BY Rand() LIMIT 32"; $res = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($res)) { extract($row); echo"$player<br>"; } This has you know generates a list of 32 names and its very hard to read, if there away to make it so after ever forth name there is a space. Quote Player 1 Player 2 Player 3 Player 4 Player 5 Player 6 Player 7 Player 8 And so on. Also once the list is generate is there anyway way of adding something in the database that would link the 4 names togeather. Like team a team b and so on. Thanks in advance for any help. I created a shell script in OS X which forces my Macbook to connect to a MySQL database to see if my laptop was stolen. I can mark the Macbook as stolen in the database, which would provide me with a series of fuctions; one of these functions allows you to take pictures through the iSight camera and upload to an FTP server. The script and database work well, but now I'm trying to make it more user friendly by making it web-based. Here is an example of the code I'm having trouble with: $picture = mysql_query("SELECT picture FROM laptops"); $picrow = mysql_fetch_array($picture); if ( $picrow[0] == 0){ echo "<td>" . "<center><a href='start.php?cmd=start&id=$row[UID]'><img src='images/stopped.gif'></center></a>" . "</td>"; } else { echo "<td>" . "<center><a href='stop.php?cmd=stop&id=$row[UID]'><img src='images/started.gif'></center></a>" . "</td>"; } In the database there is a "1" for active and a "0" for inactive. What it's looking to do is ask to see if it's active or inactive. If it's active, it will have a green button, and inactive with have a red button. Eventually I'd like to be able to activate and deactivate functions by pressing the button, but I need to complete step 1 first. Currently this code does work (except for the links of course); however, I need to specify the number in the array ($picrow[0], $picrow[1], etc.) How do I have this populate automatically from 0 to infinity? I made a field in the database called UID (starting at 1) that automatically increments. I'm not sure if this would help or not. Thanks in advance. So, I've just recently gotten into the more advanced web scripting after writing static HTML pages for years and I must say it's pretty exciting. I've finally got my home LAMP up and running and I'm really excited about learning PHP and getting into dynamic web content. One of the areas that I'm really interested in is writing applications for my work and that's one of the first things I've been getting into first. I have some PHP code below that is giving me fits though, I'm afraid. MySQL server version: 5.1.49-1ubuntu8.1 (Ubuntu) My goal: I have an HTML page that has a text input, a drop down box and a submit button. The user inputs a username into the text field, and chooses an option from the drop down box and hits the submit button. I would like for a table holding member information to be updated to reflect the new status based on the user input from the forms. My table, named 'members', has the following fields: id (int) (primary) name (varchar) username (varchar) department (varchar) type (varchar) status (int) The status is a 0 or a 1. Effectively a True/False field. Here's the code in question: <?php // Set variables to get the username and the away/here status // also trim the username variable to ensure there are no inadvertent extra whitespace characters at the // beginning or end $username=$_POST["username"]; $username=trim($username); $status=$_POST["statuschange"]; // Check to ensure the username had a value input // This should be ran before the connection to the database is made to lessen impact on the web server // This is a temporary method, the production version should have a JavaScript function to check form input before // being passed on to the web server if (!$username) { echo "No username was submitted, please try again. Redirecting to main page."; echo "<meta http-equiv='refresh' content='3;url=/ns_index.php' />"; exit; } // Set variables to connect to the mysql server and to access the database // root user is for development purposes only. The production version should have a user setup // specifically for accessing the database with restricted privileges $ns_dev_conn=mysql_pconnect("localhost","mysql","mysqlpwd") or die("Could not connect: ".mysql_error()); $dbvar=mysql_select_db("dbname",$ns_dev_conn) or die("Could not select database: ".mysql_error()); // Set variables for the SQL statement and results $statusaway="0"; $statushere="1"; // Create the SQL statements based on the status being either away or here // This method of generating the SQL statement was used based on recommendation by: http://www.php.net/ if ($status=="away") { $status_query=sprintf("UPDATE `members` SET `status`='%s' WHERE `username`='%s'",mysql_real_escape_string($statusaway),mysql_real_escape_string($username)); } else { $status_query=sprintf("UPDATE `members` SET `status`='%s' WHERE `username`='%s'",mysql_real_escape_string($statushere),mysql_real_escape_string($username)); } // Set the variable to determine the result of the query $result=mysql_query($status_query,$ns_dev_conn) or die("Query failed: ".mysql_error()); // Determine if any rows were affected $num_rows=mysql_affected_rows($result, $ns_dev_conn) or die("Hrrmm. . .<b>".$username."</b>'s status could not be changed to <b>".$status."</b>. Please go back and try again. MySQL Error: ".mysql_error()); // This is a development only block of code // Echo all the variables to ensure the proper values are being passed // If these variables aren't being echoed one of the die() functions was passed. // Compare the error message received to the other die() functions to determine what is invalid // To get the variable values comment out the bad expression echo "Username: ".$username; echo "<br />Status (char): ".$status; echo "<br />Status away (int): ".$statusaway; echo "<br />Status here (int): ".$statushere; echo "<br />Server Connection Link ID: ".$ns_dev_conn; echo "<br />Database Selection ID: ".$dbvar; echo "<br />SQL Statement: ".$status_query; echo "<br />Result: ".$result; echo "<br />Number of Affected rows: ".mysql_affected_rows($result); /* This should be uncommented for production version // If $num_rows didn't die than the database was updated // Update the user that the query was successful and then redirect them back to the main page echo $username."'s status was updated to ".$status.". You will be redirected to the main page now."; echo "<meta http-equiv="refresh" content="4;url='/ns_index.php'" />"; */ ?> So, I've tried a bunch of different things, including echoing back all the variables to ensure the connection and SQL statements are correct, in addition I've taken the echoed SQL statement and copied it into phpmyadmin and the statement works with no errors! I've also looked at the mysql_info() return values and the row is being matched, it's just not being changed or affected. Right now when I activate this script it's returning the error associated with die() on mysql_affected_rows(). This is telling me that everything is working, except for the table actually being updated. Also, just for development and testing purposes I've been using the root MySQL user so I'm pretty sure it's not a privilege issue. If anybody could provide some insight into this problem I'd be most appreciative. Thanks. Im trying to get a code to find an id by name and then find a value by id this kinda works can you help? <?php $con = mysql_connect("localhost","root","password"; if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ryanteck", $con); $result = mysql_query("SELECT * FROM forum_members WHERE member_name='ryan'"); while($row = mysql_fetch_array($result)) { echo $row['member_name'] . "s Id is " . $row['id_member']; echo "<br />"; $result2 = mysql_query("SELECT * FROM forum_themes WHERE id_member= $id && variable= 'cust_uberis'"); while($row = mysql_fetch_array($result2)) or die (mysql_error()); { echo $id . "Uber Island Is " . $row['value']; echo "<br />"; } } ?> Hi there
I am just finalising my first ever PHP/MYSQL project and I am worried about where to safely keep my connection credentials for the SQL DB.
Currently, I am storing them in ../php/config.php and this works fine, but I am worried as to the security of this
Can anyone advise please
Thanks
Hei everyone. I am new on php development and i do not have budget on offering a course so i am trying to learn my self. i need some help on the following : i want to create infopanel.php where the script will get info from. For example if user logs in the script will have to call : <?php include '/incl/infopanel.php' ; ?>The info panel to load all details from database: <?php $name='$myname'; $sur_name='$sname'; $age='$myage'; $country='$mycountry'; ?>So the info with my has to be from database . so can some one help me how to call all information from database to a specific file that i will not have to call always information on every page I hope i have been so clean with my request My hosts version of php just seems to automatically add the backslashes. Adding the escape string just seems to add like 3 of them rather than 1 Is this command out-of-date? This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=343169.0 Here is my HTML code: Code: [Select] <html> <head> <title>Simple Search Form</title> </head> <body> <form name="searchform" method="get" action="/search.php"> Select Gender: <select name="gender"> <option value="Male">Male</option> <option value="Female">Female</option> </select> Select City: <select name="gender"> <option value="all">All Cities</option> <option value="newyork">New York</option> <option value="toronto">Toronto</option> <option value="london">London</option> <option value="paris">Paris</option> </select> <form> </body> </html> Here is my PHP code: <?php // get the data from the search form # get the gender (male or female) $gender = $_GET['gender']; # get the city $city = $_GET['city']; // connect to mysql and select db mysql_connect('localhost', 'root', 'pass') or die(mysql_error()); mysql_select_db($test_db); // send query $query = mysql_query("SELECT * FROM `visitors_location` WHERE gender='$gender' AND city='$city'"); $count = mysql_num_rows($query); // display data while ( $show = mysql_fetch_assoc($query) ) { echo $gender . " " . $city; } ?> My script basically shows # of males or females in a specific city. How can I show all males in all cities? In other words, let's say I want to show # of Females from all those 4 cities combined. I don't know how to do that. Can someone please help me? Hi, Ive stumbled apon a Mongo database connected to a broadcast script. I would like to change it to a Mysql database can anybody please show me an example how it will look in Mysql format
<?php /* Require the PHP wrapper for the Mxit API */ require_once ('MxitAPI.php'); /* Function to count the number of users in MongoDB */ function count_users() { $mongo = new Mongo('127.0.0.1'); $collection = $mongo->sampleapp->users; $collection->ensureIndex(array('uid' => 1)); return $collection->count(); } /* Function to get batches of users from MongoDB */ function get_users($skip=0, $limit=50) { $mongo = new Mongo('127.0.0.1'); $collection = $mongo->sampleapp->users; $collection->ensureIndex(array('mxitid' => 1, 'created_at' => 1)); $users = $collection->find()->sort(array('created_at' => 1))->skip($skip)->limit($limit); return iterator_to_array($users); } /* Instantiate the Mxit API */ $api = new MxitAPI($key, $secret); /* Set up the message */ $message = "(\*) Congratulations to our winners (\*)\n\n"; $message .= "1st place - Michael with 100 points\n"; $message .= "2nd place - Sipho with 50 points\n"; $message .= "3nd place - Carla with 25 points\n\n"; $message .= 'Good Luck! :) $Click here$'; /* Mxit Markup is included in the message, so set ContainsMarkup to true */ $contains_markup = 'true'; /* Count the number of users in the database */ $count = count_users(); /* Initialise the variable that counts how many messages have been sent */ $sent = 0; /* Keep looping through the user list, until the number of messages sent equals the number of users */ while ($sent < $count) { /* Get users in batches of 50 */ $users = get_users($sent, 50); /* The list where the user MxitIDs will be stored */ $list = array(); foreach ($users as $user) { $list[] = $user['mxitid']; $sent++; } /* If there is a problem getting an access token, retry */ $access_token = NULL; while (is_null($access_token)) { /* We are sending a message so request access to the message/send scope */ $api->get_app_token('message/send'); $token = $api->get_token(); $access_token = $token['access_token']; // Only attempt to send a message if we have a valid auth token if (!is_null($access_token)) { $users = implode(',', $list); echo "\n$sent: $users\n"; $api->send_message($app, $users, $message, $contains_markup); } } } echo "\n\nBroadcast to $sent users\n\n"; Hello all brilliant minds, I'm a new in all this world of DB and coding and always i tried to avoid it because I think it is very hard (I'm trying to change now). problem: I have a text file (log.txt) have data like below ======================================== > rtrv-ls Command Accepted - Processing OXX 12-02-21 08:44:41 EST EAGLE5 42.0.1-63.38.31 rtrv-ls Command entered at terminal #7. ; OXX 12-02-21 08:44:41 EST EAGLE5 42.0.1-63.38.31 L3T SLT GWS GWS GWS LSN APCI (SS7) SCRN SET SET BEI LST LNKS ACT MES DIS SLSCI NIS gtcen1pls 7-010-4 none 1 2 no D 2 off off off no off gtgdv1pls 7-010-5 none 1 2 no D 2 off off off no off > rtrv-sid Command Accepted - Processing OXX 12-02-21 08:43:43 EST EAGLE5 42.0.1-63.38.31 rtrv-sid Command entered at terminal #7. ; OXX 12-02-21 08:43:43 EST EAGLE5 42.0.1-63.38.31 PCA PCI PCN CLLI PCTYPE 010-010-010 7-055-1 01830 crher1p OTHER ; . . may output like this starting always with > =================================================== Then I have SQL DB that have column with "rtrv-ls" and "rtrv-sid" Requirement : A) Use Php to open the .txt file, I used HTML form so the user can upload the file on the browser then B) Search for the column name as pattern C)Send query to MYSQL to update DB with Data for each column D) Query the Mysql for several possible outputs (I've done this part using HTML form and simple php code as below. <?php // If we got a GET request on the page from HTML part of the code, we will want to store the data in a variable e.g $my_country // So country will be passed via GET and will be stored in $my_country variable. $host="localhost"; $con_usr="aomar"; $con_pass="nokia"; if ($_POST) { $user_input = $_POST['my_log'] ; // We use the request to search in Database and return the result, First step we need to connect to the database // $connect = mysql_connect ($host,$con_usr,$con_pass); // Then we need to select database to run the query and return the result the connection stored in the $connect ressource // if ($connect) { mysql_select_db("eagle",$connect); // We store the query in variable $query becuase is it quite long text; we actually attach our varaiable $my_log passed from HTML // $query = "SELECT `".$user_input."` FROM `ss7`"; //$update="INSERT INTO ss7 ('".$user_input."') VLAUES ('; // SO if user selected Egypt it will be stored in (name=my_country) variable from HTML and will be send via GET // Then we store the query results in a variable called $result $result = mysql_query ($query) ; $arr= mysql_fetch_array($result); echo nl2br ($arr["$user_input"]); //Finally we return what we want from the array. // Print the output as we wish. in case of row data like STP output, use the nl2br to preserve the output as it was written to MYSQL DB // We need to check if the Query return no value (!$arr) , and print corresponding action } //================SECONED PART WHEN I LOAD THE LOG FILE TO BE STORED IN MYSQL================// //close the db mysql_close ($connect); } ?> <html> <body> <form action = "eagle.php?pmode=my_file" method = "POST" enctype="multipart/form-data> <fieldset> <legend> Enter you log file here and click Save: </br> </legend> <label for="my_file"> This Is My Capture File </label> <input type = "file" name ="my_file" style=margin:auto > </input><br/><br/> <input type="submit" value="Upload file"> </fieldset> </form> </body> </html> <html> <body> <title>Eagle Data Base Store</title> <form action = "eagle.php?pmode=my_log" method = "POST"> <fieldset> <legend> Please Select the DB you would like to retrive </legend> <br/><br/> <input type = "radio" name ="my_log" value = "rtrv-serial-num">Serial-Num</input> <input type = "radio" name ="my_log" value = "rtrv-stp">rtrv-stp</input> <input type = "radio" name ="my_log" value = "rtrv-feat">rtrv-feat</input> <input type = "radio" name ="my_log" value = "rtrv-dstn">rtrv-dstn</input> <input type = "radio" name ="my_log" value = "rtrv-rte">rtrv-rte</input> <input type = "radio" name ="my_log" value = "rtrv-trm">rtrv-trm</input> <input type = "radio" name ="my_log" value = "rtrv-slk">rtrv-slk</input><br/> <br/> <input type = "radio" name ="my_log" value = "rtrv-ls">rtrv-ls</input> <input type = "radio" name ="my_log" value = "rtrv-sccpopts">rtrv-sccpopts</input> <input type = "radio" name ="my_log" value = "rtrv-stpopts">rtrv-stpopts</input> <input type = "radio" name ="my_log" value = "rtrv-gsmopts">rtrv-gsmopts</input> <input type = "radio" name ="my_log" value = "rtrv-cmd">rtrv-cmd</input> <input type = "radio" name ="my_log" value = "rtrv-assoc">rtrv-assoc</input><br/> <br/> <input type = "radio" name ="my_log" value = "rtrv-gpl">rtrv-gpl</input> <input type = "radio" name ="my_log" value = "rtrv-ip-host">rtrv-ip-host</input> <input type = "radio" name ="my_log" value = "rtrv-ip-lnk">rtrv-ip-lnk</input> <input type = "radio" name ="my_log" value = "rtrv-secu-trm">rtrv-secu-trm</input> <input type = "radio" name ="my_log" value = "rtrv-secu-user">rtrc-secu-user</input> <input type = "radio" name ="my_log" value = "rept-stat-sys">rept-stat-sys</input><br/><br/> <input type = "radio" name ="my_log" value = "rept-stat-clk">rept-stat-clk</input> <input type = "radio" name ="my_log" value = "rtrv-ctrl-feat">rtrv-ctrl-feat</input> <input type = "radio" name ="my_log" value = "rtrv-tabl-capacity">rtrv-tabl-capacity</input><br/><br/> <input type = "submit" value = "Show Selected Table"/> </fieldset> </form> </body> </html> ==========================================END OF CODE=========================== *** Sorry for the many comments but I want to be sure I remember why I do that . You help is much appreciated (Please note that need to understand more than I need the Code itself) Hi! I hope somebody can help me what im do wrong. i have checked that the data from the file is in $source_file but nothing imports to the database Code: [Select] <?php include('config.php'); include('opendb.php'); if(isset($_POST['upload'])) { $source_file = @$_POST['userfile']; //$source_file = fopen('http://localhost/test/upload/test.csv', 'r'); $target_table = 'foretag'; function csv_file_to_mysql_table($source_file, $target_table, $max_line_length=10000) { if (($handle = fopen("$source_file", "r")) !== FALSE) { $columns = fgetcsv($handle, $max_line_length, ","); foreach ($columns as $column) { $column = str_replace(".","",$column); } $insert_query_prefix = "INSERT INTO $target_table (".join(",",$columns).")\nVALUES"; while (($data = fgetcsv($handle, $max_line_length, ";")) !== FALSE) { while (count($data)<count($columns)) array_push($data, NULL); $query = "$insert_query_prefix (".join(",",quote_all_array($data)).");"; mysql_query($query); } fclose($handle); } } function quote_all_array($values) { foreach ($values as $key=>$value) if (is_array($value)) $values[$key] = quote_all_array($value); else $values[$key] = quote_all($value); return $values; } function quote_all($value) { if (is_null($value)) return "NULL"; $value = "'" . mysql_real_escape_string($value) . "'"; return $value; } } include('closedb.php'); echo "<br>done<br>"; ?> I have a webpage where the candidates can attach their resumes and send to the admin.These attachments are saved in the mysql db as blob datatype.In another webpage the admin needs to download all this resumes and see the content. How will i code for that. Hello. I'm a newbie so sorry if this isn't the best forum to post my problem.
I am using a MySQL and PHP to create a web app. I have authentication, and I can register users. I also have a form that users provide information and it is successfully inserting data into a table in my database.
I will use fictional fields for my database table called meal_info:
username
dateStartedDiet
numberMealsPerDay
costPerMeal
Problem: Select user-specific data from the MySQL database, using Session username to select only the current user's data, then display it and do some calculations.
Here is thecode at the top, and I am fairly sure it's working:
session_start(); //execute commone code
require("common.php"); //includes code to connect to database, etc.
if(empty($_SESSION['user'])) I'm attempting to implement a simple social networking system but at the moment am confused about how to create a multiple query which will display a certain user's friends list. The database contains four tables, the two tables that I'm using at the moment at 'usersTable' and 'friendshipsTable' are detailed below. usersTable | Table that stores all the user data UserID | Default primary key Forename | Surname | Username | Password | Email Address | friendshipTable | Table that stores information about friendships between users FriendshipID | Default primary key userID_1 | UserID userID_2 | UserID Status | Either Pending or Confirmed. The user's id is parsed into the url, and then saved into a variable. blah.com/userprofile.php?id=6 $id = $_GET['id']; I am familiar with creating simple queries, but can't quite work out how to set up multiple table queries. What the query needs to do is to check the userID that is parsed with the url, and then check the friendshipsTable by checking if either the userID_1 or userID_2 field matches the userID to grab the records from the table where there is a match. The next step is to check to see if the friendship is 'Confirmed' or 'Pending' and if it is 'Pending' to ignore it. Once the records have then been chosen I need the query to then check the value in either userID_1 or userID_2 that doesn't match userID and then pull the user's username and name from the usersTable so it can be displayed on a webpage. I've no idea hoe much I may or may not be overcomplicating this, an example of the code that I've got so far for this query can be found below, but that's as far as I've got at the moment. $displayFriends = mysql_query("SELECT * FROM friendshipTable, usersTable WHERE friendshipTable.userID_1='$id' OR friendshipTable.userID_2='$id' "); Cheers for any help. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=333523.0 I would love to find someone that I can ask all my annoying narbish questions to. Code: [Select] $username="a1624814_bento"; $password="Password123"; $database="a1624814_siteDB"; $localhost="mysql13.xxx.xxx"; mysql_connect($localhost,$user,$password); line 13 Code: [Select] mysql_connect($localhost,$user,$password); Quote Host '31.100.100.200 is not allowed to connect to this MySQL server in /home/member/insert.php on line 13 Now after I fix this, Im sure that I will hafve a string of other failiurs, what do i do with them? some i can figure out, and normally will try to figure something out before asking. Thanks for taking the time to read!!! Good day people, got this open source script for a dog pedigree database on the net. I have no programming skills at all. Need some help with the script, i want to change the font color of the Sire's side of the pedigree that is displayed , but have no idea how to do it, any help would be appreciated. Example of displayed pedigree - http://www.sa-apbt.co.za/details.php?id=63854 below are the code. Thanks in advance <?php function DbTriad($dogVO, $level, $generations, $childText) { global $THUMBNAIL_WIDTH; global $dogDAO; # do the individual. if ($level == $generations) { echo "<TD >"; } else { echo "<TD ROWSPAN=" . pow(2,($generations - $level)); echo " >"; } if (($dogVO != -1) && (!empty($dogVO ))) { if (empty($dogVO)) { echo "Unknown Individual"; } else { $name = $dogVO->name; $sireId = $dogVO->sire->id; $damId = $dogVO->dam->id; $landofbirth = $dogVO->landofbirth; $yearofbirth = $dogVO->yearofbirth; $color = $dogVO->color; $title = $dogVO->title; $photo = $dogVO->photo->thumb_ref; if (empty($photo)) $photo = $dogVO->photo->reference; } ### Highlight title w/ Blue font if (!empty($title)) { echo "<label>"; echo "<font color=\"blue\">$title</font><BR>"; echo "</label>"; } echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$dogVO->id.'">'; if (!empty($photo)) { echo '<p><img SRC="'.$photo.'" width="'.$THUMBNAIL_WIDTH.'"></p>'; } echo "$name</a>"; echo "<label>"; //if (($level <= 3) && (!empty($color))) { if (!empty($color)) { echo "<BR>$color "; } if (!empty($landofbirth)) { echo "<BR>$landofbirth"; } if (!empty($yearofbirth)) { echo "<BR>$yearofbirth"; } echo "</label>"; } else { echo " "; if (!empty($childText) ) echo '<a href="addDog.php?child='.$childText.'">Add Dog</a>'; } echo "</TD>"; # do the father. if ($level < $generations) { if (!empty($dogVO)) $childText = "fatherOf_".$dogVO->id; else unset($childText); $dogDAO = new DogDAO(); if (empty($sireId)) $father = null; else $father = $dogDAO->get($sireId); DbTriad($father, $level + 1, $generations, $childText); } # do the mother. if ($level < $generations) { if (!empty($dogVO)) $childText = "motherOf_".$dogVO->id; else unset($childText); $dogDAO = new DogDAO(); if (empty($damId)) $mother = null; else $mother = $dogDAO->get($damId); DbTriad($mother, $level + 1, $generations, $childText); } # finish up. if ($level == $generations) { echo "</TR><TR>"; } } # begin table echo '<table id="pedigree" align="center" width="96%" border="0"><tr><th colspan='.$generations.'>Pedigree of '.$dog->name.' '.$dog->title.'</th></tr>'; # do tree. $dogDAO = new DogDAO(); $dog = $dogDAO->get($currId); DbTriad ($dog, 1, $generations, null); # end table echo "</td></tr></table>"; ?>[/php] |