MYSQL/PHP Where can i insert - php

Is it possible somehow to color "company_owner" by the code which user_color holds? That when you open select list, for the sample: Richerson, Rick would be colored by the code which user table has user_color.
$q->addQuery('user_id');
$q->addQuery('user_color');
$q->addQuery('CONCAT_WS(", ",contact_last_name,contact_first_name)');
<tr>
<tr>
<td align="right">
<?php echo $AppUI->_('Kompanijos savininkas'); ?>:
</td>
<td>
<?php
echo arraySelect($owners, 'company_owner', 'size="1" class="text"',
((#$obj->company_owner) ? $obj->company_owner : $AppUI->user_id));
?>
</td>
</tr>

Fetch the content in user_table, register it into a var and parse it in html or in css, don't know how do that in mysqli but if you want I can write it in mysql

Related

Simple HTML DOM: accessing html elements within results

I'm trying to get a better understanding of PHP Simple HTML DOM and am kinda stuck on the following.
I am trying to retrieve information from one of my user pages by using the following code :
$dom = file_get_html('http://127.0.0.1/comments/top-commenters/');
foreach($dom->find('tr[id*=commenter]') as $result) {
print_r($result->innertext);
}
Which produces for each commenter profile ($result->innertext) the following :
<td class="Position"># 3 </td>
<td class="img" align="center">
<a href="/images/users/814ocnqlN6.jpg">
<img src="/images/users/814ocnqlN6.jpg" info="Image" border="0"/></a>
<a uid="814ocnqlN6"></td>
<td> <b>User 3.</b>
<div class="tiny">Most recent comments</div>
</td>
<td class="NumCredits"> 471 </td>
<td class="NumComments"> 5.439 </td>
<td class="PercUpVotes"> 93% </td>
Now if I would like to access within each result (same foreach loop) for example :
<td class="Position"># 3 </td>
And
<td class="NumComments"> 5.439 </td>
What would be the best way to accomplish this ?
Try:
$dom = file_get_html('http://127.0.0.1/comments/top-commenters/');
foreach($dom->find('tr[id*=commenter]') as $result) {
print_r($result->find('td.Position'));
print_r($result->find('td.NumComments'));
}
}

FPDF html table to display data from mysql

I'm new to fpdf and I'm having trouble on how can I display the data based on my input field. In myh input field php file I will put the name,date etc and I have a print button where when I clicked It will automatically print what I inputted in that field. Now I want that to be printed in a table form format. Below is the fpdf file:
<?php
$html = <<<MYTABLE
<table border="1" style="width:90%" title="Leave" cellpadding="5px" align="center">
<tr>
<td rowspan=1 width="70" align:"top-left"><center><b>1. Name:</b></center><br><select name="office_agency"></td>
<td rowspan=1 width="100" colspan="2" align:"top-left"><b>2. ID / Date</b><br> </td>
</tr>
<tr>
......
</tr>
</table>
MYTABLE;
require('pdftable.inc.php');
mysql_connect('localhost','root','');
mysql_select_db('auth');
$p = new PDFTable();
$p->AddPage();
$p->setfont('times','',10);
$p->Cell(5,-5,'APPLICATION FOR LEAVE');
$p->Ln(3);
$p->htmltable($html);
$p->output();
?>
There. how can put the code for fetching the inputted data following the html format or is there any way than this? thanks
Here you cannot use the html table for direct display,you can create the table using the col() syntax for more check this link [here]
http://www.fpdf.org/en/script/script14.php

Display Images from Database via PHP

I want to display the images, stored in a table, in PHP Database, table name is "bbmp" and the column containing the images is named as, "image"
Please help me in the code in this matter as it shows my output like this
<?php
include("dbconnection.php"); // it contains all the details of the database name, database host and password
$y=$sql = "SELECT * FROM `bbmp`";
$result = mysql_query($y);
echo "<table align='center'> <tr> <td> uid </td> <td> username </td> <td> Address </td> <td> email </td> <td> description </td> <td> status </td> <td> Images </td> </tr>";
if(!$result)
{
echo "not run ($y) from: ".mysql_error();
exit;
}
while($pat=mysql_fetch_assoc($result))
{
$uid=$pat['uid'];
$username=$pat['username'];
$address=$pat['address'];
$email=$pat['email'];
$description=$pat['description'];
$status=$pat['status'];
$image=$pat['image'];
echo "<tr> <td> $uid </td> <td> $username </td> <td> $address </td> <td> $email </td> <td> $description </td> <td> $status </td> <td> $image </td> </tr>";
}
echo "</table>";
?>
<html>
<body>
Go Back
</body>
</html>
All the field is viewed except image. It shows image in some uni-code. Please help
i dont see your output, i hope this will help you..
if your image column contains image path, you must write
<img src="$image">
but
your column contains image as binary you can write
<img src="data:image/png;base64,$image">
if your image data is base64 encoded
also, if your image saved binary data, you can show it like below;
<img src="image.php?data=xxxxx">
your image.php header must be image/jpg etc...

php joomla k2 code suggestion

i'm working with k2, the joomla content module.
i'm using extra fields and i have a particular need.
i associated some link type extra fields to a k2 category:
i need them to be invisible to users while they create items from frontend,
but then come back visible after i (administrator) filled those fields from backend.
so i just need to hide those extrafields (all the link type) from the itemform view: below is the code where i should add something like
IF
THEN
ELSE
END
but i don't know nothing about php code compiling... can any body suggest something???
CODE:
<table class="admintable" id="extraFields">
<?php foreach($this->extraFields as $extraField): ?>
<tr>
<td align="right" class="key">
<?php echo $extraField->name; ?>
</td>
<td>
<?php echo $extraField->element; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
Change that code to this -
<table class="admintable" id="extraFields">
<?php foreach($this->extraFields as $extraField): ?>
<?php if ($extrafield->name !="name of field you want to hide") { ?>
<tr>
<td align="right" class="key">
<?php echo $extraField->name; ?>
</td>
<td>
<?php echo $extraField->element; ?>
</td>
</tr>
<?php } ?>
<?php endforeach; ?>
</table>
Be sure to do it as a template override so it doesn't get killed when you update.

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>';

Categories