<div class="form-group">
<td><label for="genre">Names</label></td>
<td>
<?php
foreach($array as $row){
echo "<div class='form-check form-check-inline'>";
echo "<label class='form-check-label'>";
echo "<input class='form-check-input' type='checkbox' name='genre_checked[]' value='".$row->name."'>";
echo $row->name;
echo "<label>";
echo "</div>";
}?>
</td>
</div>
I'm making a form to submit to my controller and inside that form, i am printing an array inside a "" but the way i've coded it is that it will print in a single column from top to bottom and makes the "td" height increase. I wanted to make use of the extra space so instead of increasing the height i atleast wanted to make use of the td width.
Nevermind. After a few hours of sleep. Took only 5mins.
<?php
foreach($genre as $row){
echo "<div class='col-lg-2'>";
echo "<input type='checkbox' name='genre_checked[]' value='".$row->genre_name."'>";
echo $row->genre_name;
echo "</div>";
}?>
Related
I have these codes and am not good at php please can someone help me on how to echo the videos to appear horizontall in my page thanks in advance
<?php
$h=2;
$k=mysql_query("SELECT * from aupload where type='audios' and view>='$h' order by view DESC");
while ($la=mysql_fetch_array($k)){
?>
<center>
<table width='100%'height=''>
<tr>
<?php echo"<td>" . "<a href='uploads/$la[filename]'><img src='uploads/$la[size]' width='180px' height='180px'>
<br><b>$la[filename]</b><br><a href='music1.php?id=".$la['id']."'><input type='button' value='DOWNLOAD'><input type='button' value='$la[view]'> </a></a>
"?></td>
</tr>
</table><br>
</center>
<?php }?>
<?php
include('connect.php');
$k=mysql_query("SELECT * from aupload where type='audios'");
#$la=mysql_fetch_array($k)
?>
<?php
$h=2;
$y=mysql_query("SELECT * from aupload where type='videos' and view>='$h' order by view DESC ");
?>
<table border='0' id='myTable'width='100%'>
<?php
while ($x=mysql_fetch_array($y)){
echo "<tr>";
echo "<td>" . "<video id='myVideo' onclick='message()' width='180px' height='180px' controls><source src='uploads/$x[filename]' '></video>" . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='' height=''>"."<a href='music2.php?id=$x[id]' > <b>$x[filename]</b><br><input type='button' value='DOWNLOAD'></a>" ."<input type='button' value='$x[view]'></a></a>". "</td>";
echo "</tr>";
}
echo "</table>"; echo"</center>";
?>
the problem is when I upload two or more videos they appear vertically but I just want them to appear horizontally when echo them please someone help and thanks
Use frames is the best way to display a video, try this code
This is actually a HTML question, not a PHP question. In HTML, designates a table row, and can contain many or table cell elements. So you want to have the a echoed before the while loop, then print just the elements in the while loop, then print the . This will put all the elements in a single table row.
I'm loading data from an xml file into a html table then adding a check box column at the end with the view of saving the data from each row where the check box is checked, for now I just want to display the rows with the check box checked.
In my first page I have the code below which successfully loads the xml data in to the html table and displays it as I wanted, forgive my code, it is a bit messy as I'm new to PHP.
<?php
<form method="POST" action="saved.php">
echo "<input type='submit' name='save' value='Save Checked Rows' />";
$all = simplexml_load_file('list.xml');
echo "<div style='height:200px; overflow-y: scroll;'>";
echo "<table border=\"1\">";
echo "<th>Title</th><th>Description</th><th>Link</th><th>Save</th>\n";
echo "<tr>";
$c=0;
foreach ($all as $current) {
$title=$current->title;
$description=$current->description;
$link=$current->link;
echo "<td>{$title}</td><td>{$description}</td><td><a href=$link>$link</a></td><td><input type='checkbox' name='save[]' value='$c' /></td>";
$c++;
echo "</tr>\n"; }
echo "</table>";
echo "</div>";
echo "</form>"
?>
On my second page I have the code below which displays the value of every check box that is checked when I submit the first page
<?php
Session_start();
?>
<?php
foreach($_POST['save'] as $key){
echo $key;}
}
?>
I need to get the data from the other table cells on the checked rows, the only idea that worked so far was putting an input in to the cell but I don't want that because the cells have to be uneditable. Thanks for the help !
For that there is an atribute in html which you can use i,e read only
I have the following scenario. A card reader that reads an ID card and gets the data and displays them in a table (webpage). What I am doing now is removing the table, inserting the ID Card image in the background and superimposing the card data on the image in the appropriate position, i.e. the user photo on the card's photo position, the user's name on the card's Name position etc.
When I try to put the card image in the background either directly as table/form background image, or through css, most of the time it doesn't show right or does not show at all. when it shows, I can not get the data to superimpose correctly. I have tried through css, divs with z-index etc, and nothing works correctly. I can see the data but can not arrange them on the ID card image. Here's the code I have been working on. This is a php webpage we are talking about.
<div id="login" class="login">
<form id="iform" name="iform" method="post" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
<table class="tabcont" width="100%" valign="center" border="0" cellpadding="0" cellspacing="0" summary="main area">
<tr><td align="center" class="listlr" colspan="2">
</td></tr>
<tr><td align="center" class="listlr" colspan="2">
</td></tr>
<?php if (is_array($result) && count($result) > 0):
foreach ($result as $reskey => $resvalue) {
if ($reskey == 'Surname')
echo "<input class='formfld' value='{$resvalue}'/>";
if ($reskey == 'FirstName')
echo "<input class='formfld' value='{$resvalue}'/>";
if ($reskey == 'DateOfBirth')
echo "<input class='formfld' value='{$resvalue}'/>";
if ($reskey == 'PlaceOfBirth')
echo "<input class='formfld' value='{$resvalue}'/>";
if ($reskey == 'NationalID')
echo "<input class='formfld' value='{$resvalue}'/>";
if ($reskey == 'Sex')
echo "<input class='formfld' value='{$resvalue}'/>";
if ($reskey == 'Nationality')
echo "<input class='formfld' value='{$resvalue}'/>";
if ($reskey == 'DocumentNumber')
echo "<input class='formfld' value='{$resvalue}'/>";
if ($reskey == 'CardEffectiveDate')
echo "<input class='formfld' value='{$resvalue}'/>";
if ($reskey == 'CardExpirationDate')
echo "<input class='formfld' value='{$resvalue}'/>";
echo "<tr><td width='0%'></td>";
echo "<td width='0%'>";
if ($reskey == 'CardholderPortraitImage')
echo "<img id='{$reskey}' src='{$resvalue}' value=''/>";
if ($reskey == 'CardholderHandwrittenSignatureImage')
echo "<img id='{$reskey}' src='{$resvalue}' value=''/>";
echo "</td></tr>";
}
else: ?>
<tr> <td>
<?php
echo "<div align=\"center\" class=\"listtopic\" id=\"iderror\">{$errormsg}</div>";
?>
</td>
</tr>
<?php endif; ?>
</table>
</form>
</div>
I am also trying to wrap php in DIVs like so to get to arrange the data files through css and z-index, but nothing happens:
echo '<div class="image">';
echo '</div>';
<div class="foto">';
<?php if ($reskey == 'CardholderPortraitImage')
echo "<img id='{$reskey}' src='{$resvalue}' value=''/>";
?>
</div>
What am I doing wrong?
I am a newbie to PHP and MySQL, so please ignore my bad practice of coding :)
Ok, here's the scenario:
I have a page, checkin.php which has two forms;
Form 1: Takes some input and displays data from database along with multiple checkboxes.
Form 2: It is dynamically generated if any data is found above.
Here's the code:
//Echoing out the query results
echo "<form method='POST' action='checkin.php'>";
echo "<tbody>";
foreach ($checkin_status as $row) {
echo "$rowStart";
echo "$row[book_id]";
echo "$insertColumn";
echo "$row[branch_id]";
echo "$insertColumn";
echo "$row[card_no]";
echo "$insertColumn";
echo "$row[fname]" . " " . "$row[lname]";
echo "$insertColumn";
echo "$row[date_out]";
echo "$insertColumn";
echo "$row[due_date]";
echo "$insertColumn";
//Checkbox creation
$checkin_recall_value = "$row[book_id]" . " " . "$row[branch_id]" . " " . "$row[card_no]";
echo "<div style='text-align: center;'><input type='checkbox' name='checkin' value='$checkin_recall_value'></div>";
echo "$rowEnd";
}
echo "</tbody>";
//Checkin button in foot
echo "<tfoot>";
echo "<td colspan='7' style='text-align: center; padding-right: 20px;'><input id='checkin_button' type='submit' value='Check In' title='Click to check in!'></td>";
echo "</tfoot>";
echo "</form>";
The form is generated with checkboxes along side the returned tuples.
Now when I am selecting some checkboxes and trying to display, it WONT...
Here is the code:
if(!empty($_POST['checkin'])) {
//Retrieving the recall variables as an array from POST and assigning to $main_array
$main_array = array();
//echo "I am here";
if(is_array($_POST['checkin'])) {
foreach($_POST['checkin'] as $value)
{
$sub_array = explode(" ", $value);
array_push($main_array, $sub_array);
}
}
print_r($main_array);
}
Its returning an empty array...
Please help me fix this.
IF you want to have multiple html elements with the same name, you must define it as an array, adding []:
<input type='checkbox' name='checkin[]' value='$checkin_recall_value'>
So I'm trying to get the bootstrap accordion to dynamically show the Top 5 teams judged by most wins, I also use it for other rankings.
The problem is whenever I click tab 2, 3, or 4 it only opens tab 1 in the accordion. I know the issue is from "href='#collapse41'" being the same from every loop. I assume this will require a unique ID for each accordion div tab but I don't know how to implement it correctly. I could be 100% wrong, if so please correct me!
I've done about 15 searches on this and only found one answer, which wasn't very detailed or helpful. Any help or pointers to learn how to do this would be much appreciated.
(The reason I renamed it to #collapse41 is because I have multiple accordions on the same page.)
<div class="accordion" id="accordion2">
<?php
include 'db.php'; //connect to database
$result = mysql_query("SELECT * FROM teams ORDER BY wins DESC LIMIT 5");
$rank = 1;
if (mysql_num_rows($result)) {
while ($row = mysql_fetch_assoc($result)) {
echo "<div class='accordion-group'>";
echo "<div class='accordion-heading'>";
echo "<a class='accordion-toggle' data-toggle='collapse' data-parent='#accordion4' href='#collapse41'>";
echo "<td>{$row['name']} <br /> </td>";
echo "</a>";
echo "</div>";
echo "<div id='collapse41' class='accordion-body collapse'>";
echo "<div class='accordion-inner'>";
echo "<td>Rank: {$rank} <br /> </td>";
echo "<td>Wins: {$row['wins']} <br /> </td>";
echo "<td>Losses: {$row['losses']} <br /> </td>";
echo "</div>";
echo "</div>";
echo "</div>";
$rank++;
}
}
?>
</div>
You have to break the loop up....and loop once to get headings, and twice to get body...
So you need to echo the group div first....
echo "<div class='accordion-group'>";
Then start the loop to output headings...
Then run another loop to output divs....
if (mysql_num_rows($result)) {
//LOOP 1
while ($row = mysql_fetch_assoc($result)) {
//Build heading pieces
echo "<div class='accordion-heading'>";
echo "<a class='accordion-toggle' data-toggle='collapse' data-parent='#accordion-".$row['id']." href='#accordian-".$row['id']."'>";
echo "<td>{$row['name']} <br /> </td>";
echo "</a>";
echo "</div>";}
//LOOP 2
//Build inner pieces
while ($row = mysql_fetch_assoc($result)) {
echo "<div id='accordian-".$row['id']."' class='accordion-body collapse'>";
echo "<div class='accordion-inner'>";
echo "<td>Rank: {$rank} <br /> </td>";
echo "<td>Wins: {$row['wins']} <br /> </td>";
echo "<td>Losses: {$row['losses']} <br /> </td>";
echo "</div>";
echo "</div>"; }
echo "</div>";
$rank++;
}
}
Im not actually too sure of how your accordian is to be structured, so this may or may not be correct information, but whenever I do twiiter-bootstrap accordians, this is how I do it. If you could post your expected HTML output (template for accordian), that would help me greatly, and I can revamp my answer to suit what you actually need