How to display devnagri font from INPUT to a php page - php

I have one php page in which I have changed font for input to devnagri. I need to display it in next php page and also need to insert those to mysql.
first page index.php contains this details......
<table width="535" height="54" border="1">
<tbody>
<tr>
<td height="23">नाम</td>
<td><input type="text" name="name" id="name" style="font-family: Preeti">
</td>
</tr>
<tr>
<td height="23">काम</td>
<td><input type="text" name="job" id="job" style="font-family: Preeti">
</td>
</tr>
</tbody>
</table>
my second page post.php contains
<table width="535" height="54" border="1">
<tbody>
<tr>
<td height="23">नाम</td>
<td><?php
echo $_POST['name'];
?></td>
</tr>
<tr>
<td height="23">काम</td>
<td><?php
echo $_POST['job'];
?></td>
</tr>
</tbody>
</table>
when I type कला in name and खेप in job input
it displays relative english letters on the 2nd page .....
where as I need to display as it displays in input.
I also need to insert those input to mysql and again need to display those mysql data to another page....
I am not getting the way to display and stuck at this point so insert and select query is yet to be done....
Need help to figure it out.

Thanx a lot Phil.
<table width="535" height="54" border="1">
<tbody>
<tr>
<td height="23">नाम</td>
<td style="font-family: Preeti"><?php
echo $_POST['name'];
?></td>
</tr>
<tr>
<td height="23">काम</td>
<td style="font-family: Preeti"><?php
echo $_POST['job'];
?></td>
</tr>
</tbody>
</table>
It has displayed preeti font...
Still INSERT and SELECT query is remaining.

Related

Print HTML dynamically on a page via PHP based on Condition

I want to print a section of a table if the data is available in JSON file for it. And if the data is not there and it shouldn't do anything.
So, far what I am doing is as below. Checking is the account_type is parent and then generate the table rows with corresponding data.
<?php
$str = file_get_contents('test.json');
$json = json_decode($str, true);
$parent= strtr('<tr>
<td colspan="2" style="color:#263a80;font-size:19px;padding-bottom:20px;padding-top:20px">Parent Information</td>
</tr>
<tr>
<td style="width:30%;font-weight:700;padding-bottom:10px">First Name</td>
<td>#fname</td>
</tr>
<tr>
<td style="width:30%;font-weight:700;padding-bottom:10px">Last Name</td>
<td>#lname</td>
</tr>
<tr>
<td style="width:30%;font-weight:700;padding-bottom:10px">Mobile Number</td>
<td>#mobile</td>
</tr>
<tr>
<td style="width:30%;font-weight:700;padding-bottom:10px">Email</td>
<td><a #email target="_blank" rel="noreferrer">#email</a></td>
</tr>
<tr>
<td style="width:30%;font-weight:700;padding-bottom:10px">Country</td>
<td>#country</td>
</tr>
<tr>
<td style="width:30%;font-weight:700;padding-bottom:10px">State</td>
<td>#state</td>
</tr>
<tr>
<td style="width:30%;font-weight:700;padding-bottom:10px">City</td>
<td>#city</td>
</tr>
<tr>
<td style="width:30%;font-weight:700;padding-bottom:10px">Postal Code</td>
<td>#pcode</td>
</tr>
<tr>
<td style="width:30%;font-weight:700;padding-bottom:10px">Full Home Address</td>
<td>#address</td>
</tr>', ["#fname"=>$json["json"]["register_session_1"]["first_name"],
"#lname"=>$json["json"]["register_session_1"]["last_name"],
"#mobile"=>$json["json"]["register_session_1"]["mobile"],
"#email"=>$json["json"]["register_session_1"]["email"],
"#country"=>$json["json"]["register_session_1"]["country"],
"#state"=>$json["json"]["register_session_1"]["state_online"],
"#city"=>$json["json"]["register_session_1"]["city"],
"#pcode"=>$json["json"]["register_session_1"]["postal_code"],
"#address"=>$json["json"]["register_session_1"]["address"]
]);
if ($json["json"]["register_session_1"]["account_type"]==="parent"){
echo $parent;
}
else {
echo "hahahah";
}
?>
Problem is that it printing the table data anyway. I don't know what I am doing wrong. The if-else condition is not working.
I have this code and I can't seem to figure out why. I have added this code in between the <table></table> tag.

