PHP - Please Help Print This To My Web Page
I have the following code but I cannot get it to print the results of the array into my web page. Help would be so appreciated!!
Code: [Select] $sql = "SELECT RegName, SireID, DamID FROM pedigrees WHERE ID="; $DoggieIDQ = $sql . $values["ID"]; $DoggieIDR = db_query($DoggieIDQ,$conn); $DoggieID = $_GET['ID']; $Depth = 1; $DepthLimit=8; function getParents($DoggieID, $Depth, $DepthLimit) { $Sire = getSire($DoggieID); $Dam = getDAM($DoggieID); $Depth++; if ($Depth == $DepthLimit) { return array($Sire, $Dam); } else { # Now get grandparents too $SireParents = getParents($Sire, $Depth, $DepthLimit); $DamParents = getParents($Dam, $Depth, $DepthLimit); return array($Sire, $Dam, $SireParents, $DamParents); } } Similar TutorialsI have been searching for hours to try and figure out how I could print a remote page using PHP. I know in javascript, you can print the current page with: Code: [Select] <a href="javascript:window.print()">Print Page</a> But what I want to do is "javascript:window.print(http://some-link.com)", but would be nice if I could do it using PHP, if it's even possible. I have a class that I created, halfway down my page I call a function from the class which prints some code and also changes a variable inside the class. It's a search class basically it prints out the search results and saves the total amount of results into the variable. I want to display the amount of results above the results like so:- echo $Search->results; $Search->GetResults('foo'); The problem is that $Search->results will be equal to NULL until the variable is updated in the function GetResults. Hope that makes sense, am I going about this wrong? how do i grab and print on page in date order all .jpg files in a folder ? Quesion: Show each movie in the database on its own page, and give the user links in a "page 1, Page 2, Page 3" - type navigation system. Hint: Use LIMIT to control which movie is on which page. I have provided 3 files: 1st: configure DB, 2nd: insert data, 3rd: my code for the question. I would appreciate the help. I am a noob by the way. First set up everything for DB: <?php //connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //create the main database if it doesn't already exist $query = 'CREATE DATABASE IF NOT EXISTS moviesite'; mysql_query($query, $db) or die(mysql_error($db)); //make sure our recently created database is the active one mysql_select_db('moviesite', $db) or die(mysql_error($db)); //create the movie table $query = 'CREATE TABLE movie ( movie_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, movie_name VARCHAR(255) NOT NULL, movie_type TINYINT NOT NULL DEFAULT 0, movie_year SMALLINT UNSIGNED NOT NULL DEFAULT 0, movie_leadactor INTEGER UNSIGNED NOT NULL DEFAULT 0, movie_director INTEGER UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (movie_id), KEY movie_type (movie_type, movie_year) ) ENGINE=MyISAM'; mysql_query($query, $db) or die (mysql_error($db)); //create the movietype table $query = 'CREATE TABLE movietype ( movietype_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, movietype_label VARCHAR(100) NOT NULL, PRIMARY KEY (movietype_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); //create the people table $query = 'CREATE TABLE people ( people_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, people_fullname VARCHAR(255) NOT NULL, people_isactor TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, people_isdirector TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (people_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Movie database successfully created!'; ?> ******************************************************************** *********************************************************************** second file to load info into DB: <?php // connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //make sure you're using the correct database mysql_select_db('moviesite', $db) or die(mysql_error($db)); // insert data into the movie table $query = 'INSERT INTO movie (movie_id, movie_name, movie_type, movie_year, movie_leadactor, movie_director) VALUES (1, "Bruce Almighty", 5, 2003, 1, 2), (2, "Office Space", 5, 1999, 5, 6), (3, "Grand Canyon", 2, 1991, 4, 3)'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the movietype table $query = 'INSERT INTO movietype (movietype_id, movietype_label) VALUES (1,"Sci Fi"), (2, "Drama"), (3, "Adventure"), (4, "War"), (5, "Comedy"), (6, "Horror"), (7, "Action"), (8, "Kids")'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the people table $query = 'INSERT INTO people (people_id, people_fullname, people_isactor, people_isdirector) VALUES (1, "Jim Carrey", 1, 0), (2, "Tom Shadyac", 0, 1), (3, "Lawrence Kasdan", 0, 1), (4, "Kevin Kline", 1, 0), (5, "Ron Livingston", 1, 0), (6, "Mike Judge", 0, 1)'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Data inserted successfully!'; ?> ************************************************************** **************************************************************** MY CODE FOR THE QUESTION: <?php $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); mysql_select_db('moviesite', $db) or die(mysql_error($db)); //get our starting point for the query from the URL if (isset($_GET['offset'])) { $offset = $_GET['offset']; } else { $offset = 0; } //get the movie $query = 'SELECT movie_name, movie_year FROM movie ORDER BY movie_name LIMIT ' . $offset . ' , 1'; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); ?> <html> <head> <title><?php echo $row['movie_name']; ?></title> </head> <body> <table border = "1"> <tr> <th>Movie Name</th> <th>Year</th> </tr><tr> <td><?php echo $row['movie_name']; ?></td> <td><?php echo $row['movie_year']; ?></td> </tr> </table> <p> <a href="page.php?offset=0">Page 1</a>, <a href="page.php?offset=1">Page 2</a>, <a href="page.php?offset=2">Page 3</a> </p> </body> </html> Hello, How to customize print page in php ? I had a page, but I need to print it like an invoice look page. Thanks in advance Code: [Select] $query ="SELECT oneID FROM table WHERE table.PersonID = 'game.PlayerA'" ; $result = mysql_query($query); $row = mysql_fetch_array($result); $oneID = $row[0]; [code] If I then echo "$oneID" why does it not print anything? $result echos resource7 Hello.
i am totally new to php and just started to learn now. i just dont understand why the following code is not printing the username that i enter on the page.
Please note that the code itself is saved with the name "basicForm.php".
Thanks.
<html> I spent some time "Googling" today but all I found was how to create PDFs on the fly. What I wonder is if it is possible to print text on an existing PDF. And if so, could I get some pointer where to obtain this knowledge? Simply put. I have a PDF form that is not yet filled out. I would like to be able to look up an address and other information in a database, and use that information to print on the existing PDF file. Any help is much appreciated. Probably a simple solution, just one I'm not sure how to do it. I need the array to print out like this Code: [Select] array( 'name'=>'Store 1', 'address'=>'LA1' ), Right now, I got it to look like this Thanks in advance Code: [Select] Array ( [name] => 'Albertville Farmers Market', [address] => '116 Main Street Albertville, Alabama 35950' ) , Array ( [name] => 'Alexander City Downtown Market', [address] => 'Braod Street Alexander City, Alabama 35010' ) , How can I go about accomplishing this? Here is my code Code: [Select] $stores = array('name'=>"'$MktName',",'address'=>"'$address'"); echo "<pre>"; print_r($stores); echo "</pre>"; Is there a way to dynamically print the url of a web page once it loads? If so, how? This is for metadata purposes. Thanks! hihi, so I have the following, except it goes all the way up to server 400. Is there a way to make it print after each echo? As it is right now it will not print the entire list until all 400 servers are done echo "Server 01: " . count($server01->listaccts()) . " / 130" . "<br />" ; echo "Server 02: " . count($server02->listaccts()) . " / 130" . "<br />" ; echo "Server 03: " . count($server03->listaccts()) . " / 130" . "<br />" ; echo "Server 04: " . count($server04->listaccts()) . " / 130" . "<br />" ; echo "Server 05: " . count($server05->listaccts()) . " / 130" . "<br />" ; echo "Server 06: " . count($server06->listaccts()) . " / 130" . "<br />" ; echo "Server 07: " . count($server07->listaccts()) . " / 130" . "<br />" ; echo "Server 08: " . count($server08->listaccts()) . " / 130" . "<br />" ; thanks! I am trying to print pdf document from php code but error shows warning printer_write() couldn't allocate the printerjob 3003. Here my code
$printer = ("Printername");
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=346728.0 I'm working on a site where I've implemented a simple back end wysiwyg editor for content on a page. Then on the public page I run a php query to pull that content and display it. But doing this cancels out the css I have been using to split content into two columns. Is there a way to do this in php, or is there a way to circumvent the problem? ( also tried echoing the entire css style along with the query result - that didn't work either) The <p id='container_sub'> is what is split into two columns. I tried it outside of the query, and inside the query around where I echo results. Neither worked. Here's the basic php code, and further down the css that makes two columns: Code: [Select] <?php $pageid = '2'; // Formulate Query // This is the best way to perform an SQL query // For more examples, see mysql_real_escape_string() $query = sprintf("SELECT content FROM tbl_pages WHERE page_id='%s'", mysql_real_escape_string($pageid)); // Perform Query $result = mysql_query($query); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } // Use result // Attempting to print $result won't allow access to information in the resource // One of the mysql result functions must be used // See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. while ($row = mysql_fetch_assoc($result)) { echo "<p id='container_sub'>".$row['content']."</p>"; } // Free the resources associated with the result set // This is done automatically at the end of the script mysql_free_result($result); ?> The css.... Code: [Select] #container_sub {-moz-column-count: 2; -moz-column-gap: 25px; -webkit-column-count: 2; -webkit-column-gap: 20px; column-count: 2; column-gap: 20px;} #container_sub2 {-moz-column-count: 2; -moz-column-gap: 25px; -webkit-column-count: 2; -webkit-column-gap: 20px; column-count: 2; column-gap: 20px;} Hi all this might be a bit of a novice question, but if anyone knows the following i would be pleased and my eyes will too I am looking for a way to print on paper or pdf (en print the pdf in the end) all the stringfunctions on php.net (http://www.php.net/manual/en/ref.strings.php) If anyone knows a way to do so i would love to hear it, because after a few days behind a computer my eyes are about to go on strike. I am trying to get the code at the bottom of the script to print just once during the loop but it either doesn't print at all or repeats with the loop im am using if (!$i++) to print once and i works the first time i use it. foreach($uploadFilename as $key => $myvar) { if (!$i++) print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <title>Upload Complete....</title> </head> <body> <body onload=\"document.forms.formname.submit);\"> <form id=\"formname\" name=\"form1\" method=\"post\" action=\"reg5.php\">\n"; echo "<input type=\"hidden\" name=\"image$key\" value=\""; echo end(explode('/',$myvar)); echo "\">\n"; if (!$i++) print "</form> </body> </html>\n"; } Hi Guys I want to knw if its possible to send job to print with php. example, in my database I have a table called Letters which stores letters, while I loop through the table, I want to print each letter off, any examples available? Thank you This topic has been moved to Installation in Windows. http://www.phpfreaks.com/forums/index.php?topic=351150.0 Hello.
How would I print the following:
http://site.com/break?return=site2.com
So that I can set a button containing site2.com.
Example: <a href="site2.com"></a>
And so forth:
http://site.com/break?return=site3.com
Would print: <a href="site3.com"></a>
I am using function to insert into database. But the primary key is automatic and I used Quote $_SESSION['Tes_ID'] = mysql_insert_id(); to retrieve this. But now that I use function method. I am not sure how to retrieve the primary key on to the next page. Code: [Select] $value = modulesql($postVar1, $postVar2, $SessionVar1, $SessionVar2); $_SESSION['Tes_ID'] = mysql_insert_id(); echo $value, $_SESSION['Tes_ID']; Code: [Select] <?php function modulesql($Tes_Name, $Tes_Description, $Use_ID, $Sub_ID){ $con = OpenConnection(); mysql_select_db("examination", $con); $module = ("INSERT INTO test (`Tes_Name`, `Tes_Description`, `Use_ID`, `Sub_ID`) VALUES ($Tes_Name, $Tes_Description, $Use_ID, $Sub_ID)") or die('Cannot Execute:'. mysql_error()); CloseConnection($con); return $module; } ?> Have I lost you with my question?? |