PHP - Creating Pdf Files With Table Inside
I need php code that creates pdf file with table inside.
Similar Tutorialsi am able to create csv's and can do so with no trouble .. but what i am having difficulty with is being able to auto save the csv and then email it all in one script. anybody every dealt with something like this? Hi All
I have a a directory website but numereous listings don't have their own website so they are requesting a single page to show a summary of their business and products.
I know how to do most of it the part I am unsure of is:
I have a form where they upload text, images, etc to a database and upload the images. what I would like to do is to save it as a file under a subdirectory. Is it possible to save a file php file using php
Thank you in advance
Lional
I'm looking for any guidance on how to dynamically create css files. I want users to be able to select colors for fonts/backgrounds, borders, etc. from a form which they will submit and it will create a css file and put it in a certain folder. Can someone point me in the right direction? Hi all. I work at a university library where I am the default web coding person. Although I know far more than anyone else who works here, my skills are not exactly at the guru level. At the moment I'm fighting with libcURL, trying to use a (secured) submission form to upload files from faculty to a remote server. (Of course, I had one that worked which uploaded to a safe directory on our web server, but that was deemed insufficient. ) I have managed to connect to the FTP server with cURL, and I have managed to create files on that server which have the same name as the files uploaded in the form. However, for some reason that escapes me, the files created on the FTP server are empty files. The server is using Server 2003 and IIS 6, and I am able to successfully upload to it using Filezilla, so I suspect the problem is with my code. I have searched Google for help with this, but all I can get is examples of how to upload which are the same as the one I already have, and how to delete a file using cURL, which is not what I want to do. The problem does seem to be somewhere in the file transfer process. die($_Files['syllabus']['size']); gives me the correct file size, and I tried moving the file onto the (local) webserver before transfering it via FTP, and the server one was fine--the FTPed version still showed up empty. If anybody has any idea what's going on, your help would be greatly appreciated. //the syllabus file from the form $syllabus=$_FILES['syllabus']['name']; //the syllabus as it will appear on the server (to make it a clickable link in the e-mail sent //to our processing librarian later in the script. Removing this did not fix the problem anyway.) $REMsyllabus = str_replace(' ', '-', $_FILES['syllabus']['name']); //formatted URL, with FTP information defined just before the syllabus and REMsyllabus files. $SYLremoteurl = "ftp://${ftpuser}:${ftppasswd}@${ftpserver}/${REMsyllabus}"; $ch = curl_init(); $fp = fopen($syllabus, 'r'); curl_setopt($ch, CURLOPT_URL, $SYLremoteurl); curl_setopt($ch, CURLOPT_UPLOAD, 1); curl_setopt($ch, CURLOPT_INFILE, $fp); curl_setopt($ch, CURLOPT_INFILESIZE, $_FILES['syllabus']['size']); curl_exec ($ch); $error_no = curl_errno($ch); curl_close ($ch); if ($error_no == 0) { $error = 'File uploaded succesfully.'; } //if else { $error = 'File upload error: '.$error_no; }//else } //if else { $error = 'No syllabus file selected.'; }//else This is pretty much the example code from the libcURL PHP section web page, so I'm not entirely sure why it doesn't work. Thanks in advance for any help anybody can offer! Hi Everyone, I'm semi-new to php and trying to create a site where I have only one includes file for my navigation (main_nav.inc) and 2-3 includes files (main_template.inc) that act as templates. I then call the the nav and the template in my index.php file. Everything was working fine until I decided I should use php have my links appear active depending on which page the user is on. Everything works totally fine if I insert the code for my nav (including both the html and php) into my main_template.inc file but when I make that code into it's own includes file (main_nav.inc), I get an error. I believe the issue is with using both single and double quotes in my code and wrapping that code in single quotes in my main_nav.inc file. Here is the code from my main_nav.inc file: <?php $main_nav = ' <div id="mainNav"><ul id="mainNav"> <li><a href="index.php" <?php if ($page=='index.php') { ?> class="active" <?php } ?>>Welcome</a></li> <li><a href="healthcare.php" <?php if ($page=='healthcare.php') { ?> class="active" <?php } ?>>Healthcare</a></li> </ul></div> '; // end main_nav ?> I think that since the code is wrapped in single quotes, I can only use double quotes in my code. This is the only difference I can figure out between inserting the code into the template directly (which works perfectly fine) and inserting it as a separate inc file. When I use the main_nav.inc file I get the following error: Parse error: syntax error, unexpected T_STRING in /home/content/k/a/l/kalilaks3/html/includes/main_nav.inc on line 11 I tried changing the quotes around ($page=='index.php') to ($page=="index.php") but that causes the browser to literally read the name of the link a class="active">Welcome I also tried variations of escaping quotes such as ($page==\"index.php\") and even escaping the other quotes and wrapping everything in double quotes as opposed to single quotes. Here is my code for my main_template.inc file <?php $page = basename($_SERVER['SCRIPT_NAME']); $page_title = "Welcome"; include_once ("includes/main_nav.inc"); // sets variable include_once ("home_template.inc"); // sets all variables ?> And here is my index.php file: <!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 content="healthcare" name="keywords"></meta> <meta content="healthcare" name="description"></meta> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title><?php echo $page_title; ?></title> <link rel = "stylesheet" href = "_css/layout.css"></link> <script type="text/javascript" src="scripts/script.js"></script> </head> <body> <div id = "header"><div id = "globalHeader"> <?php echo $main_nav; ?> </div></div> </body> </html> Any help or suggestions would be greatly appreciated!!! I would love to get this figured out so that I only have to create my navigation once for all my sites! I know this code works
INSERT INTO archive_table SELECT * FROM original_table WHERE id = 1But i want to also add the current date whenever i copy the data into a new table. Thanks in advance Hi everyone. i'm trying to write an if statement for several scenerios 1. if the date entered in '$DateDue' is overdue, meaning greater than todays date, then display the word 'Late'. 2. if the date entered in '$DateDue' is not yet past, meaning its greater than todays date, then display the word 'ok'. 3. if the date entered in '$DateDue' is within a week of todays date, then display the word 'warning' the code snippet below is my partial script. it runs perfectly without embedding the 'php if statement' on the first td row. So my problems a 1. how to embed a php if statement in table results and 2. have OK, LATE or WARNING to be displayed based on if $DateDue expires or not. there are no errors in the code below, it just echos the line '<?php if ($DataDue > CURDATE()) {echo "OK";} elseif ($DateDue < CURDATE()) {echo "LATE";} else {echo "Warning";}?>' instead of displaying OK, LATE or Warning. I'd appreciate any assistance you could provide. thanks. Code: [Select] // echo out the contents of each row into a table echo "<tr>"; echo '<td nowrap><?php if ($DataDue > CURDATE()) {echo "OK";} elseif ($DateDue < CURDATE()) {echo "LATE";} else {echo "Warning";}?>' . mysql_result($result, $i, 'DateDue') . '</td>'; echo '<td nowrap>' . mysql_result($result, $i, 'Description') . '</td>'; echo '<td nowrap>' . mysql_result($result, $i, 'CompanyName') . '</td>'; echo "</tr>"; Hi guys, i cannot figure out what is wrong with this and I hope you could help figure it out? This is the code I am using - Code: [Select] $create_cart_table = "CREATE TABLE `". $string ."` (cart_id int NOT NULL AUTO_INCREMENT, PRIMARY KEY(cart_id), item_name VARCHAR(1000) NOT NULL, item_id VARCHAR(30) NOT NULL, price VARCHAR(30) NOT NULL, date_time TIMESTAMP(100) NOT NULL CURRENT_TIMESTAMP, quantity VARCHAR(100) NOT NULL)"; $set_cart_table = mysql_query($create_cart_table); $string is defined above and there are no database connection warnings etc coming up and I am lost as to how the heck this isn't working? It was working for about an hour when I first made the script but now it is not. Please help? I have a string (Product1-Product2-Product3#2-4-1) where Product1-Product2-Product3 are products and 2-4-1 are quantities. I am struggling to make a table out of it where products and quantities are shown in rows. here is what i tried. Code: [Select] list($products, $quantities) = explode("#", $specs); //to separate Quantities from products <?php foreach(preg_split("/-/", $products) as $product_list) { ?> <tr> <td> <?php echo $product_list; ?></td><? } ?> <?php foreach(preg_split("/-/", $quantities) as $qtylist) { ?> <td></td> <td><?php echo $qtylist; ?></td> <?php } ?> </tr> <?php //} ?> </table> I know something is wrong with this and its giving me unexpected reasult Please help me create a table out of the above string. Many Thanks -Max Hi there, trying to create a function more out of lazyness an timesaving than anything im sure it has to do with something combining the use of INSERT and x++ in an array, but im failing at figuring out the right way of doing it to achieve the right combination of effects. in simple need to create a 600x600 grid of co-ordinates where x starts at 1, ending in 600 with y starting at 1 and ending in 600 so basically a cubed set of entrys, (360,000 rows) not even sure thats possible lol.. the table only needs to contain the colums of id, x , y , ownerid (where id is auto inc) any suggestions, as you can tell its a pain-staking long case of affairs to create with a manual VERY long sql statement, trying to figure out a better way of doing this. help please? Thanks What I want to do is create a table out of records from a table that shows an image and a radio button under the image (so I would imagine it would be in 2 rows). I want it to have 3 columns across. Here's what I have to get and output the results: $fabricsql = "SELECT * FROM Fabric f, Images i WHERE f.SKU = i.SKU"; //echo $fabricsql; $fabricResult = mysql_query($fabricsql); $i=0; while($fabricAssoc = mysql_fetch_assoc($fabricResult)){ //echo $fabricAssoc['SKU']. "+ ".$fabricAssoc['Name']; echo "<a href=\"\"><img src='../../".$fabricAssoc['ThumbPath']."' alt='".$fabricAssoc['Description']."' width='".$fabricAssoc['ThumbWidth']."' /></a><br /> <input type=\"radio\" name=\"fabricSelect\" value='".$fabricAssoc['SKU']."' id=\"RadioGroup1_".$i."\" /><br /><br />"; $i++; } Any help is much appreciated. I'm not even sure this is the best way to go about this so any suggestions are appreciated. It's about making a form for a web page. Which is better? Using table or divs? Which do you use? <form action='a.php' method='post'> <table> ............. </table> </form> <form action='a.php' method='post'> <div> ............. </div> </form> hello, im trying to add a hyperlink that launches in a new window to the following (in the last column) any ideas? Code: [Select] echo "<tr>"; echo "<td align='center'>" . $row["ID"] . "</td>"; echo "<td align='center'>" . $row["Name"] . "</td>"; echo "<td align='center'>" . $row["jobNO"] . "</td>"; echo "<td align='center'>" . $epn . "</td>"; echo "<td align='center'>" . $cname . "</td>"; echo "<td align='center'>" . $cadd . "</td>"; //want to add a hyperlink here echo "</tr>"; } echo "</table>"; } I am trying to create something similar to a bar chart, using a html table based on the values stored in an array. However, I cannot seem to get the next column to begin after printing the number at the bottom. I can get it going horizontal, but I would like to create a vertical version. If anyone can provide me with help I would greatly appreciate it. Code: [Select] <?php $month = date("n"); //numeric representation of month (1-12) $year = date("Y"); //4 digit representation of year $day = date("d"); //numeric representation of the day of the month // constant variable to determine how many days alive according to the current date define('DAYS_ALIVE',(($year - 1902) * 365.24) + (($month - 1) * 30.5 )+ ($day - 1)); $divident = 100000; // variable for modulus $divider = 10000; // variable to shrink the divident for($i = 0; $i <= 4; $i++) // for loop to fill the array with days alive { $daysArray[$i]= floor((DAYS_ALIVE % $divident)/$divider); //calculates the single digit to store in array $divident= $divident/10; //after every iteration the divident is decreased $divider= $divider/10; //after every iteration the divider is decreased } echo "<table border='2' width='100%'>"; $arraySize = count($daysArray); //variable for the array size for($k=0;$k<=$arraySize-1;$k++) { echo "<tr>"; for($j=1;$j<=$daysArray[$k];$j++) { echo "<td> * </td>"; } echo "<td>$daysArray[$k]</td>"; } echo "</table>"; ?> What I want is something like this. I'm in the process of creating a webage that shows latest scores and an updated league table for soccer/football matches like the bbc sports website does. I have the database set up with a form to update and display latest score all work well apart from if i update a score like the following teamA 1 teamB 0 it updates table to give teamA 3 points based on the current score however if teamA score again teamA 2 teamB 0 it updates table again but gives teamA another 3 points which is not correct so i need a way to stop it happening. thought about it for a while and only thing i can come up with is some maths to compare the values of score for each team and add/remove points as dependent on current score. Anyone got something similar to this I made a table that gets the rows from a mysql table and lists them with the information on each row. What i need is an edit button at the end of the row so i can click it to change the data. What i want it to do is pop up a new window (child) that i can easily change the data by a text box, drop down menu, etc. and click submit to update it on the table. What i also need is a second button that will completely remove the data from that row in the table. I am still learning php and html and have no knowledge of javascript so any help would be appreciated! Windows 7, Apache 2.2.21 / PHP 5.3.5. What does the below error mean? I am new and fighting through this particular piece of code. Thank you in advance for your help. Warning: mysql() expects parameter 3 to be resource, string given in C:\website\do_createtable.php on line 3 <? $db_name="booster"; $connection=mysql("localhost", "USERNAME", "PASSWORD") or die (mysql_error()); $db=mysql_select_db($db_name, $connection) or die (mysql_error()); $sql="CREATE TABLE $_POST[table_name] ("; for ($i=0; $i < count($_POST[field_name]); $i++) { $sql .= $_POST[field_name][$i]." ".$_POST[field_type][$i]; if ($_POST[field_length][$i] != "") { $sql .= " (".$_POST[field_length][$i]."),"; } else { $sql .= ","; } } $sql=substr($sql,0,-1); $sql .= ")"; $result=mysql_query($sql,$connection) or die (mysql_error()); if ($result) { $msg="<P>".$_POST[table_name]." has been created!</P>"; } ?> <HTML> <HEAD> <TITLE>Create a Database Table: Step 3</TITLE> </HEAD> <BODY> <h1>Adding table to <? echo "$db_name"; ?>....</h1> <? echo "$msg"; ?> </BODY> </HTML> HI. Im new to database. I didnt know how to use bridge table. In my bridge table i have SubjectID and studentID, PK from student table and subject table. In my subject table have SubjectID, SubjectName and SubjectLecturer while in my student table have studentID,,studentName,IC,studentFac,studentPhone, studentEmail,pswd,studentAddress. I didnt know where is the wrong part because when i click my form which is enroll button, this enroll page blank Can someone check my coding ? Help ?
<!DOCTYPE HTML> <html> <head> <?php error_reporting(0); session_start(); if (!isset($_SESSION['studentID'])) { $_SESSION['studentID'] = $_POST['studentID']; $_SESSION['pswd'] = $_POST['pswd']; } include("connect.php"); $sql = "SELECT * FROM student WHERE studentID='".$_SESSION['studentID']."' AND pswd='".$_SESSION['pswd']."'"; $result = mysql_query($sql); $row = mysql_num_rows($result); if ($row == 0) { echo "Login fail Try again <a href='http://bytes.com/'>here</a>"; ?> <meta http-equiv="refresh" content="0;userlogin.php" /> <?php } else { $row = mysql_fetch_assoc($result); } ?> <meta charset="UTF-8"> <title>E-Education portal</title> <link href="http://bytes.com/style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="header"></ div> <?php if(isset($_POST["submit"])) { session_start(); include("connect.php"); $SubjectID = $_POST['SubjectID']; $SubjectName = $_POST['SubjectName']; $SubjectLecturer = $_POST['SubjectLecturer']; $Subject= "SELECT SubjectID FROM Subject WHERE SubjectID='$SubjectID'"; $queryssubject=mysql_query($subject) or die(mysql_error); $record=mysql_num_rows($querysubject); if($record==1) { header ('Location: studentSubject.php'); } else if($record<1) { if(substr($subjectID)) { $insertIntoSubject= "INSERT INTO Subject ('SubjectID', 'SubjectName', 'SubjectLecturer') VALUES ('$SubjectID','$SubjectName','$SubjectLecturer')"; $result1=mysql_query($insertIntoSubject) or die(mysql_error()); $insertIntobridge="INSERT INTO `bridge`(`SubjectID`, `studentID`) VALUES ('$SubjectID', '$studentID')"; $result2=mysql_query($insertIntobridge)or die(mysql_error()); $insertIntostudent="INSERT INTO student (`studentID`, `studentName`, `IC`, `studentFac`, `studentPhone`, `studentEmail`, `pswd`, `studentAddress') VALUES ('$studentID', '$studentName', '$IC', '$studentFac', '$studentPhone', '$studentEmail', 'abc123', '$studentAddress')"; $result3=mysql_query($insertIntostudent)or die(mysql_error()); if ($result1 && $result2 && $result3) { header ('Location: studentSubject.php'); } } else echo 'insert error'; } else { echo "<script type='text/javascript'> alert('Data Updated!') location.href='homestudent.php' </script>"; } mysql_close($conn); } ?> Can someone five me the correct code or format to use that will allow my TINYINT columns to carry TWO decimal places when creating my table? I have a script for creating the table and columns, but only recently learned that I need to ADD the TWO decimal place FUNCTION in order to get whole dollar values to display WITH the trailing zeros (ie.:2.00). I don't expect to need any values greater than xxx.xx in my columns, I'm just not clear on how to get the desired script when running the initial CREAT script. Thanks |