Yes
Noticed below where we bind input with type s (string), i (integer)
$query->bind_param('ss', $start,$end);
These correspond to the question marks.
Yes
Noticed below where we bind input with type s (string), i (integer)
$query->bind_param('ss', $start,$end);
These correspond to the question marks.
i still just get blank page. i ran the query in my phpMyAdmin and got some results back. here is my query from phpMyAdmin:
SELECT e.start, e.title, e.description, t.mobileURL, t.mobileFile, t.mobileIndicator, t.chanID
FROM epg AS e
LEFT JOIN tblMobile AS t ON t.chanID = e.id_channel
WHERE e.start
BETWEEN ‘2015-09-23 00:00:00’
AND ‘2015-09-23 23:59:59’
AND t.mobileActive = ‘1’
AND t.chanID = ‘4’
LIMIT 30 , 30
See you’ve changed both table and field names throughout this thread. Looks like where I have “timeBlockIndicator”, it should be “mobileIndicator” and where I have " AND t.id_channel = ? "; change to t.chanID if I am reading your post correctly.
Again, Adjust fields in the query as needed,
yes, i had to change it. it was a request from the owner of the DB. i did change the fields from your script to what they are in the DB right now. i copied the query from the php page i am using and pasted it to phpMyAdmin. for the id = 4 i get 36 results in the phpMyAdmin but when i run the page online i don’t get any output
Well this looks like what you should have.
$sql = "SELECT
e.start
, e.title
, e.description
, t.mobileURL
, t.mobileFile
, t.mobileIndicator
, t.chanID
FROM epg as e
LEFT JOIN tblMobile as t
ON t.chanID = e.id_channel
WHERE e.start BETWEEN ? AND ? AND t.mobileActive = '1'";
if(isset($_GET['id']) && is_numeric($_GET['id'])):
$sql .= " AND t.chanID = ? ";
endif;
$sql .= " ORDER BY e.start ASC";
$query = $conn->prepare($sql);
if(isset($_GET['id']) && is_numeric($_GET['id'])){
$query->bind_param('ssi', $start,$end,$_GET['id']);
}else{
$query->bind_param('ss', $start,$end);
}
$query->execute();
$result = $query->get_result();
while ($row = $result->fetch_assoc()) {
$data[$row['mobileIndicator']][strtotime($row['start'])] = $row;
}
Look like your version?
yes. and i still get nothing i am going to run simple query to see where my issue is
And when you un comment that print data line it shows nothing?
echo "<pre>";
print_r($data);
echo "</pre>";
I’m sure we must have different DB tables. Would be nice to have a copy of what you are working with.
Really hate even going here but here is a mysql version.
<?php
$host = "localhost";
$login = "";
$dbpass = "";
$dbname = "";
mysql_connect($host,$login,$dbpass) OR DIE
("There is a problem with the system. Please notify your system administrator." .mysql_error());
mysql_select_db($dbname) OR DIE
("There is a problem with the system. Please notify your system administrator." .mysql_error());
?>
<html>
<body>
<?php
$day = date("Y-m-d");
$start = date("Y-m-d H:i:s", strtotime($day));
$end = date("Y-m-d H:i:s", strtotime($day.' + 86400 seconds'));
$data = array();
$sql = "SELECT
e.start
, e.title
, e.description
, t.mobileURL
, t.mobileFile
, t.mobileIndicator
, t.chanID
FROM epg as e
LEFT JOIN tblMobile as t
ON t.chanID = e.id_channel
WHERE e.start BETWEEN '$start' AND '$end' AND t.mobileActive = '1'";
if(isset($_GET['id']) && is_numeric($_GET['id'])):
$sql .= " AND t.chanID = '{$_GET['id']} ";
endif;
$sql .= " ORDER BY e.start ASC";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$data[$row['mobileIndicator']][strtotime($row['start'])] = $row;
}
echo "<pre>";
print_r($data);
echo "</pre>";
echo "<table>
<tr>
<th>Hour</th>
<th>Time</th>
<th>Name</th>
</tr>\r";
for($h=0;$h<=24;$h++):
$hourstart = date("Y-m-d H:i:s", strtotime($start.' +'.$h.' hours'));
$hourend = date("Y-m-d H:i:s", strtotime($hourstart.' +3599 seconds'));
$hourstarttime = strtotime($hourstart);
$hourendtime = strtotime($hourend);
$hourshown = date("g:i a", strtotime($start.' +'.$h.' hours'));
echo '<tr>
<td>'.$hourshown.'</td>'."\r";
if (array_key_exists($h.'s',$data)){
foreach($data[$h.'s'] as $showtime => $showdata):
//double check time
if($showtime >= $hourstarttime && $showtime <= $hourendtime){
$showtimeshown = date("g:i a", $showtime);
// format link as needed
$link = $showdata['mobileURL'];
echo '<td>'.$showtimeshown.'</td><td><a href="'.$link.'">'.$showdata['title'].'</a></td>'."\r";
}else{
echo '<td> </td><td> </td>'."\r";
}
endforeach;
}else{
echo '<td> </td><td> </td>'."\r";
}
echo '</tr>'."\r";
endfor;
echo '</table>'."\r";
?>
</body>
</html>
ok, so i ran following and got no results:
<?php
$login = ".....";
$dbpass = ".....";
$dbname = ".......";
$conn = mysqli_connect('localhost', $login,$dbpass,$dbname);
?>
<html>
<body>
<?php
$day = date("Y-m-d");
$start = date("Y-m-d H:i:s", strtotime($day));
$end = date("Y-m-d H:i:s", strtotime($day.' + 86400 seconds'));
$data = array();
$sql = "SELECT * FROM tblMobile";
$query = $conn->prepare($sql);
$query->execute();
$result = $query->get_result();
while ($row = $result->fetch_assoc()) {
$data[$row['mobileURL']][($row['mobileFile'])] = $row;
}
//echo "<pre>";
print_r($data);;
…
then with this code i get 36 records:
<?php require_once('Connections/slovakvideo.php'); ?>
<?php
mysql_select_db($database_slovakvideo, $slovakvideo);
$query_rsALinks = "SELECT * FROM tblMobile";
$rsALinks = mysql_query($query_rsALinks, $slovakvideo) or die(mysql_error());
$row_rsALinks = mysql_fetch_assoc($rsALinks);
$totalRows_rsALinks = mysql_num_rows($rsALinks);
?>
<html>
<body>
<?php $x = 0;
do {
$x = $x + 1 ?>
<?php echo $x; ?>. <?php echo $row_rsALinks['mobileURL']; ?><br>
<?php } while ($row_rsALinks = mysql_fetch_assoc($rsALinks)); ?>
</body>
</html>
<?php
mysql_free_result($rsALinks);
?>
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.