<?php
$count = 1;
foreach($_SESSION["searchmultipleTSIKDO"] as $key=>$rows) {
echo '<tr><td>'.$count++.'.</td>';
echo '<td>'.$rows["key"].'</td>';
echo '<td>';
if ( $rows["key"] == 'bcounty') {
$array = $listcounty->get("WHERE id = $rows[value]");
foreach($array as $rows1) {
echo $rows1["name"];
}
}
else if ( $rows["key"] == 'gender') {
if ( $rows["value"] == 1) {
echo 'Male';
} else {
echo 'Female';
}
}
else if ( $rows["key"] == 'dob') {
.......
}
}
else if ( $rows["key"] == 'qualification') {
$array = $listqualification->get("WHERE id = $rows[value]");
foreach($array as $rows1) {
echo $rows1["name"];
}
}
else {
echo $rows["value"];
}
echo '</td>';
echo "<td><a href=\"report.php?deletesearchmultiple=$key\" style='color: red;'> X</a></td>";
}
?>
You mean something like
else if ( $rows["key"] == 'dob') {
echo '<label>DOB: <input type="date" value="'.date("Y-m-d\TH:i:s",$rows["value"]).'" /></label>';
}
Related
I am learning php and in doing it I had a problem.
I have to insert in a table of the payment data taken from a second table but only after checking that the id of the person corresponds to the id of the person who made the payment.
<?php
3 Query ...
while($rowSocio = mysqli_fetch_array($mostraSocio)) {
$idSocio = $rowSocio['socio_id'];
$nomeSocio = $rowSocio['socio_nome'];
$cognomeSocio = $rowSocio['socio_cognome'];
echo "<tr>";
echo "<td>{$cognomeSocio}</td>";
echo "<td>{$nomeSocio}</td>";
$i = 0;
$print = "0";
while($row = mysqli_fetch_array($mostraOperazione)) {
$id = $row['socio_id'];
$nome = $row['socio_nome'];
$cognome = $row['socio_cognome'];
$importo = $row['opfin_importo'];
$quota = $row['quota_nome'];
if($idSocio === $id) {
if($quota === "Prima Rata" && $print !== "1") {
echo "<td class='align-rx'>€ {$importo}</td>";
echo "<td></td>";
echo "<td></td>";
echo "<td></td>";
$i++;
$print = "1";
} elseif($quota === "Seconda Rata" && $print !== "2") {
echo "<td></td>";
echo "<td class='align-rx'>€ {$importo}</td>";
echo "<td></td>";
echo "<td></td>";
$i++;
$print = "2";
} elseif($quota === "Terza Rata" && $print !== "3") {
echo "<td></td>";
echo "<td></td>";
echo "<td class='align-rx'>€ {$importo}</td>";
echo "<td></td>";
$i++;
$print = "3";
} elseif($quota === "Quota Stagionale" && $print !== "4") {
echo "<td></td>";
echo "<td></td>";
echo "<td></td>";
$i++;
$print = "4";
echo "<td class='align-rx'>€ {$importo}</td>";
} else {
echo "<td></td>";
echo "<td></td>";
echo "<td></td>";
echo "<td></td>";
echo "</tr>";
$i++;
}
} else {
echo "</tr>";
$i++;
}
}
}
?>
so I only print the names of the people and not the payments they make
output:
enter image description here
I created a code that converts characters to binary and make table cells black/white corresponding to the ones and zeros. This is my code:
$str_splt = str_split($text);
echo "<table>";
for ($a=0;$a < count($str_splt);$a++) {
$bits = array(128,64,32,16,8,4,2,1);
$store = array(0,0,0,0,0,0,0,0);
$inp = ord($str_splt[$a]);
for ($x=0;$x < count($bits);$x++) {
if ($bits[$x] <= $inp) {
$inp = $inp - $bits[$x];
$store[$x] = 1;
} else {
$store[$x] = 0;
}
};
$store_rvs = array_reverse($store);
echo "<tr>";
for ($b=0;$b < count($store_rvs);$b++) {
if ($store_rvs[$b] == '1') {
echo "<td id=\"blk\"></td>";
}
else {
echo "<td></td>";
}
}
echo "</tr>";
}
echo "</table>";
Its output looks like this ($text = "ABCDEFGH"):
As you can see it's 8x8 table. I want to add the next set of bytes to the side of that table like this:
Each 8x8 table is a group. The two images above is group 1 and group 2:
I want to display the tables like this but I can't find the solution.
I did it in this way. Ignore my css if you are fine with yours. I replaced the id tag with class because each id should be defined once only.
echo "<html><head>";
echo "<style type='text/css'>";
echo " table, td { padding:0px; margin:0px; }";
echo " td.cell { width:15px; height:15px; }";
echo " td.blk { background-color:black; }";
echo " td.wht { background-color:yellow; }";
echo "</style>";
echo "</head><body>";
$text = "ABCDEFGH";
$text.= "ABCDEFGH";
echo "<table><tr><td><table>";
for($a=0; $a<strlen($text); $a++) {
$chr = substr($text,$a,1);
$bits = array(128,64,32,16,8,4,2,1);
$store = array(0,0,0,0,0,0,0,0);
$inp = ord($chr);
for($x=0; $x<count($bits); $x++) {
if($bits[$x] <= $inp) {
$inp = $inp - $bits[$x];
$store[$x] = 1;
} else {
$store[$x] = 0;
}
}
$store_rvs = array_reverse($store);
if($a % 8 === 0) {
echo "</table></td><td><table>";
}
echo "<tr>";
for($b=0; $b<count($store_rvs); $b++) {
if($store_rvs[$b] == '1') {
echo "<td class='cell blk'></td>";
} else {
echo "<td class='cell wht'></td>";
}
}
echo "</tr>";
}
echo "</table></td></tr></table>";
How to display this query result in 4 columns
<?php
$direction = $_POST['direction'];
$sumword = $_POST['sumword'];
$length = $_POST['length'];
$con = mysql_connect("localhost","elsha","12q(5PSZ.");
$db = mysql_select_db("elsha",$con);
$query = "SELECT answer FROM words WHERE direction = '$direction' AND sumword = '$sumword' AND sumletter = '$length'";
$result = mysql_query($query);
if(mysql_error()) {
//check that no error has occurred first; take this out in production or make more graceful handling
die(mysql_error());
}
if(mysql_num_rows($result) == 0) {
echo "No Results";
} else {
while($row = mysql_fetch_array($result)) {
echo '<img src="/images/'. $row['0'].'.jpg"><br> '. $row['0'].'<br>';
}
}
?>
like this :
result1 result2 result3 result4
result5 result6 result7 result8
Try this
$i = 0;
while($row = mysql_fetch_array($result)) {
echo '<img src="/images/'. $row['0'].'.jpg"> ';
$i++;
if($i % 4 == 1 && $i!=1){
echo '<br>';
}
}
Use flag like
$flag=0;
while($row = mysql_fetch_array($result)) {
if(($flag%4)==0) {
echo '<tr>';
}
echo '<td><img src="/images/'. $row['0'].'.jpg"><br> '. $row['0'].'</td>';
if(($flag%4)==3) {
echo '</tr>';
$flag=-1;
}
$flag++;
}
replace your while with the following code. try this
$a=1;
while($row = mysql_fetch_array($result)) {
if($a%4==0) {
echo '<img src="/images/'. $row['0'].'.jpg">'. $row['0'].'<br>';
} //4th line with break
else {
echo '<img src="/images/'. $row['0'].'.jpg"> '. $row['0'].' '; // prints first 3 lines
}
$a=$a+1;
}
I think you are trying to display the image name too below the image. Try this:
$i = 1;
while($row = mysql_fetch_array($result)) {
echo '<div class="imgs">';
echo '<img src="/images/'. $row['0'].'.jpg"><br> '. $row['0'];
echo '</div>';
if ($i === 4) {
echo '<div class="clear"></div>';
$i = 1;
} else {
$i++;
}
}
and then style div's
.imgs {
float: left;
/* other styles */
}
.clear {
clear: both;
}
I´m trying to do a checkbox in my form but its just returning the last value. What´s wrong here?
if ($type == "w") {
//check buttons
foreach ($values as $indexa => $value) {
$value = trim($value);
echo "<input type=\"checkbox\" name=\"input[$fieldno]\" value=\"$value\" ";
if (isset($input)) {
if ($input[$fieldno] == $value) {
echo " checked";
// var_dump($fieldno); die();
}
}
if ($compulsory == 1) {
echo " class=\"required\"";
}
$label = ($value == 'OTHER') ? 'OUTROS' : $value;
echo " onclick=radio_other($fieldno,\"$value\")> $label<br>";
}
if (strtoupper($value) == "OTHER") {
echo "<input type=\"text\" name=\"other[$fieldno]\" id=\"other[$fieldno]\" style=\"display:none\">";
}
}
Ps: $type == w is a checkbox type.
Hello I have this query
$upit = "SELECT id from usluga";
$rezultat = mysql_query($upit);
while($red = mysql_fetch_object($rezultat))
{
echo "<li>{$red->id}</li>";
}
I want on exit to get this:
<li>1,2,3,4,5,6</li>
<li>7,8,9,10,11,12</li>
<li>13,14,15,16,17,18</li>
<li>19,20,21,22,23,24</li>
and so on..
Any help?
You can use the mod operator(%) or use array functions to achive this
$upit = "SELECT id from usluga";
$rezultat = mysql_query($upit);
while ($red=mysql_fetch_object ($rezultat)) {
$t[] = $red->id;
}
$chunks = array_chunk($t, 6);
foreach ($chunks as $chunk) {
echo "<li>" . join(",", $chunk) . "</li>";
}
try this..
$upit="SELECT id from usluga";
$rezultat=mysql_query($upit);
$i=0;
$liflag=0;
while ($red=mysql_fetch_assoc($rezultat))
{
if($i<6)
{
$liflag=1;
if($i==0)
{
echo "<li>$red->id";
$i++;
continue;
}
else
{
echo ",$red->id";
$i++;
continue;
}
}
else
{
echo ",$red->id</li>";
$i=0;
$liflag=0;
continue;
}
}
if($liflag==1)
{
echo "</li>";
}