Updating MySQL table with PHP and checkboxes in WordPress

On my website enter link description here I'm using checkbox buttons for updating data in a MySql table (pages are with login) and use this code in PHP that's working fine:
<?php
$sql="SELECT *,cast(DATE_FORMAT(datum,'%d-%m-%Y ') AS CHAR(32)) as datum FROM wedstrijden";
$result=mysqli_query($db,$sql);
$count=mysqli_num_rows($result);
?>
<table style="width: 100%;">
<tr>
<td><form name="frmactive" action="1fanionchange.php" method="post">
<tr>
<td colspan="6"><input name="activate" type="submit" id="activate" value="Open selected" />
</tr>
<tr>
<td> </td>
</tr><tr>
<td align="center"><!--<input type="checkbox" name="allbox" title="Select or Deselct ALL" style="background-color:#ccc;"/> --></td>
<td align="center"><strong>Id</strong></td>
<td align="center"><strong>Datum</strong></td>
<td align="center"><strong>Uur</strong></td>
<td align="center"><strong>Thuis</strong></td>
<td align="center"><strong>Uit</strong></td>
</tr>
<?php
while($rows=mysqli_fetch_array($result)){
?>
<tr>
<td align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td>
<td align="center"><? echo $rows['id']; ?></td>
<td align="center"><? echo $rows['datum']; ?></td>
<td align="center"><? echo $rows['uur']; ?></td>
<td align="center"><? echo zoeknaam($rows['thuisploeg']); ?></td>
<td align="center"><? echo zoeknaam($rows['uitploeg']); ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="6"><input name="activate" type="submit" id="activate" value="Open selected" />
</tr>
</form>
</td>
</tr>
</table>
But when I use the same code in WordPress (I'm trying to make the website in WordPress), it is not working and no records are displayed. When I try to find the number of rows using:
echo $count. "<br />";
I get the correct number of records in that table. But the records are not showed?
Any idea how to handle the problem? Thanks.
PS. I use the plugin phpexec in WordPress!
In WordPress it is suggested to use the WordPress builtin Queries. So that it can have maximum compatibility with the server too it is hosted.
Reference: https://codex.wordpress.org/Class_Reference/wpdb
global $wpdb;
And all the following functions will attach the database that is defined as global..
$wpdb->insert('wp_submitted_form', array(
'name' => 'Kumkum',
'email' => 'kumkum#gmail.com',
'phone' => '3456734567', // ... and so on
));
Like wise you can use it for Update / Select as per your wish and it is considered as the best one according to WordPress..

popup page php data doesn't show on submit

i have a table has php variables fetched from mysql , the table is inside a Form , what i am trying to do is to display page to be printed for the user with a an invoice style layout, i tried to make a behavior that when the FORM Is submitted , a pop up page will come display the php variables data , which is doesn't work at all , i tried to display the content of popup page inside a regluar page , it worked ! , which means there is no problem with my php code .
here is the form page code :
<form action="../../printInvoice.php" method="post" onsubmit="MM_openBrWindow('../../printInvoice.php','Invoice','status=yes,scrollbars=yes')">
<table width="100%" border="0">
<tr>
<td align="left">Invoice:</td>
</tr>
<tr>
<td width="12%" height="39" bgcolor="#9DE3FB" align="center">Invoice Number</td>
<td width="12%" bgcolor="#9DE3FB" align="center">Event Name</td>
<td width="12%" bgcolor="#9DE3FB" align="center">Reservation Date</td>
<td width="12%" bgcolor="#9DE3FB" align="center">Quantity</td>
<td width="12%" bgcolor="#9DE3FB" align="center">Price Per Ticket</td>
<td width="12%" bgcolor="#9DE3FB" align="center">Total Price</td>
</tr>
<tr>
<td width="12%" height="39" align="center"><input type="text" name="invoiceId" readonly="readonly" value="<? echo $row['invoiceId']; ?>" class ="field-style"/></td>
<td width="12%" height="39" align="center"><input type="text" name="eventTitle" readonly="readonly" value="<? echo $row['name']; ?>" class="field-style" /></td>
<td width="12%" height="39" align="center"><input type="text" name="invoiceDate" readonly="readonly" value="<? echo $row['invoiceDate']; ?>" class="field-style" /></td>
<td width="12%" height="39" align="center"><input type="text" name="invoiceqty" readonly="readonly" value="<? echo $row['quantity'] ?>" class="field-style" /></td>
<td width="12%" height="39" align="center"><input type="text" name="invoicePPU" readonly="readonly" value="<? echo $row['price']; ?>" class="field-style" /></td>
<td width="12%" height="39" align="center"><input type="text" name="invoiceTotal" readonly="readonly" value="<? echo $row['totalPrice']; ?>" class="field-style" /></td>
</tr>
</table>
<br />
<input type="submit" value="Print Invoice" />
</form>
here is the popup window code (invoice layout to print ):
<table width="65%" border="1" cellspacing="5" cellpadding="5">
<tr>
<td colspan="5"><table width="100%" border="0" cellspacing="5" cellpadding="5">
<tr>
<td width="60%"><img src="images/Logo.png" /></td>
<td width="40%"><p>Invoice No:# <? echo $invoiceId; ?></p>
<p>Invoice Date: <? echo $invoiceDate ;?> </p></td>
</tr>
</table></td>
</tr>
<tr>
<td height="125" colspan="5" valign="top"><p>Bill To:</p>
<p>Name:</p>
<p>Address:</p></td>
</tr>
<tr>
<td width="12%" align="center" height="40">Item Id</td>
<td width="28%" align="center">Item Disc</td>
<td width="9%" align="center">QTY</td>
<td width="40%" align="center">Price Per Unit</td>
<td width="11%" align="center">Total</td>
</tr>
<tr>
<td align="center" valign="middle">1</td>
<td align="center" valign="middle"><? echo $eventTitle . " ticket(s)"; ?></td>
<td align="center" valign="middle"><? echo $invoiceqty ; ?></td>
<td align="center" valign="middle"><? echo $invoicePPU ; ?></td>
<td align="center" valign="middle"><? echo $invoiceqty * $invoicePPU ; ?></td>
</tr>
</table>
for submitting behavior, i used Dreamweaver behavior panel. what's wrong here ?
I'm not sure about dreamweaver behaviour but as far as I can tell this will never work.
You are posting the data to a the "../../printInvoice.php" but when you request the popup page you are opening a new instance that hasn't received the post data.
You need to alter your javascript that pops the page up so that it posts the forms data when it performs the popup request.
I don't know which library you are using to create your popup but fancybox (Jquery plugin: http://fancybox.net) allows you to post data to the popup it creates.
If you could tell me what popup library you are using I might be able to help further.
you cant use php to show a popup you must use ajax, and javascript :
http://jquery.malsup.com/form/
$(document).ready(function() {
// bind 'myForm' and provide a simple callback function
$('#myForm').ajaxForm(function() {
//show your Popup
});
});
Have you tried to use $row['invoiceId']; instaed of $invoiceId in the popupwindow?
It seems to be the same file and therfore the $row[] data should be accessable!
If this doesn't works we propably need more code, especially of the php side.
^^ Overlooked something, we definitely need more code!
thanks, instead of all of this , i posted all the variables as url parameters such as :
<onsubmit="MM_openBrWindow('../../printInvoice.php?invoiceId=<? echo $row['invoiceId']; ?>&eventTitle=<? echo $row['name']; ?>','Invoice'
thanks for trying & your time everyone :)

PHP MySQL populating values from database

lets say i retrieve all of the values where their position belongs to top8.I populate them out in a table and instead of displaying different kinds of values , it displays 3 tables with 3 different values, how is this so? any help so that different values belonging to certain values will all be displayed out? i only need one table with 3 different values.
<?
$facebookID = "top8";
mysql_connect("localhost","root","password") or die(mysql_error());
mysql_select_db("schoutweet") or ie(mysql_error());
$data= mysql_query("SELECT schInitial FROM matchTable WHERE position='".$facebookID."'")
or die(mysql_error());
while($row = mysql_fetch_array($data))
{
?>
<center>
<table border="0" cellspacing="0" cellpadding="0" class="tbl_bracket">
<tr>
<td class="brack_under cell_1"><a href="www.facebook.com"/>team 1.1><?= $row['schInitial']?><a/></td>
<td class="cell_2"> </td>
<td class="cell_3"> </td>
<td class="cell_4"> </td>
<td class="cell_5"> </td>
<td class="cell_6"> </td>
</tr>
<tr>
<td class="brack_under_right_up">team 1.2><?= $row['schInitial']?></</td>
<td class="brack_right"><!--1.2.1--></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="brack_right"><!--2.1--></td>
<td class="brack_under"><!--3.1--></td>
<td><!--here?--></td>
<td><!--there?--></td>
<td><!--everywhere?--></td>
</tr>
</table>
</center>
<?
}
?>
</body>
That's because your <table> tag is within the loop! Place the <table> tag outside the while loop.
place your table tags outside the while loop
Because your writing the table tag inside the while loop. Everything inside the loop is done each loop cycle. If you only want to have one table in the output, you'll have to open and close the table outside of the loop, like this:
$data= mysql_query("SELECT schInitial FROM matchTable WHERE position='".$facebookID."'")
or die(mysql_error());
?>
<center>
<table border="0" cellspacing="0" cellpadding="0" class="tbl_bracket">
<?
while($row = mysql_fetch_array($data))
{
?>
<tr>
<td class="brack_under cell_1"><a href="www.facebook.com"/>team 1.1><?= $row['schInitial']?><a/></td>
<td class="cell_2"> </td>
<td class="cell_3"> </td>
<td class="cell_4"> </td>
<td class="cell_5"> </td>
<td class="cell_6"> </td>
</tr>
<tr>
<td class="brack_under_right_up">team 1.2><?= $row['schInitial']?></</td>
<td class="brack_right"><!--1.2.1--></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="brack_right"><!--2.1--></td>
<td class="brack_under"><!--3.1--></td>
<td><!--here?--></td>
<td><!--there?--></td>
<td><!--everywhere?--></td>
</tr>
<?
}
?>
</table>
</center>
That will, however, print three rows per loop and therefore per record (but you have references to the table contents in two of them, so I suppose that's what you want?).
Also take care about some not well-formed HTML you have there (e.g. the > character in the expression team 1.1> / team 1.2>. If you want to print the > character to the browser, encode it as HTML entity (> for this case). You also have a probably superfluous </ in the first column of the second row (</</td>).
you need to echo the HTML part as well in the while loop like
echo '<table>';

Can php code execute while creation of pdf using tcpdf?

I m working on module in which i have to make pdf from php page. I m Using tcpdf for that but m facing one problem that file contain some mysql queries and php coding which is not executed by pdf page.
$prn_no = $_POST['prn_no'];
$current_sem = $_POST['current_sem'];
$qr_fetch_sem_res_id = mysql_query("SELECT * FROM table1 WHERE ((prn='$prn_no') AND (semisterName='$current_sem'))")or die(mysql_error());
$qr_fetch_sem_result_ans = mysql_fetch_array($qr_fetch_sem_res_id);
<tr>
<td colspan="11" align="left" valign="middle">Programme Name: <?php echo $qr_fetch_sem_result_ans['programme_name'];?></td>
</tr>
<tr>
<td colspan="11" align="center" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="27%">Seat No.: <?php echo $qr_fetch_sem_result_ans['seatNo'];?></td>
<td width="3%"> </td>
<td width="22%">PR No. : <?php echo $qr_fetch_sem_result_ans['prn'];?></td>
<td width="2%"> </td>
<td width="17%">Semester : <?php echo $qr_fetch_sem_result_ans['semisterName'];?></td>
<td width="1%"> </td>
<td width="25%">Month / Year Of Exam : <?php echo $qr_fetch_sem_result_ans['month_year_of_exam'];?> </td>
<td width="3%"> </td>
</tr>
<tr>
<td colspan="3">Name: <?php echo $qr_fetch_sem_result_ans['student_name'];?></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="7">College / Institute: <?php echo $qr_fetch_sem_result_ans['institute_name'];?></td>
<td> </td>
</tr>
</table></td>
</tr>
I'm going to go out on a limb here and suggest that you run your queries fist and then build your pdf file. If you run the queries after you build the pdf then of course it will not have access to your data. If that doesn't help then I must not understand what you're asking.

Categories