Vote once with Status: ON / OFF feature
Moderator: General Moderators
Re: Vote once with Status: ON / OFF feature
No,.
i want to add the text "NOW PLAYING" at the first data..
and "UP NEXT" at the second data..
i want to add the text "NOW PLAYING" at the first data..
and "UP NEXT" at the second data..
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Vote once with Status: ON / OFF feature
Code: Select all
<?php
switch($counter) {
case 1:
$title = 'Now Playing';
break;
case 2:
$title = 'Up Next';
break;
default:
$title = '';
break;
}
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Vote once with Status: ON / OFF feature
Code: Select all
<?php
// check the value from the voting status table
$qry = "SELECT status FROM songreqstat";
$sql = mysql_query($qry);
$ary = mysql_fetch_array($sql);
$value = $ary['status'];
if (strtolower($value) == 'yes' or strtolower($value) == 'pause') {
// select the data from the database
$qry = "SELECT * FROM songreqlist WHERE songstatus='approved' ORDER BY srlid ASC";
$sql = mysql_query($qry);
$counter = 1;
echo '<table broder="0" width="305">';
// echo table headers, etc
while ($ary = mysql_fetch_array($sql)) {
switch($counter) {
case 1:
$ary['stitle'] = 'Now Playing';
break;
case 2:
$ary['stitle'] = 'Up Next';
break;
default:
$title = '';
break;
}
echo '<tr>';
echo '<td><div class="number-bg"><div class="number">';
echo $counter;
echo '</div></div></td>';
echo '<td width="100%"><div class="reqbg"><b> ';
echo $ary['stitle'];
echo ' - ';
echo $ary['sartist'];
echo '</b><br/>';
echo ' <small><font style="color:#e6e6e6;">Requested by: ';
echo $ary['reqby'];
echo '</font></small></div></td>';
echo '<td></td>';
echo '</tr>';
$counter = $counter + 1;
}
echo '</table>';
}
else {
echo '<center><b><br/><br/><br/>Sorry, Song Request will not be entertained at this moment.<br/><br/>a Current
DJ is playing/finishing all remaining song request(s).<br/><br/>or DJ is not accepting song request
anymore.</b></center>';
}
?>not working. i dont know if i placed the code correctly.
Re: Vote once with Status: ON / OFF feature
here's the result:


- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Vote once with Status: ON / OFF feature
Is there a specific reason for adding the title to the array $ary?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Vote once with Status: ON / OFF feature
actually none..
why??
why??
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Vote once with Status: ON / OFF feature
Thought there might a issue with adding the value to the array but it doesn't seem to be that. Is there a stitle field within your database?v3inTe wrote:actually none..
why??
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Vote once with Status: ON / OFF feature
yes, there is..
stitle, sartist, reqby, etc.
stitle, sartist, reqby, etc.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Vote once with Status: ON / OFF feature
$ary['stitle'] already contains a value you might want to use later; use another variable like $title or $songStatus
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Vote once with Status: ON / OFF feature
i got it. 
thanks a lot!
thanks a lot!
Re: Vote once with Status: ON / OFF feature
social_experiment,
another one..
if the table is empty,
it will echo the following msg "No song added yet"
another one..
if the table is empty,
it will echo the following msg "No song added yet"
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Vote once with Status: ON / OFF feature
For the last message to be displayed you have to count the amount of rows within the table
Code: Select all
<?php
// 'id' should be some unique key, i use the primary key of the table usually.
$countSql = "SELECT COUNT(id) FROM table";
$countQry = mysql_query($countSql);
$countAry = mysql_fetch_array($countQry);
$rows = $countAry[0];
if ($rows == 0) {
$title = 'No song added yet';
echo $title;
}
else {
// echo your table, data, etc
}
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Vote once with Status: ON / OFF feature
thank you so much!
great help.
great help.
Re: Vote once with Status: ON / OFF feature
hello social!
if i place the separate code in the page, it shows two echos..
is there a way to combine the two??
and
so that, if the status is not set to "yes" or "pause"
it'll echo this line:
if the status is YES / PAUSE AND the table has no data yet,
that's the time that "No song added yet" will appear..
otherwise, display all data in the table..
because in my case,
there are 2 messages display..
thank you.
if i place the separate code in the page, it shows two echos..
is there a way to combine the two??
Code: Select all
<?php
// check the value from the voting status table
$qry = "SELECT status FROM songreqstat";
$sql = mysql_query($qry);
$ary = mysql_fetch_array($sql);
$value = $ary['status'];
if (strtolower($value) == 'yes' or strtolower($value) == 'pause') {
// select the data from the database
$qry = "SELECT * FROM songreqlist WHERE songstatus='approved' ORDER BY srlid ASC";
$sql = mysql_query($qry);
$counter = 1;
echo '<table broder="0" width="305">';
// echo table headers, etc
while ($ary = mysql_fetch_array($sql)) {
switch($counter) {
case 1:
$title = '<font style="color: red;"><b> NOW PLAYING</b></font> | Req by: ';
break;
case 2:
$title = '<font style="color: red;"><b> UP NEXT</b></font> | Req by: ';
break;
default:
$title = ' Requested by: ';
break;
}
echo '<tr>';
echo '<td><div class="number-bg"><div class="number">';
echo $counter;
echo '</div></div></td>';
echo '<td width="100%"><div class="reqbg"><b> ';
echo $ary['stitle'];
echo ' - ';
echo $ary['sartist'];
echo '</b><br/>';
echo '<small>';
echo $title;
echo $ary['reqby'];
echo '</small></div></td>';
echo '<td></td>';
echo '</tr>';
$counter = $counter + 1;
}
echo '</table>';
}
else {
echo '<center><b><br/><br/><br/>Sorry, Song Request will not be entertained at this moment.<br/><br/>a Current
DJ is playing/finishing all remaining song request(s).<br/><br/>or DJ is not accepting song request
anymore.</b></center>';
}
?>
Code: Select all
<?php
// 'id' should be some unique key, i use the primary key of the table usually.
$countSql = "SELECT COUNT(id) FROM table";
$countQry = mysql_query($countSql);
$countAry = mysql_fetch_array($countQry);
$rows = $countAry[0];
if ($rows == 0) {
$title = 'There are no song on the list.<br/>Please wait the current DJ to approve your Song Request.<br/>Thank you!';
echo $title;
}
else {
// echo your table, data, etc
}
?>it'll echo this line:
Code: Select all
Sorry, Song Request will not be entertained at this moment.
a Current DJ is playing/finishing all remaining song request(s).
or DJ is not accepting song request anymore.that's the time that "No song added yet" will appear..
otherwise, display all data in the table..
because in my case,
there are 2 messages display..
i hope you can help with this.Sorry, Song Request will not be entertained at this moment.
a Current DJ is playing/finishing all remaining song request(s).
or DJ is not accepting song request anymore.
There are no song on the list.
Please wait the current DJ to approve your Song Request.
Thank you!
thank you.