Page 2 of 3

Re: Vote once with Status: ON / OFF feature

Posted: Tue Oct 11, 2011 12:11 pm
by v3inTe
No,.
i want to add the text "NOW PLAYING" at the first data..
and "UP NEXT" at the second data..

Re: Vote once with Status: ON / OFF feature

Posted: Wed Oct 12, 2011 9:48 pm
by v3inTe
anyone. :)

Re: Vote once with Status: ON / OFF feature

Posted: Thu Oct 13, 2011 12:05 am
by social_experiment

Code: Select all

<?php
switch($counter) {
		case 1:
		$title = 'Now Playing';
		break;
		case 2:
		$title = 'Up Next';
		break;
		default:
		$title = '';
		break;
	}
?>
Add this inside the while loop and somewhere in the script echo $title. Hth

Re: Vote once with Status: ON / OFF feature

Posted: Thu Oct 13, 2011 12:18 am
by v3inTe

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>&nbsp;&nbsp;&nbsp;';
    echo $ary['stitle'];
    echo ' - ';
    echo $ary['sartist'];
    echo '</b><br/>';
    echo '&nbsp;&nbsp;&nbsp;<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>';
}
?>
No changes.. :D
not working. i dont know if i placed the code correctly.

Re: Vote once with Status: ON / OFF feature

Posted: Thu Oct 13, 2011 12:27 am
by v3inTe
here's the result:
Image

Re: Vote once with Status: ON / OFF feature

Posted: Thu Oct 13, 2011 12:35 am
by social_experiment
Is there a specific reason for adding the title to the array $ary?

Re: Vote once with Status: ON / OFF feature

Posted: Thu Oct 13, 2011 12:50 am
by v3inTe
actually none..
why??

Re: Vote once with Status: ON / OFF feature

Posted: Thu Oct 13, 2011 1:48 am
by social_experiment
v3inTe wrote:actually none..
why??
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?

Re: Vote once with Status: ON / OFF feature

Posted: Fri Oct 14, 2011 5:44 pm
by v3inTe
yes, there is..
stitle, sartist, reqby, etc. :)

Re: Vote once with Status: ON / OFF feature

Posted: Sat Oct 15, 2011 2:43 am
by social_experiment
$ary['stitle'] already contains a value you might want to use later; use another variable like $title or $songStatus

Re: Vote once with Status: ON / OFF feature

Posted: Sun Oct 16, 2011 6:55 pm
by v3inTe
i got it. :)
thanks a lot!

Re: Vote once with Status: ON / OFF feature

Posted: Sun Oct 16, 2011 11:06 pm
by v3inTe
social_experiment,
another one..

if the table is empty,
it will echo the following msg "No song added yet"

Re: Vote once with Status: ON / OFF feature

Posted: Mon Oct 17, 2011 8:06 am
by social_experiment
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
 }
?>

Re: Vote once with Status: ON / OFF feature

Posted: Tue Oct 18, 2011 4:07 am
by v3inTe
thank you so much!
great help.

Re: Vote once with Status: ON / OFF feature

Posted: Tue Oct 18, 2011 5:54 pm
by v3inTe
hello social!
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>&nbsp;NOW PLAYING</b></font> | Req by:&nbsp;';
                break;
                case 2:
                $title = '<font style="color: red;"><b>&nbsp;UP NEXT</b></font> | Req by:&nbsp;';
                break;
                default:
                $title = '&nbsp;Requested by:&nbsp;';
                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>&nbsp;';
    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>';
}
?>
and

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
 }
?>
so that, if the status is not set to "yes" or "pause"
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.
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..
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!
i hope you can help with this.
thank you. :)