I have a page called MemberArea.php that use bootstrap tab to change its content according to div id.
<div id="tabs-1" class="tab-pane fade in active">
<div class="tabbable tabs-left">
<br />
<ul class="nav nav-tabs" id="maincontent" role="tablist">
<li class="active"><a data-toggle="tab" href="#tabs-5" role="tab">Basic Information</a></li>
<li><a data-toggle="tab" href="#tabs-6" role="tab">View Team</a></li>
</ul>
<div class="tab-content">
<div id="tabs-5" class="tab-pane active">
<?php include("information.php"); ?>
</div>
<div id="tabs-6" class="tab-pane">
<?php include("viewTeam.php"); ?>
</div>
<div id="tabs-14" class="tab-pane">
<?php include("EditSinging.php"); ?>
</div>
<div id="tabs-15" class="tab-pane">
<?php include("EditSpeech.php"); ?>
</div>
<div id="tabs-16" class="tab-pane">
<?php include("EditStory.php"); ?>
</div>
</div>
</div>
In ViewTeam, it's to display all registered team
<?php
$query="select * from etj12singing where etj12id=$id AND etj12Pay ='Yes' ";
$result =mysql_query($query);
while($row= mysql_fetch_array($result))
{
$SIidnumber=$row['etj12idnum'];
$SIidtype = $row['etj12idtype'];
$SIfullName = $row['etj12fullname'];
$SIgender = $row['etj12gender'];
$SIemail = $row['etj12email'];
$SIphone = $row['etj12phone'];
$SIvege = $row['etj12vege'];
$SIpay = $row['etj12Pay'];
$SIidsinging = $row['etj12idsinging'];
?>
<tr>
<td><?php echo $SIidnumber; ?></td>
<td><?php echo $SIidtype; ?></td>
<td><?php echo $SIfullName; ?></td>
<td><?php echo $SIgender; ?></td>
<td><?php echo $SIemail; ?></td>
<td><?php echo $SIphone; ?></td>
<td><?php echo $SIvege; ?></td>
<td><?php echo $SIpay; ?></td>
<td>
<a data-toggle="tab" href="?idSIE=<?php echo $SIidsinging; ?>#tabs-14" role="tab">
<input type="submit" value="Edit" class="btn-warning"/>
</td>
</tr>
My problem is I cannot pass the value to tabs-14(EditSinging.php)
Here is how i get the value in tabs-14(EditSinging.php)
$idsinging=$_GET['idSIE'];
UPDATE
Here is the code in EditSinging.php
PHP :
$idinst = $_SESSION['id'];
$idsinging=$_POST['idSIE'];
$query = "SELECT * FROM etj12singing WHERE etj12id=$idinst AND etj12idsinging=$idsinging";
$result = mysql_query($query);
if($row=mysql_fetch_array($result))
{
$idNum = $row['etj12idnum'];
$idtype = $row['etj12idtype'];
$fullname = $row['etj12fullname'];
$gender = $row['etj12gender'];
$email = $row['etj12email'];
$phone = $row['etj12phone'];
$vege = $row['etj12vege'];
}
Below is the form to edit the value that i got from the query above
<table style="width:100%;height:auto;border-spacing:10px;border-collapse:separate">
<tr>
<td>Id Number<br/>
<span style="font-style:italic;">(Nomor Identitas)</span>
</td>
<td>
<input type="text" id="IdNumber" name="IdNumber" value="<?php echo $idNum; ?>" class="textbox_register"/>
<input type="hidden" name="idSIC" value="<?php echo $idsinging; ?>" class="textbox_register"/>
<br/><label id="err1" class="error"></label>
</td>
</tr></table>
In your ViewTeam file the query:
$query="select * from etj12singing where etj12id=$id AND etj12Pay ='Yes' ";
this content ($id) witch not defined in file;
you must give the string (id) a value.
so your query return null results.
I think this is the problem you have.
Related
I've been creating a CMS blog and this is one of the pages that accessible by the admins. I'm trying to implement pagination in it.
As you can see, it shows the latest six posts in the first page with the IDs from 1 to 6, but when I click on the forward button, it shows the IDs 1 and 2 again for the other posts in which it should be 7 and 8. Could someone tell me what's causing this bug?
First page
Second page
<!-- Right Side Area Start -->
<div class="col-lg-10">
<div class="card-body bg-info">
<h2 class="large-georgia-white-bold">Top Posts</h2>
</div>
<table class="table table-striped table-hover">
<thead class="thead-dark small-times-white">
<tr>
<th>No.</th>
<th>Title</th>
<th>Date&Time</th>
<th>Author</th>
<th>Comments</th>
<th>Details</th>
</tr>
</thead>
<?php
$SrNo = 0;
global $ConnectingDB;
// Query When Pagination is Active i.e Dashboard.php?page=1
if (isset($_GET["page"])) {
$Page = $_GET["page"];
if ($Page==0||$Page<0) {
$ShowPostFrom=0;
}else{
$ShowPostFrom=($Page*6)-6;
}
$sql ="SELECT * FROM posts ORDER BY id desc LIMIT $ShowPostFrom,6";
$stmt=$ConnectingDB->query($sql);
}
// The default SQL query
else{
$sql = "SELECT * FROM posts ORDER BY id desc LIMIT 0,6";
$stmt=$ConnectingDB->query($sql);
}
while ($DataRows=$stmt->fetch()) {
$PostId = $DataRows["id"];
$DateTime = $DataRows["datetime"];
$Author = $DataRows["author"];
$Title = $DataRows["title"];
$SrNo++;
?>
<tbody class="small-times-black">
<tr>
<td><?php echo $SrNo; ?></td>
<td><?php echo $Title; ?></td>
<td><?php echo $DateTime; ?></td>
<td><?php echo $Author; ?></td>
<td>
<?php $Total = ApproveCommentsAccordingtoPost($PostId);
if ($Total>0) {
?>
<span class="badge badge-success">
<?php
echo $Total; ?>
</span>
<?php } ?>
<?php $Total = DisApproveCommentsAccordingtoPost($PostId);
if ($Total>0) { ?>
<span class="badge badge-danger">
<?php
echo $Total; ?>
</span>
<?php } ?>
</td>
<td> <a target="_blank" href="FullPost.php?id=<?php echo $PostId; ?>">
<span class="btn btn-info">Preview</span>
</a>
</td>
</tr>
</tbody>
<?php } ?>
</table>
<!-- Right Side Area End -->
<!-- Pagination -->
<nav>
<ul class="pagination pagination-lg">
<!-- Creating Backward Button -->
<?php if( isset($Page) ) {
if ( $Page>1 ) {?>
<li class="page-item">
«
</li>
<?php } }?>
<?php
global $ConnectingDB;
$sql = "SELECT COUNT(*) FROM posts";
$stmt = $ConnectingDB->query($sql);
$RowPagination = $stmt->fetch();
$TotalPosts = array_shift($RowPagination);
//echo $TotalPosts."<br>";
$PostPagination=$TotalPosts/6;
$PostPagination=ceil($PostPagination);
//echo $PostPagination;
for ($i=1; $i <= $PostPagination ; $i++) {
?>
<li class="page-item">
<?php echo $i; ?>
</li>
<?php } ?>
<!-- Creating Forward Button -->
<?php if ( isset($Page) && !empty($Page) ) {
if ($Page+1 <= $PostPagination) {?>
<li class="page-item">
»
</li>
<?php } }?>
</ul>
</nav>
</div>
</div>
</section>
<!-- Main area end -->
Your script always reassigns $SrNo = 0 when the page is loaded and starts over. You should add the page * 6 value to it so it becomes aware of the offset. In fact, you're already using that logic for $ShowPostFrom, so you can simply assign the same value to $SrNo and it should work:
if ($Page==0||$Page<0) {
$ShowPostFrom=0;
}else{
$ShowPostFrom=($Page*6)-6;
}
$SrNo = $ShowPostFrom; // <- this is what you should add
If you don't mind modifying $ShowPostFrom, you can drop $SrNo completely and just use $ShowPostFrom to show the number.
I explain briefly I created a table that shows all my products on video, where inside the container that contains it are two select, enclosed in a form, which pass values in order to populate the table in my db, and everything works perfectly. The only thing though that when I select more than one product the db correctly registers only the last one selected from the checkbox,place my code in order to reach my goal, that of being able to insert more products(impianto_id_campagna),for the same customer id (cliente_id_campagna), and event id (id_campagna_cliente):
code:
<?php
$messaggio = "";
if (isset($_POST['submit'])) {
include '../connessione.php';
$id_campagna_cliente = $connessione->real_escape_string($_POST['id_campagna_cliente']);
$cliente_id_campagna = $connessione->real_escape_string($_POST['cliente_id_campagna']);
$impianto_id_campagna = $connessione->real_escape_string($_POST['impianto_id_campagna']);
$connessione->query("INSERT INTO campagne_cliente (
id_campagna_cliente,
cliente_id_campagna,
impianto_id_campagna)
VALUES (
'$id_campagna_cliente',
'$cliente_id_campagna',
'$impianto_id_campagna')");
$messaggio = "Registrazione Completata!";
}
?>
<main>
<?php
include '../connessione.php';
$query_string = "SELECT * FROM store_locator WHERE store_locator.id NOT IN (SELECT impianto_id_campagna FROM campagne_cliente)";
$query = mysqli_query($connessione, $query_string);
?>
<?php
include '../connessione.php';
$query_string = "SELECT * FROM clienti";
$clienti = mysqli_query($connessione, $query_string);
?>
<?php
include '../connessione.php';
$query_string = "SELECT * FROM campagne_cliente
INNER JOIN clienti
ON clienti.cliente_id = campagne_cliente.cliente_id_campagna
INNER JOIN campagne
ON campagne.id_campagna = campagne_cliente.id_campagna_cliente GROUP BY cognome";
$campagne = mysqli_query($connessione, $query_string);
?>
<!-- Datatables initialization -->
<script>
// Basic example
$(document).ready(function () {
$('#dtBasicExample').DataTable();
$('.dataTables_length').addClass('bs-select');
});
</script>
<!-- Structured data: Breadcrumbs -->
<form method="post" action="index.php">
<div class="container-fluid text-center">
<div class="row">
<div class="col-md-6">
<select name="cliente_id_campagna" class="ciao colorful-select dropdown-primary" multiple searchable="Cerca il Cliente">
<option value="" disabled selected>Cliente</option>
<?php
while($row = mysqli_fetch_assoc($clienti)){ ?>
<option value="<?php echo $row['cliente_id'] ;?>"><?php echo $row['nome'].' '.$row['cognome'] ;?></option>
<?php } ?>
</select>
<script type="text/javascript">
// Material Select Initialization
$(document).ready(function() {
$('.ciao').material_select();
});
</script>
</div>
<div class="col-md-6">
<select name="id_campagna_cliente" class="ok colorful-select dropdown-primary" multiple searchable="Cerca la campagna">
<option value="" disabled selected>Cliente</option>
<?php
while($row = mysqli_fetch_assoc($campagne)){ ?>
<option value="<?php echo $row['id_campagna_cliente'] ;?>"><?php echo $row['nome'].' '.$row['cognome'].' INIZIO['.$row['data_inizio'].'] FINE['.$row['data_fine'].']' ;?></option>
<?php } ?>
</select>
<script type="text/javascript">
// Material Select Initialization
$(document).ready(function() {
$('.ok').material_select();
});
</script>
</div>
</div>
<div class="col-md-12">
<?php if ($messaggio != "") echo $messaggio . "<br><br>"; ?>
<table id="dtBasicExample" class="table table-striped table-bordered table-sm" cellspacing="0" width="100%">
<thead>
<tr>
<th class="th-sm">ID
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
<th class="th-sm">Cimasa
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
<th class="th-sm">Proprietaria
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
<th class="th-sm">Concessionaria
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
<th class="th-sm">City
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
<th class="th-sm">Latitudine
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
<th class="th-sm">Longitudine
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_assoc($query)){ ?>
<tr>
<td>
<!-- Material unchecked -->
<div class="form-check">
<input type="checkbox" name="impianto_id_campagna" class="form-check-input" value="<?php echo $row['id'] ;?>" id="<?php echo $row['id'] ;?>">
<label class="form-check-label" for="<?php echo $row['id'] ;?>"></label>
</div>
</td>
<td><?php echo $row['cimasa'] ;?></td>
<td><?php echo $row['proprietaria'] ;?></td>
<td><?php echo $row['concessionaria'] ;?></td>
<td><?php echo $row['city'] ;?></td>
<td><?php echo $row['lat'] ;?></td>
<td><?php echo $row['lng'] ;?></td>
</tr>
<?php } ?>
</tfoot>
</table>
<input class="btn btn-primary" name="submit" type="submit" value="Register..."><br>
</form>
</div>
</div>
It register only the last one selected product because you have the same name attribute for every checkbox. Set the name to impianto_id_campagna[] in order to return an array in your $_POST variable.
<input type="checkbox" name="impianto_id_campagna[]" class="form-check-input" value="<?php echo $row['id'] ;?>" id="<?php echo $row['id'] ;?>">
Then you loop all your checkbox values inserting one product at a time:
<?php
$id_campagna_cliente = $connessione->real_escape_string($_POST['id_campagna_cliente']);
$cliente_id_campagna = $connessione->real_escape_string($_POST['cliente_id_campagna']);
foreach ($_POST['impianto_id_campagna'] as $value)
{
$impianto_id_campagna = $connessione->real_escape_string($value);
$connessione->query("INSERT INTO campagne_cliente (
id_campagna_cliente,
cliente_id_campagna,
impianto_id_campagna)
VALUES (
'$id_campagna_cliente',
'$cliente_id_campagna',
'$impianto_id_campagna')");
$messaggio = "Registrazione Completata!";
}
Checkbox items are passed as an array. In order to get them in to the database, you have to loop through the array and act accordingly.
foreach($impianto_id_campagna as $row){
//Iterate through and do what you need to do with the data.
}
I am trying to generate Tabs from 1st while loop and within that table from second while loop.
I will fetch the records date wise from my 1st table ie, treatment from that i am generating Tab, In another table called treatment_litems i have stored all the line items for treatment table records. So for 1st date (Tab) from treatment table, i want to display all the related records from treatment_litems in table format.
I am getting records but Tabs are not getting added, but everytime new Tabs are generating.
here is my code
<ul class="nav nav-tabs">
<?php $i=1; while($tt2 = mysqli_fetch_array($tt1)) { ?>
<li>
<?php echo $tt2['date']; ?>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade active in" id="tab_1_<?php echo $i; ?>">
<?php $l1 = mysqli_query($con, "SELECT * FROM treatment_litems WHERE tid=".$tt2['tid'].""); ?>
<table class="table">
<thead><tr><th>Drugs</th><th>Route</th><th>Dosage</th></tr></thead>
<tbody>
<?php
while($l2 = mysqli_fetch_array($l1)) { ?>
<tr><td><?php echo $l2['drugs']; ?></td>
<td><?php echo $l2['route']; ?></td>
<td><?php echo $l2['dosage']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php $i++ ; } ?>
</div>
Here is the image
**** EDITED ******
<ul class="nav nav-tabs">
<?php
while($tt2 = mysqli_fetch_array($tt1)) { ?>
<li>
<?php echo $tt2['date']; ?>
</li>
</ul>
<?php } ?>
<div class="tab-content">
<div class="tab-pane fade active in" id="tab_1_<?php echo $tt2['tid']; ?>">
This is my working code, you can get hints by this:
<div id="tabs" style="float:left">
<ul>
<?php $getlang=mysql_query("select * from language where Mid='$mid' and status='1' order by LanguageName asc");
if(mysql_num_rows($getlang)>0){
while($arr=mysql_fetch_array($getlang)){?>
<li><?php echo $arr['LanguageName']; ?></li>
<?php }}?>
</ul>
<?php $getlang=mysql_query("select * from language where Mid='$mid' and status='1' order by LanguageName asc");
if(mysql_num_rows($getlang)>0){
while($arr=mysql_fetch_array($getlang)){?>
<div id="tabs-<?php echo $arr['LanguageID'] ?>">
<input type="hidden" name="LanguageId[]" class="langID" value="<?php echo $arr['LanguageID']; ?>">
<input type="hidden" name="mid" value="<?php echo $mid; ?>">
<div class="rows">
<label>Notification Text</label><br/>
<textarea rows="3" cols="10" name="description[]" id="" maxlength="1000" style="width:700px; height:100px;" required="required"></textarea>
</div>
</div>
<?php } }
Check and do let me know.
I'm about to display comments on a page, everything works fine but I want to display the comments from the user first. So, how do I display the user comments from the user_id first? I'm using a while loop to display the comments.
I would be very grateful if anyone could help me. :)
<?php
$sql = "SELECT * FROM `comments` WHERE `post_id`=$pid AND `active`=1 ORDER BY ups-downs DESC";
$result = $mysqli->query($sql);
$count = $result->num_rows;
if($count == 1){
$counttext = "1 Comment";
}else{
$counttext = $count ." Comments";
}
?>
<div class="media-area media-area-small">
<h3 class="text-center"><?php echo $counttext; ?></h3>
<?php
while($row = $result->fetch_assoc()){
$uid = (int)$row["user_id"];
$user = get_user_info($mysqli,$uid);
?>
<div class="media">
<a class="pull-left" href="#">
<div class="avatar">
<img class="media-object" src="<?php echo $user["picture"]; ?>" alt="...">
</div>
</a>
<div class="media-body">
<table width="100%">
<tr valign="middle">
<td align="left"><h4 class="media-heading text-left"><?php echo fb_clear_name($mysqli, $user["id"]); ?></h4></td>
<td align="right"><h6 class="pull-right text-muted"><?php echo $row["ups"] - $row["downs"]; ?> bits</h6></td>
</tr>
</table>
<p><?php echo htmlentities($row["content"]); ?></p>
<div class="media-footer">
<i class="fa fa-reply"></i> Reply
<a href="#" class="pull-right text-muted">
<?php echo $row["timestamp"]; ?>
</a>
</div>
</div>
</div>
<?php
}
?>
Greetings
You can prefilter the data. For example use
$user_comments=array();
$other_comments=array();
while($row = mysql_fetch_assoc($result))
{
if($row['user']==$current_user)
{
$user_comments[]=$row;
}
else
{
$other_comments[]=$row;
}
}
$comments=array_merge($user_comments,$other_comments);
Then you can display the information the way you want to.
I have a query that selects all the information from a database table and puts it into an array. I then use a PHP foreach statement to display all that in a uniform manner. It's the left table here to get a sense of what I'm talking about.
What I want to do is to make one of the divs (it normally just appears repeatedly under the same name) to have a unique name for each sumbission row. For example, instead of the "response" divs all just being called response, they are "response1", "response2", and so on. Is there any way to do this? (code below)
Any help would be greatly appreciated.
Here's where I call the info from the query:
<?php foreach($images as $image) { ?>
<table id="front_pgs">
<tr>
<td id="front_text">
<div id="imagetitle">
<?php echo $image['name'];?>
</div>
<div id="submission_info">
submitted by <?php echo $image['submitter'];?>
</div>
<div id="ratingcontainer">
<form id="ratingform">
<input name="vote" type="button" onclick="getVote('<?php echo $image['filename'];?>')" value='Like' id="likebutton"/>
<input name="dislike" type="button" value='Disike' id="dislikebutton"/>
</form>
<div id="rate_count">
<div id="response">
<?php echo $image['rating'];?>
</div>
</div>
</div>
</td>
<td id="front_pg_img" valign="center" align="center">
<a onClick="switchImageUrl('<?php echo $image['filename']; ?>', '<?php echo $image['width']; ?>', '<?php echo $image['height']; ?>')"><img src="<?php echo $image['filename'];?>" id="front_pg_thumbnail"/></a>
</td>
</tr>
</table>
<?php } ?>
You can do this by two ways I will show you now
1- add the row id if exists to the id value or any unique column
<div id="response<?php echo $image['id']; ?>">
<?php echo $image['rating'];?>
</div>
2- make a counter
<?php
$i= 1;
foreach($images as $image) { ?>
<table id="front_pgs">
<tr>
<td id="front_text">
<div id="imagetitle">
<?php echo $image['name'];?>
</div>
<div id="submission_info">
submitted by <?php echo $image['submitter'];?>
</div>
<div id="ratingcontainer">
<form id="ratingform">
<input name="vote" type="button" onclick="getVote('<?php echo $image['filename'];?>')" value='Like' id="likebutton"/>
<input name="dislike" type="button" value='Disike' id="dislikebutton"/>
</form>
<div id="rate_count">
<div id="response<?php echo $i; ?>">
<?php echo $image['rating'];?>
</div>
</div>
</div>
</td>
<td id="front_pg_img" valign="center" align="center">
<a onClick="switchImageUrl('<?php echo $image['filename']; ?>', '<?php echo $image['width']; ?>', '<?php echo $image['height']; ?>')"><img src="<?php echo $image['filename'];?>" id="front_pg_thumbnail"/></a>
</td>
</tr>
</table>
<?php
$i++; //increment the $i each iteration
} ?>
<?php $i = 1; foreach($images as $image) { ?>
<table id="front_pgs">
<tr>
<td id="front_text">
<div id="imagetitle">
<?php echo $image['name'];?>
</div>
<div id="submission_info">
submitted by <?php echo $image['submitter'];?>
</div>
<div id="ratingcontainer">
<form id="ratingform">
<input name="vote" type="button" onclick="getVote('<?php echo $image['filename'];?>')" value='Like' id="likebutton"/>
<input name="dislike" type="button" value='Disike' id="dislikebutton"/>
</form>
<div id="rate_count">
<div id="response<?php echo $i; ?>">
<?php echo $image['rating'];?>
</div>
</div>
</div>
</td>
<td id="front_pg_img" valign="center" align="center">
<a onClick="switchImageUrl('<?php echo $image['filename']; ?>', '<?php echo $image['width']; ?>', '<?php echo $image['height']; ?>')"><img src="<?php echo $image['filename'];?>" id="front_pg_thumbnail"/></a>
</td>
</tr>
</table>
<?php $i ++; } ?>
Notice the $i = 1 before the foreach as well as the $i ++ before the closing }. Also, echo $i in the response div id.