PHP - Printing Variable Value In Side Eod
Hi guys,
I'm using this EOD thingi in order to print a table and get it PDF. I am using TCPDF and following their examples to get the PDF output. I need to print a php variable's value within the EOD. Can you please help me out. Below is the piece of code I'm running. Code: [Select] $tbl = <<<EOD <table cellspacing="0" cellpadding="1" border="1"> <tr> <td rowspan="4"><img src="images/m24.jpg"></td> <td align="right" width="150">From the desk of</td> <td>: $contat</td> </tr> <tr> <td align="right">E-Mail</td> <td>: $email</td> </tr> <tr> <td align="right">Telephone</td> <td>: $telephone</td> </tr> <tr> <td align="right">Mobile</td> <td>: $mobile</td> </tr> </table> EOD; the $variables are simply ignored. or even if I echo, there is no PHP value. Can you guys please shed some light on this issue. Pretty pleeeaaassseee Similar TutorialsHello, I need help with this issue, I am displaying <a href='index.php?cat=h & r'>text</a> when I do print $_GET['cat'] it only displays h, why ? Thanks Hey everyone, I've come around this problem quite a few times now, so I'm looking for a cleaner way to do what I always resort to. Here's my scenario: The following line is fairly straightforward: $sql_where = " WHERE SUBSTRING(name,1,1) = '".$c."' "; But sometimes I need to explode on some values, rising a need for multiple instances of the above, as in MYSQL's WHERE bla = 1 || WHERE bla = 2 || WHERE bla = 3 Of course, I could always write it out manually, like this: foreach($c as $v) { $sql_str .= "WHERE SUBSTRING(name,1,1) = '".$v."' "; } But I want my code to be more modular. The only solution I've been using so far is something like this: $where_start = "WHERE SUBSTRING(name,1,1) = '"; $where_end = "' "; foreach($c as $v) { $sql_str .= $where_start . $v . $where_end; } I find this technique a bit ridiculous and I was wondering if there was a similar method as say when you want to sprintf like this: $v = 'Bla bla %s bla'; sprintf($str, $v); So my question is basically this: is there any way to use a sprintf-like function that will concatenate variables inside variables? Thanks for any suggestions or input. Dear Friends, I am alot before doing the mixed content of php and HTML in single variable in PHP.. I could not get the data even though there is not SYNTAX error.. please look my code and advise
$htmlcontent .=" <tr> <td colspan=\"8\">".$details."></td> </tr>"; for($k=0;$k<count($reg_years[$details]);$k++) { $year = (int)($reg_years[$details][$k]); $singlecount[$year] = array_filter($result[$details],function($details1) use ($year){ return ($details1['reg_year'] == $year && $details1['bench_type'] == 1); }); $divisioncount[$year] = array_filter($result[$details],function($details2) use ($year){ return ($details2['reg_year'] == $year && $details2['bench_type'] == 2); }); $fullcount[$year] = array_filter($result[$details],function($details3) use ($year){ return ($details3['reg_year'] == $year && $details3['bench_type'] >= 3); }); $rpcount[$year] = array_filter($result[$details],function($rp) use ($year){ return ($rp['reg_year'] == $year && $rp['bench_type'] == 'RP'); }); $mjccount[$year] = array_filter($result[$details],function($mjc) use ($year){ return ($mjc['reg_year'] == $year && $mjc['bench_type'] == 'MJC'); }); $cocount[$year] = array_filter($result[$details],function($co) use ($year){ return ($co['reg_year'] == $year && $co['bench_type'] == 'X'); }); $total = 0; $total = (int)(count($singlecount[$year])+count($divisioncount[$year])+count($fullcount[$year])+count($rpcount[$year])+count($mjccount[$year])+count($cocount[$year])); $htmlcontent .=" <tr> <td>".$year."</td> <td align=\"center\"> if(count($singlecount[$year])>0) { echo (count($singlecount[$year])); } else { echo "-"; } </td> <td align=\"center\"> if(count($divisioncount[$year])>0) { ".count($divisioncount[$year])." } else { "-" } </td> <td align=\"center\"> if (count($fullcount[$year]) > 0) { echo (count($fullcount[$year])); } else { echo "-"; } </td > < td align =\"center\"> if(count($rpcount[$year])>0) { echo (count($rpcount[$year])); } else { echo " - "; } </td> <td align=\"center\"> if(count($mjccount[$year])>0) { echo (count($mjccount[$year])); } else { echo " - "; } </td> <td align=\"center\"> if(count($cocount[$year])>0) { echo (count($cocount[$year])); } else { echo " - "; } </td> <td align=\"center\"> echo $total; </td> </tr>"; } } $htmlcontent .= "</tbody></table>"; $mpdf = new \Mpdf\Mpdf(); $mpdf->WriteHTML($htmlcontent); $mpdf->Output(); Waiting for FAST reply
Thanks Anes I have 64 rows of players and want each User to be able to choose to bookmark an player, as well as unbookmark it too. I have a bookmark table set up, and each time a User decides to bookmark(+) or unbookmark(-) an player a row is created in the data table. (Matching the player ID and User ID) That's working fine. A query reads the most recent row for each player to determine if there is a + or - button next to each player. Testing the query and adding some dummy data, that part of it works too. However, the issue is the initial state, which I want to be a +. Once I go live, the table will be empty, nothing for the query to return/produce. How do I create an initial state of a + with no rows and have it not used or swapped out when Users start clicking + or -?
$query = "SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."'&&'". $id ."' = playerID ORDER BY b.id desc LIMIT 1 "; $results = mysqli_query($con,$query); echo mysqli_error($con); while($row = mysqli_fetch_assoc($results)) { echo $row['bookmark']; if($row['bookmark'] == 0) { echo '-'; // this is where a form goes to remove a bookmark } else { echo '+'; // this is where a form goes to add a bookmark } } I tried to get it with CASE, but I don't think that's the right path. I also looked at UNION. I was able to get it to produce an initial state of +, but it still printed the already made up sample data too (so I have three instances of ++ or +-). (Players 2, 4 and 4)
Here is the what the UNION query looked like: $query = "(SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."'&&'". $id ."' = playerID ORDER BY b.id desc LIMIT 1) UNION (SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."' ORDER BY p.id desc LIMIT 1) ";
I have a web portal which is scripted using client side scripting language i.e HTML. I want to create a login page in .php and want the other pages to be in .hmtl. Can i do so? I want to do this because i want the login password to be stored in a database. Also I want the password to get encrypted (by either MD5 javascript or OpenSSL ) when user enters it inside the login form. I cannot create the entire portal in php because my portal makes use of C code. And php doesn't have an interface with C language. Can a user get directed to a .html page after a secure login from login.php page ? My main aim is to secure the access to my web portal using a password. I tried to authenticate the login using javascript where the password was stored in an array. But i feel any one having moderate knowledge can easily break that password. Any help would be greatly appreciated!! I’m trying to write a post-panel where the user can see the preview of his post to the right of the text area he’s writing into. I tried the following into a file called writepost.php : <?php $text=(isset($_GET['message']))?$_GET['message']:''; $formatted_text=nl2br(stripslashes(htmlspecialchars($text))); echo '<form method="post" action="proceedtopost.php?>'. '<table>'. '<td style width="50%"><tr>'. '<fieldset> Write your post here : <br> <textarea cols="50" rows="12" '. 'id="message" name="message">'.$text.'</textarea>'. '</fieldset> <p> '. '<input type="submit" name="submit" formaction="writepost.php" value="Preview" /> '. '<input type="submit" name="submit" value="Sent" /> '. '</p>'. '</td>'. '<td>'. '<fieldset> Your post will appear as follows :<br><p> '. $formatted_text. '</fieldset>'. '</td></tr>'. '</table>'. '</form>';There are several things wrong with this code : 1) When the user hits the "Preview" button, I expect writepost.php to be reloaded (this is what happens), and the current content of the textarea to be stored in $_GET['message'] (this is not what happens). 2) Why does my browser output the preview part under the text area (or in other words outputs the HTML table as a single column of two cells), when I insist in my HTML code for the table to be displayed as a single row ? need a little help guys! I use the script below to display profile images, trouble is it shows 1 on top of the other, and i need it to double up 2 profile images on top of 2 profile images ect any ideas how i can do this. require("./include/mysqldb.php"); $con = mysql_connect("$dbhost","$dbuser","$dbpass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$dbame", $con); $result = mysql_query("SELECT * FROM Search_profiles_up WHERE upgrade_one ='1' ORDER BY RAND() LIMIT 40"); print "<table width=\"293\" height=\"111\" border=\"0\"> <tr>\n"; while($row = mysql_fetch_array($result)) { print "<td width=\"142\"><img src=" . $row['search_small_image'] . " width=\"144\" height=\"169\" /></td>\n"; print " </tr>\n"; print " <tr> \n"; print "<td>" . $row['star'] . "</td>\n"; print " </tr>\n"; print " <tr>\n"; print "<td>" . $row['username_search'] . "</td>\n"; print " </tr>\n"; print " <tr> \n"; print "<td>" . $row['phone_search'] . "</td>\n"; print " </tr> \n"; } print "</table>"; mysql_close($con); ?> is it true that all the server side code runs before the client side code when accessing a webpage? if that is true, what about PHP code that is embedded inside HTML tags? wouldn't that result in an error a lot of times? I have a few tables in php and want them to be side by side instead of under each other like below. I have spent about 2 days trying to figure it out, Anyone got a clue? This is the code im using <?php $con = mysql_connect("localhost","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("People", $con); $result = mysql_query("SELECT * FROM wang"); echo "<table border='1'> <tr> <th>Wang Total Report</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['got'] . "</td>"; echo "</tr>"; } echo "</table>"; $result2 = mysql_query("SELECT * FROM miah"); echo "<table border='1'> <tr> <th>Miah Total Report</th> </tr>"; while($row = mysql_fetch_array($result2)) { echo "<tr>"; echo "<td>" . $row['got'] . "</td>"; echo "</tr>"; } echo "</table>"; $result3 = mysql_query("SELECT * FROM vinc"); echo "<table border='1'> <tr> <th>Vinc Total Report</th> </tr>"; while($row = mysql_fetch_array($result3)) { echo "<tr>"; echo "<td>" . $row['got'] . "</td>"; echo "</tr>"; } echo "</table>"; $result4 = mysql_query("SELECT * FROM ketarie"); echo "<table border='1'> <tr> <th>Ketarie Report</th> </tr>"; while($row = mysql_fetch_array($result4)) { echo "<tr>"; echo "<td>" . $row['got'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Hi there, I'm new in PHP, my output is in at table, I designed it already, now I want to print it..how can I do that ? do i need JS ? hi everyone I have a small user & business Directory and for it, I use a .htaccess ReWrite. My .htaccess file looks like Code: [Select] RewriteEngine On RewriteRule ^([^/.]+)$ index.php?q=$1 [QSA,L] so basically when I run Code: [Select] http://localhost/Johnsons/ then it treats that like Code: [Select] http://localhost/index.php?q=Johnsons I then do a PHP Query to find the result, I use the following; print "You looked up $_GET['q']"; $result = mysql_query("SELECT `name` FROM `directory` WHERE `name` = '".$_GET['q']."'"); while($row = mysql_fetch_array($result)) { print $row['name']; } this all works fine. The problem I now have is that I have been sent some new data in a SQL database import file and it contains entries such as Dugāriy T-ī-Corā but when I try and run http://localhost/Dugāriy/ or http://localhost/T-ī-Corā/ it does not return the correct value and instead it either misses characters or it exchanges one character for another, (ā is swapped "a" as an example). It seems this is due to a mix of Special Characters & Accents within words such as ā ū ī I have tried altering the META charset tag without any luck, I have also tried print utf8_encode($_GET['q']); print urlencode($_GET['q']); but nothing seems to work. Any idea on how I can solve this? Thanks very much J hello all, i know that php is server side. if i have a printer attached to the server, can i have users press a button and have it print there? I have the following php script and get data from a database and prints in on a page however it does not print a carriage return. Why can this be? The script: <?php include "database.inc"; mysql_select_db("php", $connection); $result = mysql_query("SELECT * FROM orders", $connection); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { foreach ($row as $attribute) print "($attribute)"; print "\n"; } ?> I have a directory that I would like to allow users to print to PDF format for download. How can I do this and where do I start? I've got a database file from sqlite, there is a multidimensional array in it with 10 metals. I just want two print out each element in a table It won't get all the separate data inside a HEREDOC foreach ($product_prices as $metal => $prices) "<tr><td>$metal</td><td align = 'right'>". round($prices[wire][28]*$l_conv*$w_conv,4). "<tr><td>$metal</td><td align = 'right'>". round($prices[wire][36]*$l_conv*$w_conv,4). "<tr><td>$metal</td><td align = 'right'>". round($prices[wire][45]*$l_conv*$w_conv,4). "<tr><td>$metal</td><td align = 'right'>". round($prices[dust][100]*$l_conv*$w_conv,4). "<tr><td>$metal</td><td align = 'right'>". round($prices[dust][10]*$l_conv*$w_conv,4). "<tr><td>$metal</td><td align = 'right'>". round($prices[dust][1]*$l_conv*$w_conv,4). "</td></tr>"; Hi, I really need to find a way to print the code below in php. Code: [Select] <script> $(document).ready(function() { $.sticky('The page has loaded!'); }); </script> i tried Code: [Select] print"<script> $(document).ready(function() { $.sticky('The page has loaded!'); });"; </script> any help would be great. Hi, I want to echo an image depending on a value. This is the code I'm using Code: [Select] <?php if ($row_cliente_RS['estadofactura_titulo']) == 'yes' echo '<img src="img/pagada.jpg" width="70" height="15">'; ?>...but nothing echoes. What am I doing wrong? Thanks is there a way to make a link or button that will print the current page, but only page 1, landscape with no headers or footers? or print between two tags? thanks Hello,
I am trying to print the invoice in pdf, using fpdf. i am not getting how to do it. I am able to display line items , but its not in proper format. I tried changing X, Y positions, but its not going into my head . Also i want to display Logo and address in left side, invoice number and order date in right side.
Here is the code i have done so far... Please please help me in this
<?php require('includes/fpdf/fpdf.php'); //Connect to your database include("connect/DB_Connect.php"); $id = $_GET['id']; //Select the Products you want to show in your PDF file $result=mysql_query("select invoice_no, order_no, order_date, completion_date, artwork, customer_po, order_quantity, comments, order_amount from invoice where invoice_no='".$id."' ") or die(mysql_error()); $number_of_products = mysql_numrows($result); //Initialize the 3 columns and the total $column_order_date = ""; $column_order_no = ""; $column_artwork = ""; $column_cpo = ""; $column_order_quantity = ""; $column_order_amount = ""; $column_comments = ""; $total = 0; //For each row, add the field to the corresponding column while($row = mysql_fetch_array($result)) { $order_date = $row["order_date"]; $order_no = $row["order_no"]; $artwork = $row['artwork']; $cpo = $row['customer_po']; $oquantity = $row['order_quantity']; $oamount = $row['order_amount']; $comments = $row['comments']; //$price_to_show = number_format($row["Price"],',','.','.'); $column_order_date = $column_order_date.$order_date."\n"; $column_order_no = $column_order_no.$order_no."\n"; $column_artwork = $column_artwork.$artwork."\n"; $column_cpo = $column_cpo.$cpo."\n"; $column_order_quantity = $column_order_quantity.$oquantity."\n"; $column_order_amount = $column_order_amount.$oamount."\n"; $column_comments = $column_comments.$comments."\n"; //Sum all the Prices (TOTAL) $total = $total+$oamount; } mysql_close(); //Create a new PDF file $pdf=new FPDF(); $pdf->AddPage(); //Fields Name position $Y_Fields_Name_position = 20; //Table position, under Fields Name $Y_Table_Position = 26; //First create each Field Name //Gray color filling each Field Name box $pdf->SetFillColor(232,232,232); //Bold Font for Field Name $pdf->SetFont('Arial','B',12); $pdf->SetY($Y_Fields_Name_position); $pdf->SetX(5); $pdf->Cell(25,6,'Order Date',1,0,'L',1); $pdf->SetX(30); $pdf->Cell(50,6,'Graphixide Order No',1,0,'L',1); $pdf->SetX(75); $pdf->Cell(40,6,'Artwork',1,0,'L',1); $pdf->SetX(110); $pdf->Cell(20,6,'PO #',1,0,'L',1); $pdf->SetX(130); $pdf->Cell(20,6,'Quantity',1,0,'L',1); $pdf->SetX(150); $pdf->Cell(25,6,'Amount',1,0,'L',1); $pdf->SetX(175); $pdf->Cell(25,6,'Comments',1,0,'L',1); //Now show the 3 columns $pdf->SetFont('Arial','',12); $pdf->SetY($Y_Table_Position); $pdf->SetX(5); $pdf->MultiCell(25,6,$column_order_date,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(30); $pdf->MultiCell(80,6,$column_order_no,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(75); $pdf->MultiCell(40,6,$column_artwork,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(110); $pdf->MultiCell(20,9,$column_cpo,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(130); $pdf->MultiCell(20,6,$column_order_quantity,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(150); $pdf->MultiCell(75,6,$column_order_amount,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(175); $pdf->MultiCell(25,10,$column_comments,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(150); $pdf->MultiCell(130,6,'$ '.$total,1,'R'); //Create lines (boxes) for each ROW (Product) //If you don't use the following code, you don't create the lines separating each row $i = 0; while ($i < $number_of_products) { $pdf->SetX(45); $pdf->MultiCell(120,6,'',1); $i = $i +1; } $pdf->Output(); ?>Here is the output of this code ss.PNG 32.3KB 7 downloads |