CodeIgniter iterate the outputted row over each instance of the Html - php

I can't get <?php $row->entryData; ?></td> to output. If I have two rows in the database I need it to iterate over each instance of the Html. It's not doing that though. It is outputting all the rows in one box. How can I get it to output in the correct box?
<?php $userid = $this->session->userdata('userid');
$query = $this->db->query("SELECT * FROM churchMembers WHERE cMuserId = '{$userid}'");
$row = $query->row();
$membersChurchId = $row->cMchurchId;
$query = $this->db->query("SELECT wp.entryData, wp.entryCreationDateTime, u.firstname, u.lastname, u.userid, u.defaultImgURI FROM users u
INNER JOIN wallPosts wp ON wp.postingUserid = u.userid
WHERE wp.wpChurchId = '{$membersChurchId}'");
foreach ($query->result() as $row) { ?>
<table cellpadding="0" cellspacing="0" style="width: 500px; height: 107px" align="left">
<td valign="top" style="padding: 3px; width: 101px;" rowspan="2">
<img id="defaultImg a0" src="<?php echo base_url().$row->defaultImgURI; ?>" width="95" height="96" /></td>
<td valign="top" class="style1" style="width: 124px">
<a class="font1"><?php echo $row->firstname . " " . $row->lastname; ?></a>
</td>
<td valign="top" class="right-align-button1" style="height: 35px; width: 269px;">
<a class="link-font1" id="like" href="#" style="width: 138px">Like</a> </span>
<span class="font2"> | </span>
<a id="comment" href="#" style="width: 138px" class="link-font1">Comment</a><br />
<span class="font2"><?php echo $row->entryCreationDateTime; ?></span>
</td>
<tr>
<td valign="top" colspan="2" style="height: 72px">
<?php $row->entryData; ?></td>
</tr>
</table>
<?php } ?>

I guess you have to change:
<?php $row->entryData; ?>
To
<?php echo $row->entryData; ?> //you missed echo i guess
If everything else if fine in your code.

Related

Split page into 4 sections with data from database

How to split my page into 4 sections with data from database?
I'm displaying data from the database and they appear one by one on the table. And I want to split them into 4 parts and each of them will show another result from the database. In addition, I would like to make line in the middle, which will keep them separated.
That's my code, to show results from DB:
EDIT: Ok, I edited like u said, and now page is splitted on 2 section, but I got on them the same results. How to change this, that on the left side will be shown one record, and on the right side another.
$result = $wpdb->get_results("SELECT company_wojewodztwo, company_powiat, company_miasto, company_name, telefon, company_nip, company_opis FROM test WHERE company_wojewodztwo = '$woj' AND company_powiat = '$pow' AND company_miasto = '$nazwa' ORDER BY RAND()");
foreach ( $result as $k => $v ) {
$c_name = stripslashes($v->company_name);
$c_opis = stripslashes($v->company_opis);
$c_mob_nr = stripslashes($v->telefon);
$c_nip = stripslashes($v->company_nip);
?>
<table>
<tbody>
<tr style="height: 50%;">
<td style="width: 50%;"><?php echo $c_name; ?></td>
<td style="width: 50%;"><?php echo $c_name; ?></td>
</tr>
<tr style="height: 50%;">
<td style="width: 50%;"><?php echo $c_nip ?></td>
<td style="width: 50%;"><?php echo $c_nip ?></td>
</tr>
<tr style="height: 50%;">
<td style="width: 50%;"><?php echo $c_mob_nr ?></td>
<td style="width: 50%;"><?php echo $c_mob_nr ?></td>
</tr>
<tr style="height: 50%;">
<td style="width: 50%;"><?php echo $c_opis ?></td>
<td style="width: 50%;"><?php echo $c_opis ?></td>
</tr>
</tbody>
</table>
<?php if(count($result) != $k+1){ ?>
<p>___________________________________________________</p>
<?php } ?>
<?php
}
?>
do something like this:
<table>
<tbody>
<tr style="height: 50%;">
<td style="width: 50%;"><?php echo 'data 1'; ?></td>
<td style="width: 50%;"><?php echo 'data 2'; ?></td>
</tr>
<tr style="height: 50%;">
<td style="width: 50%;"><?php echo 'data 1'; ?></td>
<td style="width: 50%;"><?php echo 'data 2'; ?></td>
</tr>
</tbody>
</table>
I put styles inline, You try to put them in a css file.
Update your code...
<?php
global $wpdb;
$result = $wpdb->get_results("SELECT company_province, company_district, company_city, company_name, telefon, company_nip, company_opis FROM test WHERE company_province = '$woj' AND company_district = '$pow' AND company_city = '$nazwa' ORDER BY RAND()");
foreach ( $result as $k => $v ) {
$c_name = stripslashes($v['company_name']);
$c_opis = stripslashes($v['company_opis']);
$c_mob_nr = stripslashes($v['telefon']);
$c_nip = stripslashes($v['company_nip']);
?>
<div class="parent">
<table>
<tr><th><p><b> Name: </b></th><td>
<?php echo $c_name;?></p></td></tr>
<tr><th><p><b> NIP: </b></th><td>
<?php echo $c_nip;?></p></td></tr>
<tr><th><b> Number tel: </b></th><td>
<?php echo '+48 '.$c_mob_nr;?><br></td></tr>
<tr><th><b> Opis Firmy: </b></th><td>
<span class="more"> <?php echo $c_opis;?></span></td></tr>
</table>
<?php if(count($result) != $k+1){ ?>
<p>___________________________________________________</p>
<?php } ?>
</div>
<?php
}
?>

delete selected rows list in php mysql

I'm trying to delete the selected rows from the list I have in mysql so I won't have to delete the rows in my table one by one. When I press delete, my page refreshes without any php error but I don't get the result desired either. here is what I have:
<?php $product_set = find_all_products(); ?>
<body>
<form action="manage_products.php" method="delete">
<div class="page">
<article>
<div id="page">
<?php echo message(); ?>
<h2>Manage Products</h2>
<table>
<tr>
<th style="text-align: left; width: 125px;">Location</th>
<th style="text-align: left; width: 250px;">URL to the Product</th>
<th style="text-align: left; width: 100px;">First Name</th>
<th style="text-align: left; width: 100px;">Last Name</th>
<th style="text-align: left; width: 100px;">Size</th>
<th style="text-align: left; width: 100px;">Status</th>
<th style="text-align: left; width: 100px;">Checked</th>
<th colspan="2" style="text-align: left;">Actions</th>
</tr>
<?php while($product = mysqli_fetch_assoc($product_set)){ ?>
<tr>
<td><?php echo htmlentities($product["location"]);?></td>
<td><?php echo htmlentities($product["productURL"]); ?></td>
<td><?php echo htmlentities($product["fname"]); ?></td>
<td><?php echo htmlentities($product["lname"]); ?></td>
<td><?php echo htmlentities($product["size"]); ?></td>
<td><?php echo htmlentities($product["status"]); ?></td>
<td><input name="checkbox" type="checkbox" id="checkbox[]" value="<?php echo $product['id']; ?>"></td>
<td>Edit Order</td>
<td>Delete Order</td>
</tr>
<?php } ?>
</table>
<?php
// Check if delete button active, start this
if(isset($_GET['delete']))
{
$checkbox = $_GET['checkbox'];
for($i=0;$i<count($checkbox);$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM product WHERE link_id='$del_id'";
$result = mysql_query($sql);
}
// if successful redirect to delete_multiple.php
if($result){
$_SESSION["message"] = "Product deletion failed.";
redirect_to("created_products.php"); }
}
//mysqli_close($dbc);
?>
<br />
</div>
</div>
<br>
<input type="submit" name="submit" value="Delete" onclick="return val();"/>
</form>
<div class="clear-all"></div>
</article>
</div>
</body>
Also place all the code which is for deleting the rows in the starting of your file. Thank you #Traveller for this.
Instead of for loop, use WHERE IN
for($i=0;$i<count($checkbox);$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM product WHERE link_id='$del_id'";
$result = mysql_query($sql);
}
Replace that with
$ids = implode(",", $_POST['checkbox']);
$sql = "DELETE FROM product WHERE link_id in ($ids)";

Displaying submitted form results as a list of URL links

First of all my PHP skills are kinda limited, Hence my question to you here.
I have built a fairly complex form with multiple inputs(text boxs and drop downs) which are stored in a MYsql DB. When the form is submitted it displays on a new page as completed reports. These completed reports display one under the next every time the form is submitted. My question is, How can i get the reports displayed to show as a list of links to the individual reports rather then a list of complete reports.
I hope i've explained the situation well enough.
Code snippit from viewpage.php
<html>
<head>
<body>
<?php
mysql_connect("localhost","user","passwrd");
mysql_select_db("dtbase");
$order = "SELECT * FROM jobrequest" ;
$result = mysql_query($order);
while ($row=mysql_fetch_array($result)){
?>
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
<div style="padding:15px 0px 0px 100px;">
<table cellpadding="0" cellspacing="0" border="0" style="vertical-align:middle;width: 1139px; background-color:#213568; height:36px;">
<tr>
<td class="topbar">Client Request Form</td>
<td style="width:900px;"></td>
<td class="topbar"><a style="color:#ffffff;" href="logout.php?logout">Logout</a></td>
</tr>
</table>
<div class="main-wrap">
<div class="content">
<table cellpadding="0" cellspacing="0" border="0" style="width: 1137px; background-color:#ffffff; height:5px;">
<tr>
<td></td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" border="0" >
<tr>
<td style="vertical-align:top; width:5px;"></td>
<td style="vertical-align:top;"><?php include("includes/clientchoices.php"); ?></td>
<td style="vertical-align:top; padding:0px 5px 15px 5px;">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="vertical-align:top; width:1002px;"> <h1> Dashboard</h1></td>
</tr>
<tr>
<td style="vertical-align:top; background-color:#f5f5f5;"><h2>Job Request Form</h2></td>
</tr>
<tr>
<td style="vertical-align:top; background-color:#ffffff; height:5px;"> </td>
</tr>
<tr>
<td>
<div class="form">
<table cellspacing="0" cellpadding="0" border="0" style="width:998px">
<tr>
<td style="width:1002px; border:solid 1px #000000; padding:10px 0px 10px 0px;"><center><img src="../../images/spectra_logotop.jpg" alt="Spectra" title="Spectra" width="735" height="120" style="padding:5px;"></center>
</td>
</tr>
<tr>
<td>
<div style="padding:10px 0px 10px 0px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="headingsa">Project Leader:</td><td class="answersa"><div class= "typesectiona"><?php echo ($row['project_leader'] ); ?></div></td>
<td class="headingsb">Contact Number:</td><td class="answersb"><div class= "typesectionb"><?php echo ($row['contact_number'] ); ?></div></td>
<td class="headingsc">Company Details:</td><td class="answersc"><div class= "typesectionc"><?php echo ($row['company_details'] ); ?></div></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0">
<tr>
<td class="headings5">Contact Person On Site:</td><td class="answers5"><div class= "typesection5"><?php echo ($row['contactperson_onsite'] ); ?></div></td>
<td class="headings6">Contact Details:</td><td class="answers6"><div class= "typesection6"><?php echo ($row['contact_no'] ); ?></div></td>
<td class="headings7">Date:</td><td class="answers7"><div class= "typesection7"><?php echo ($row['date'] ); ?></div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0">
<tr>
<td class="headings1">Job/Order Number:</td><td class="answers1"><div class= "typesection1"><?php echo ($row['job_order_number'] ); ?></div></td>
<td class="headings2">Document Number:</td><td class="answers2"><div class= "typesection2"><?php echo ($row['doument_number'] ); ?></div></td>
<td class="headings3">QCP:</td><td class="answers3"><div class= "typesection3"><?php echo ($row['qcp'] ); ?></div></td>
<td class="headings4">Page No:</td><td class="answers4"><div class= "typesection4"><?php echo ($row['pageno'] ); ?></div></td>
</tr>
</table>
</td>
</tr>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="15px"></td>
<td><a class="othersubmitsLink" href="actionpdf.php">Email to Spectra</a></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
<?php
}
?>
</body>
</html>
You will need a separate PHP script for displaying a report based on a supplied ID. This separate script would look something like this:
Using mysqli
<?php
$conn = new mysqli("localhost", "user", "passwrd", "dtbase");
$jrQry = $conn->prepare("SELECT * FROM jobrequest WHERE jobrequest_id = ?");
$jrQry->bind_param('i', $_GET['jobrequest_id']);
$jrQry->execute();
$jobrequestResult = $jrQry->get_result();
$jobrequest = $jobrequestResult->fetch_assoc();
// At this point, $jobrequest will contain the jobrequest record you want to display.
?>
<!-- HTML FOR REPORT GOES HERE, USING $jobrequest VARIABLE TO SHOW THE DATA -->
Note that I have used mysqli in this example, if this is unsuitable you can use the old-style mysql commands, but for many many reasons (security chief among them) I would strongly suggest against this.
Using mysql
<?php
mysql_connect("localhost","user","passwrd");
mysql_select_db("dtbase");
$order = "SELECT * FROM jobrequest WHERE jobrequest_id = " . (int)$_GET['jobrequest_id'];
$result = mysql_query($order);
$jobrequest = mysql_fetch_array($result);
// At this point, $jobrequest will contain the jobrequest record you want to display.
?>
<!-- HTML FOR REPORT GOES HERE, USING $jobrequest VARIABLE TO SHOW THE DATA -->
Save this page as "viewjobrequest.php" and you will be able to load a given job request's report by supplying the jobrequest ID as a parameter in the URL, like so:
http://address_of_site/viewjobrequest.php?jobrequest_id=X
Now you can automatically generate a list of links to these pages by looking up your complete set of jobrequests and iterating over them, but instead on outputting a full report, just output a link:
Using mysqli
<?php
$conn = new mysqli("localhost", "user", "passwrd", "dtbase");
$jrQry = $conn->prepare("SELECT * FROM jobrequest WHERE jobrequest_id = ?");
$jrQry->bind_param('i', $_GET['jobrequest_id']);
$jrQry->execute();
$jobrequestResult = $jrQry->get_result();
?>
<ul>
<?php
while ($jobrequest = $jobrequestResult->fetch_assoc())
{
?>
<li>
<a href="viewjobrequest.php?jobrequest_id=<?php echo $jobrequest['jobrequest_id']; ?>">
View job request #<?php echo $jobrequest['jobrequest_id']; ?>
</a>
</li>
<?php
}
?>
</ul>
Using mysql
<?php
mysql_connect("localhost","user","passwrd");
mysql_select_db("dtbase");
$order = "SELECT * FROM jobrequest WHERE jobrequest_id = " . (int)$_GET['jobrequest_id'];
$result = mysql_query($order);
?>
<ul>
<?php
while ($jobrequest = mysql_fetch_assoc($result))
{
?>
<li>
<a href="viewjobrequest.php?jobrequest_id=<?php echo $jobrequest['jobrequest_id']; ?>">
View job request #<?php echo $jobrequest['jobrequest_id']; ?>
</a>
</li>
<?php
}
?>
</ul>
Note: I have deliberately omitted large portions of your HTML, you can add as much extra HTML as you need, I've just offered the bare bones to get you started.
BY looking at your code, I can say, it's not problem with PHP, it's more like HOW you are showing the result after fetching from database,
you are running loop, started from here
<?php while ($row=mysql_fetch_array($result)){ ?>
and ends here
<?php}?>
So everything inside loop or in easy words inside these brackets {} repeating again and again with new row of result fetched from database, if you take view source of viewpage.php you will see that style css file <link rel="stylesheet" href="css/style.css" type="text/css" /> repeating, Imagine if you are fetching 10 rows of result, you are also loading css file 10 times.
So the answer (most probably the solution) of your question is;
Your mysql query
<?php
mysql_connect("localhost","user","passwrd");
mysql_select_db("dtbase");
$order = "SELECT * FROM jobrequest" ;
$result = mysql_query($order);
$totalrows = mysql_num_rows($result); //Check Total Number of Rows To Check if Data Exist or Not
?>
and then in your HTML, First check if there are any rows exist in database which match your WHERE clause in mysql query.
//Set an if else statement here so incase if no data exist.
<?php if($totalrows > 0) {
//If row(s) exist run your while loop here
<?php while ($row=mysql_fetch_array($result)){ ?>
//Show the result here from database
//Close your loop
<?php } ?>
//Close your if condition
<?php } else { ?>
//Display a message here if there is no data to show
//Close your else bracket
<?php } ?>
With above explaniation I adjusted your HTML to show the result in desired way;
<table cellspacing="0" cellpadding="0" border="0" style="width:998px">
<tr>
<td style="width:1002px; border:solid 1px #000000; padding:10px 0px 10px 0px;"><center><img src="../../images/spectra_logotop.jpg" alt="Spectra" title="Spectra" width="735" height="120" style="padding:5px;"></center></td>
</tr>
<tr>
<td>
<?php if($totalrows > 0) {
<div style="padding:10px 0px 10px 0px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="headingsa">Link to Report</td>
</tr>
<?php while ($row=mysql_fetch_array($result)){ ?>
<tr>
//You have to replace `nameoffile.php` with file in which you want to display report and correct this (as i assumed it) if it's wrong `$row['id']`
<td>Open Report</td>
</tr>
<?php } ?>
</table>
</div>
<?php } else { ?>
<div style="padding:10px 0px 10px 0px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td>There is No Result To Show</td>
</tr>
</table>
</div>
<?php } ?>
</td>
</tr>
</table>
Note: MySQL will soon be deprecated, consider start using MYSQLi or PDO

Display products of particular vendor in Admin Panel

I have a basic admin panel where I can see all the vendors and all the products that have been added. In the vendors page, I want to add a link which when clicked on would display/add/edit only the products for that vendor. Any leads on how this can be done?
************ EDIT **************
This is how my products page looks like. This page displays all the products.
<?php
$sno=$pagination->getLimit() + 1;
$sql2 = $sql1." limit " . $pagination->getLimit() . ", ". $rowsperpage;
$res2 = #mysql_query($sql2, $connection) or die("failed");
$i = 1;
$c=1;
$k=0;
while($res=mysql_fetch_array($res2))
{
?>
<tr <?php if($k==0) { echo 'class=""'; } else { echo 'class="row_color"'; } ?> id="row<?php echo $i;?>">
<td class="table_text"><?php echo $sno; ?>.</td>
<td class="table_text" style="line-height:12pt;">
<?php
if($res['off_status']=='N')
{
?>
<span style="padding-left: 0px;font-weight:bold;color:#E8E8E8;"><?php echo $res['Name']; ?></span>
<?php
}
else
{
?>
<?php echo $res['Name']; ?>
<?php
}
?>
</td>
<td class="table_text" style="line-height:12pt;">
<?php
$rest_name = mysql_query("SELECT * FROM `restaurants` WHERE `RestID`='$res[RestID]'");
$res_fet = mysql_fetch_array($rest_name);
if($res['off_status']=='N')
{
?>
<span style="padding-left: 0px;font-weight:bold;color:#E8E8E8;"><?php echo $res_fet['Name']; ?></span>
<?php
}
else
{
?>
<?php echo $res_fet['Name']; ?>
<?php
}
?>
</td>
<td class="table_text" style="line-height:12pt;"> <?php
if($res['off_status']=='N')
{
?>
<span style="padding-left: 0px;font-weight:bold;color:#E8E8E8;"><?php echo date('d-m-Y',strtotime($res['StartDate']));?></span>
<?php
}
else
{
?>
<?php echo date('d-m-Y',strtotime($res['StartDate']));?>
<?php
}
?> </td>
<td class="table_text" style="line-height:12pt;"><?php
if($res['off_status']=='N')
{
?>
<span style="padding-left: 0px;font-weight:bold;color:#E8E8E8;"><?php echo date('d-m-Y',strtotime($res['ExpiryDate']));?></span>
<?php
}
else
{
?>
<?php echo date('d-m-Y',strtotime($res['ExpiryDate']));?>
<?php
}
?></td>
<td class="table_text"><table width="68" height="68" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffebc1">
<tr>
<td align="center"><?php
if($res['Image'] != "")
{
?>
<img src="../images/offers/thumb/<?php echo $res['Image']; ?>" border="0" />
<?php
}
else
{
?>
<img src="../images/no_image.jpg" width="88" height="76" border="0" />
<?php
}
?> </td>
</tr>
</table></td>
<td align="center" class="table_text"><img src="images/icon/level.png" width="47" height="43" border="0" /></td>
<td align="center" class="table_text"><img src="images/link.png" alt="" width="47" height="43" border="0" /></td>
<td align="center" class="table_text"><img src="images/icon/edit_icon.gif" width="16" height="15" border="0" /></td>
<td align="center" class="table_text"><img src="images/icon/view_icon.gif" width="16" height="16" border="0" /></td>
<?php
if($res['off_status']=='Y')
{
?>
<td align="center" class="table_text">Active</td>
<?php
}
else
{
?>
<td width="15%" align="center" class="table_text"> Inactive</td>
<?php
}
?>
<td width="14%" align="center" class="table_text"><img src="images/del.png" width="16" height="15" border="0" /></td>
</tr>
<?php
$c++;
$i++;
$k++;
$sno++;
if($k==2)
{
$k=0;
}
}
?>
<input type="hidden" name="acount" id="acount" value="<?php echo $i-1; ?>">
</table>
This is how I've called the link to the above mentioned page:
<?php
$sel=mysql_query("select * from offers where OfferID='".$id."'") or die(mysql_error());
$fet=mysql_fetch_array($sel);
$rest=mysql_query("select * from restaurants where RestID='".$fet['RestID']."'") or die(mysql_error());
$restfet=mysql_fetch_array($rest);
$dd= $fet['Links'];
$rest_id=$fet['RestID'];
$sql_mlink=mysql_query("select * from offers where off_status='Y' and OfferID!='".$id."' and RestID='".$rest_id."' order by OfferID asc") or die(mysql_error());
$sql_query = mysql_query("SELECT * FROM offers where RestID='".$res['RestID']."'");
$row = mysql_fetch_array($sql_query);
//$res_count=mysql_num_rows($row);
$sy = mysql_query("SELECT * FROM offers where RestID='".$res['RestID']."' and status='Y'");
$res_count=mysql_num_rows($sy);
$rw = mysql_fetch_array($sy);
?>
<td class="table_text">
Menu
</td>
You should be able to achieve this quite easily using php get and adjusting you're SQL slightly.
Add the vendor number/escaped name to the end of links to this page... e.g.:
<a href='this-page.php?vendor=vendor-1'>vendor 1</a>
Then at the beginning of the page check if there was a vendor set and if so, create some extra sql for the end of your statements. If not leave the extra sql variable blank so nothing is added:
if(!empty($_GET['vendor']))
{
$extra_sql = " AND vendor = ".$_GET['vendor'];
}
else
{
$extra_sql = "";
}
Then add the $extra_sql variable to the end of your existing SQL:
$rest=mysql_query("select * from restaurants where RestID='".$fet['RestID']."'".$extra_sql) or die(mysql_error());

some ?> appears in my page all tags opned are closed

I met some trouvle in my pages, some ?> ?> ?> ?> ?> ?> ?> does appears in my page, it seems lie the code is not interpreted, but all is closed and I do not know where it can comes from
below is my code
<?php
//For weight change
$down_icon = 'images/thumb_down.gif';
$same_icon = 'images/cool.gif';
$up_icon = 'images/thumb_up.gif';
$comment_icon = 'images/notebook.gif';
//DB Values for icons
$status_icons[0] = $down_icon;
$status_icons[1] = $same_icon;
$status_icons[2] = $up_icon;
?>
<style>
.fif {display: inline-block;
padding-left:5px;
padding-right: 5px;
/* box-shadow: 8px 8px 0px #aaa;
border-width:1px;
border-style:dashed;
border-color:black;}*/
}
</style>
<table class="noborder">
<tr><td>
<div class="uibutton-group">
<a class="uibutton" href="index.php?p=history&day=1">Lundi</a>
<a class="uibutton" href="index.php?p=history&day=2">Mardi</a>
<a class="uibutton" href="index.php?p=history&day=3">Mercredi</a>
<a class="uibutton" href="index.php?p=history&day=4">Jeudi</a>
<a class="uibutton" href="index.php?p=history&day=5">Vendredi</a>
<a class="uibutton" href="index.php?p=history&day=6">Samedi</a>
<a class="uibutton" href="index.php?p=history&day=7">Dimanche</a>
</div>
</td>
<td><b>Derniers jours en arrière </b> </td>
<td><div class="uibutton-group">
<a class="uibutton" href="index.php?p=history&day=<?php echo $_GET['day'] ?>&farback=30">30</a>
<a class="uibutton" href="index.php?p=history&day=<?php echo $_GET['day'] ?>&farback=60">60</a>
<a class="uibutton" href="index.php?p=history&day=<?php echo $_GET['day'] ?>&farback=90">90</a>
<a class="uibutton" href="index.php?p=history&day=<?php echo $_GET['day'] ?>&farback=120">120</a>
</div></td>
</tr>
</table><p><br></p>
<div class="maindivforexos" style="width:100%;display:inline-block">
<?php
if (!isset($_GET['day'])) {
$_GET['day'] = 1;
}
if (isset($_GET['farback'])) {
$farback = $_GET['farback'];
} else {
$farback = 28;
}
$query = "SELECT `record` FROM `workouts`
WHERE `workouts`.`day_number`='1'
AND `workouts`.`user` = {$_SESSION['userid']}
AND `workouts`.`record` >= SUBDATE(now(),INTERVAL {$farback} day)
GROUP BY `record` ";
$result = mysql_query($query);
if (!mysql_num_rows($result)):
?>
<div class=warning>Il n'y a pas d'enregistrements pour ce jour.</div>
<?php
else:
while ($cr = mysql_fetch_array($result)):
?>
<div style="width:200px" class="fif"><table style="width:100%">
<tr class="fbgreybox">
<td colspan="3" style="text-align: center;font-weight: bold">
<img src="images/calendar_2.png"> Séance du : <?php echo date('d-m-Y', strtotime($cr['record'])) ?>
</td>
</tr>
<?php
$sql = "SELECT `exercise` FROM `workouts` WHERE `record` = '{$cr['record']}' AND `user`= {$_SESSION['userid']} GROUP BY `exercise`";
$result = mysql_query($sql);
while ($exo = mysql_fetch_assoc($result)) :
?>
<tr class="fbinfobox">
<td colspan="3" style="text-align: left">
<img src="images/Sport-dumbbell.png"> <?php echo exerciseName($exo['exercise']) ?>
</td>
</tr>
<tr>
<td style="text-align: center;font-weight: bold">Séries</td>
<td style="text-align: center;font-weight: bold">Reps</td>
<td style="text-align: center;font-weight: bold">Poids</td>
</tr>
<?php
$rqt = "SELECT `set_number`, `reps`, `weight` FROM `workouts` WHERE `exercise` = {$exo['exercise']} AND `record` = '{$cr['record']}' AND `user` = {$_SESSION['userid']} ORDER BY `set_number`";
$result2 = mysql_query($rqt);
while ($detail = mysql_fetch_assoc($result2)):
?>
<tr>
<td>
Série <?php echo $detail['set_number'] ?>
</td>
<td>
<?php echo $detail['reps'] ?>
</td>
<td>
<?php echo $detail['weight'] ?>
</td>
</tr>
?>
<?php
endwhile;
endwhile;
?>
</table>
</div>
<?php
endwhile;
endif;
?>
</div>
I really have no Idead on where it can comes from because All tags opened are closed.
It appears between the div and the table in the loop
Anykind of help will be much appreciated
It looks like there is an extra closing PHP tag in your code.
<?php echo $detail['weight'] ?>
</td>
</tr>
?> <----------here

Categories