Jump to content

Need help with while() and Bootstrap Tables


Sarabveer

Recommended Posts

<?php
function getFullMonthName($num) {
	if ($num < 1 || $num > 12) {
		return "Unknown";
	}
	return ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][$num - 1];
}
$ids = mysqli_real_escape_string($db, $id);
$sql = "SELECT * FROM multimedia, keertan WHERE multimedia.id LIKE '$ids' AND keertan.multimediaid LIKE '$ids' ORDER BY k_order ASC";
$result = mysqli_query($db, $sql);
$title_list = "xyz";
$done = "xyz";
while ($myrow = mysqli_fetch_array($result)) {
	$location  = $myrow["location"];
	$program   = $myrow["program"];
	$year      = sprintf("%04s", $myrow["year"]);
	$month     = sprintf("%02s", $myrow["month"]);
	$monthName = getFullMonthName($month);
	$isnew     = $myrow["isnew"];
	if ($done != "true") {
		echo "<h3><b>$location $program $monthName $year</b></h3>";
    }
	$done = "true";
	while ($title_list != $myrow["title"]) {
        $title_list = $myrow["title"];
		$sublist = $myrow["sub_title"];
        echo "<div class=\"panel panel-primary\"><div class=\"panel-heading clickable\"><h3 class=\"panel-title\"><b>$title_list</b></h3>";
        echo "<small>$sublist</small><span class=\"pull-right\"><i class=\"fa fa-minus\"></i></span></div><div class=\"panel-sarabveer-table\"><table class=\"table\"><thead><tr><th>Time</th><th>Kirtani</th><th>MP3</th><th>Video</th></thead>";
	}
	if (strtotime($myrow["created"]) > strtotime("3 weeks ago")) {
		$newed = "NEW";
	} elseif (strtotime($myrow["modified"]) > strtotime("3 weeks ago")) {
		$newed = "UPDATED";
	} else {
		$newed = "";
	}
	printf("<tr><td>%s</td><td>%s <small>%s</small></td>", $myrow["length"], $myrow["keertaneeya"], $newed);
	$mp3f = urlencode($myrow['mp3_link']);
	if ($myrow["mp3_link"] != "") {
		printf("<td><a target=\"_blank\" href=\"http://www.akji.org.uk/multimedia/%s/%s/%s\"><img src=\"images/play.png\" border=\"0\" width=\"25\" height=\"25\"></a></td>", $myrow["location"], $year, $mp3f);
	} else {
		echo "<td></td>";
	}
	if ($myrow["rv1_link"] != "") {
		printf("<td><a target=\"_blank\" href=\"%s\"><img src=\"images/vplay.png\" border=\"0\" width=\"25\" height=\"25\"></a></td></tr>", $myrow["rv1_link"]);
	} else {
		echo "<td></td></tr>";
	}
	echo "</table></div></div>";
}
?>

So Basically I have this code that displays this page: https://akjmobile.org/keertannew.php?id=532

 

The problem is that the echo on line 97 runs to early and cuts of rest of the table information, making the other table information be spit out outside of the Bootstrap Panel.

 

How would I fix this?

Edited by Sarabveer
Link to comment
Share on other sites

  • 2 weeks later...
 echo "<div class=\"panel panel-primary\"><div class=\"panel-heading clickable\"><h3 class=\"panel-title\"><b>$title_list</b></h3>";
        echo "<small>$sublist</small><span class=\"pull-right\"><i class=\"fa fa-minus\"></i></span></div><div class=\"panel-sarabveer-table\"><table class=\"table\"><thead><tr><th>Time</th><th>Kirtani</th><th>MP3</th><th>Video</th></thead>";

Is inside your database loop. You're creating a panel and table for every single result. If that's not what you're intending to do I would move this and line 97 outside of your database loop.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.