PDA

View Full Version : can php change a background color of a html form field?



mdcloud
07-10-2007, 04:08 PM
what i have is class registration. it is in weeklong sessions. on my admin area i have a drop down in a form. my admin user selects the class week to look at in that drop down. is there a way to show them using php what class weeks have new signups in them?

mburt
07-13-2007, 02:28 PM
With PHP, it all has to be done before the page loads. And yes, PHP can do this, but it is dependant on how the form works:

<form style="<?php if (condition) echo 'background:#ff0000;'; ?>" ...>
</form>

mdcloud
07-13-2007, 04:21 PM
below is my listing page. you can ignore most of that code, but i thought i would throw it in just in case.

basicly we have people approved to come or not in a database field called Approved with a 0 for not approved and a 1 for approved. i need the drop down at the bottom of my code to change things based wether or not anyone in that week is not approved. how would i do this?

would i have to use an array to put all not approved people in and then a if statement on each day somehow? i am very new to php so please excuse my ignorance. thanks for any help you can offer.

mdcloud



<?php
require('link.php');

// If search is active
if ($_POST['search']) {
$date = $_POST['date'];
$count = 0;

// Get results from database
$users = mysql_query("SELECT * FROM `form` WHERE Date = '$date' ORDER BY LName ASC") or die ('Error Getting Users! \n<br />\n' .mysql_error());
$chk = mysql_num_rows($users);

// If no users found
if ($chk < 1) {
echo 'There are no users registered on the date: <b>'.$date.'</b>
<br />
<a href="bih.html">Back to Menu</a>';
}

// If there are users
else {

// Set header to download users




echo '
<html><head><title>Admin Area</title><meta http-equiv="refresh" content="1000">
<link rel="stylesheet" href="http://www.beinhealth.com/main.css"></head>
<body bgcolor="#FFFFCC" text="#000000" alink="#AF1F00" vlink="#AF1F00" link="#AF1F00">
<div id="Layer1" style="position:absolute; width:1200px; height:800px; z-index:1; visibility: visible; left: 0px; top: 0px;"><img class="header1" src="http://www.beinhealth.com/pics/header1.jpg" width="1083" height="224" border="0"></div><div id="Layer2" style="position:absolute; width:800px; height:800px; z-index:2; visibility: visible;"><br><br><br><br><br><br><br><br><br>
<table align="left"><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></td></tr></table><table width="650" class="main"><tr><td>

People attending '.$date.'<br><br>

Sort Options -- Show only:<br>
<hr align="Center" size="1">
<a href="dateandprinted.php?date='.$date.'">Printed</FONT></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="dateandnotprinted.php?date='.$date.'">Not Printed</FONT></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="dateandapproved.php?date='.$date.'">Approved</FONT></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="dateandnotapproved.php?date='.$date.'">Not Approved</FONT></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="dateall.php?date='.$date.'">View All</FONT></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<hr align="Center" size="1">


<br><br>
<table border="1" bordercolor="black" cellpadding="4">
<tr>
<td>Menu</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>Name</td>
<td>Printed</td>
<td>Approved</td>
</tr>
';
// Show data for each user
while($u = mysql_fetch_array($users)) {
echo '
<tr>
<td><a href="edit2.php?RegID='.$u['RegID'].'" target="_blank">Update</a></td>
<td><a href="view.php?RegID='.$u['RegID'].'" target="_blank">View</a></td>
<td><a href="print.php?RegID='.$u['RegID'].'" target="_blank">Print</a></td>
<td><a href="approve.php?RegID='.$u['RegID'].'" target="_blank">Approve</a></td>
<td>&nbsp;</td>
<td>'.$u['FName'].' '.$u['LName'].'</td>
<td>';

if ($u['Printed'] == 1) {
echo 'Yes';
}
else {
echo'No';
}

echo '</td><td>';

if ($u['Approved'] == 1) {
echo 'Yes';
}
else {
echo'No';
}
echo'</td>
</tr>';
$count++;
}
echo '</table> <br><br>Number Of Attendees is '.$count.'<br><br>
<a href="bih.html">Back to Menu</a><br><br>
</td></tr></table>
</div>
</body>
</html>
';
}

// End table

}


// download on click
if (!$_POST['search']) {
echo '
<html>
<head>
<title>
Admin Area
</title>

<link rel="stylesheet" href="../main.css">

</head>
<body bgcolor="#FFFFCC" text="#000000" alink="#AF1F00" vlink="#AF1F00" link="#AF1F00">


<div id="Layer1" style="position:absolute; width:1200px; height:800px; z-index:1; visibility: visible; left: 0px; top: 0px;">
<img class="header1" src="../pics/header1.jpg" width="1083" height="224" border="0">

</div>
<div id="Layer2" style="position:absolute; width:800px; height:800px; z-index:2; visibility: visible;">
<br><br><br><br><br><br><br><br><br><br>
<table align="left">
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></td>
</tr>
</table>
<table width="650" class="main">
<tr>
<td>
<center><h2>Download Program Signups.</h2></center><br><br>
<form method="post" action="">
<b>Date:</b> <select name="date" size="1">
<option selected value="">Program...</option>

<option value="For My Life 06/10/07 - 06/16/07">For My Life 06/10/07 - 06/16/07</option>
<option value="For Their Life 06/10/07 - 06/16/07">For Their Life 06/10/07 - 06/16/07</option>
<option value="For My Life 06/24/07 - 06/30/07">For My Life 06/24/07 - 06/30/07</option>
<option value="For My Life 07/08/07 - 07/14/07">For My Life 07/08/07 - 07/14/07</option>
<option value="For Their Life 07/08/07 - 07/14/07">For Their Life 07/08/07 - 07/14/07</option>
<option value="For My Life 07/22/07 - 07/28/07">For My Life 07/22/07 - 07/28/07</option>
<option value="For My Life 07/29/07 - 08/4/07">For My Life 07/29/07 - 08/4/07</option>
<option value="For Their Life 07/29/07 - 08/4/07">For Their Life 07/29/07 - 08/4/07</option>
<option value="For My Life 08/12/07 - 08/18/07">For My Life 08/12/07 - 08/18/07</option>
<option value="For My Life Childrens 08/12/07 - 08/18/07">For My Life Childrens 08/12/07 - 08/18/07</option>
<option value="For My Life 08/19/07 - 08/25/07">For My Life 08/19/07 - 08/25/07</option>
<option value="For Their Life 08/19/07 - 08/25/07">For Their Life 08/19/07 - 08/25/07</option>
<option value="For My Life 09/02/07 - 09/08/07">For My Life 09/02/07 - 09/08/07</option>
<option value="For My Life 09/09/07 - 09/15/07">For My Life 09/09/07 - 09/15/07</option>
<option value="For Their Life 09/09/07 - 09/15/07">For Their Life 09/09/07 - 09/15/07</option>
<option value="For My Life 09/23/07 - 09/29/07">For My Life 09/23/07 - 09/29/07</option>
<option value="For My Life 09/30/07 - 10/06/07">For My Life 09/30/07 - 10/06/07</option>
<option value="For My Life 10/14/07 - 10/20/07">For My Life 10/14/07 - 10/20/07</option>
<option value="For My Life Childrens 10/14/07 - 10/20/07">For My Life Childrens 10/14/07 - 10/20/07</option>
<option value="For My Life 10/21/07 - 10/27/07">For My Life 10/21/07 - 10/27/07</option>
<option value="For Their Life 10/21/07 - 10/27/07">For Their Life 10/21/07 - 10/27/07</option>
<option value="For My Life 11/04/07 - 11/10/07">For My Life 11/04/07 - 11/10/07</option>
<option value="For My Life 11/11/07 - 11/17/07">For My Life 11/11/07 - 11/17/07</option>
<option value="For Their Life 11/11/07 - 11/17/07">For Their Life 11/11/07 - 11/17/07</option>
<option value="For My Life 11/25/07 - 12/01/07">For My Life 11/25/07 - 12/01/07</option>
<option value="For My Life 12/02/07 - 12/08/07">For My Life 12/02/07 - 12/08/07</option>
<option value="For Their Life 12/02/07 - 12/08/07">For Their Life 12/02/07 - 12/08/07</option>
<option value="For My Life 12/09/07 - 12/15/07">For My Life 12/09/07 - 12/15/07</option>
</select>
<input type="submit" name="search" value="Search" />
</form><br><br><br><a href="bih.html">Back to Menu</a>
</td></tr></table>
</div>
</body>
</html>
';
}


?>

superjadex12
07-13-2007, 06:25 PM
I have read your posts about 8 times and I still can't understand what you want your code to do. I can show you how to have select fields populated with different options based different keys, or show you how to have a certain select option display as default (useful to show a particular users current setting, by means of a select field). But I don't know if these things are truly what you want? Could you try to explain more precisely what you want to happen and use ONE specific example?

mdcloud
07-13-2007, 09:27 PM
sorry for the confusion. i will try to explain it more clearly.

it might help for you to know what the site does. it is basicly a reservation system for classes. a client books a specific week. now an admin must check them out and approve them to come. what i have set up for them is a drop down list in a html form. what i need is a way to show the admin person which weeks in that drop down list have new clients signed up. i though that if you had the drop down list, but could change something about the weeks displayed in that list that had new signups it would work well.

take a look at this
www.beinhealth.com/testing/list.php

you can see how the program works for us now. as you can see to find out what weeks have new people in it i have to go to each date and look. i want something to denote this on the list before i go to each week to save time

i hope this more fully explains what i am trying to do.

superjadex12
07-13-2007, 11:10 PM
i think i get it now. We'll need to know how you are storing your data right now. If its in a mysql table then you can just set up your tables in such a way that enables you to count the number of rows (signups) for a particular date, or date range. Then you display the data in such a way that if the rows > 0 then it outputs the link, if the rows count is 0 then it does not. You could even display the actual count number.

THere are tons of things you can do with mysql but they all rely heavily on HOW WELL your data is organized based on your specific needs.

Hopefully you have some knowledge of mysql, because I can help you on some of that stuff and give you some suggestions. You should also look into "mysql normalization" when you can. It's a great concept of how to organize your data.

So post back with some info on how you store your data right now and we can work on ways to better store, manupulate, and thus display that data.

mdcloud
07-15-2007, 04:38 PM
well i have a mysql database set up with a table called form in it. in that table i have columns for all of the things i ask. however i think i already have a way to show who is new, i just do not have a way to display it on the drop down menu. we use a approved field. when a person signs up i have mysql set up to give them a 0 by default. what my admin needs to see the dates for is the not approved or the dates that have a client that still have a 0 in that field. once they are approved then it is changed to a 1 in that field.

so to break it all down i need a function that denotes which dates have a client in it that has a 0 in the approved field. my dates are orginized by a text field. when they sign up it is a drop down so the text put in that field is exact so i can keep it straight. if you look at my code above what it basicly does is search for what i enter. it could be a text field, or in this case a drop down that has the exact wording of the dates. i hope this makes sense.

superjadex12
07-15-2007, 10:16 PM
<?
$users = mysql_query("SELECT Date, Approved FROM `form` WHERE Approved = '0' GROUP BY Date") or die ('Error Getting Users! \n<br />\n' .mysql_error());
$chk = mysql_num_rows($users);

// If no users found
if ($chk < 1) {
echo 'All users for all dates have been approved</b>
<br /><a href="bih.html">Back to Menu</a>';
}

// If there are users
else {
echo '<select name="date">';

while($u = mysql_fetch_array($users)){
echo '<option value="'.$u[Date].'">'.$u[Date].'</option>';
}

echo '</select>';

?>

that code will search your form table for all users that have '0' in the approved field. It will then GROUP all of these rows BY the date. What grouping does is instead of listing all the rows it groups them base on some parameter, in this case, "date" , so that all users with a '0' in the approved field AND having the same date, will get grouped as ONE row.

So your output will be a drop down list of dates that have at least 1 user who has not been approved.

mdcloud
07-16-2007, 03:40 PM
that is definatly a start, i will give it a try but i will still have to have 2 different pages which is what i was trying to get away from. on showing new users only and one showing all. that is why i wanted the drop down to show all of the dates, but change the background color or something of the dates with not approved users in it. is that possible?

mac

ps thanks for all you help

littleEd
07-19-2007, 07:12 PM
i am not sure i fully understand what you want but here is my take on it

i read that u want a drop down box like the one superjadex12 suggested. but on top of that you would like the dates that have new users to be highlighted.

to highlight in a drop down box you want to assign a class to the items you want highlighted.
so a highlighted row looks like this.

echo '<option value="'.$u[Date].'" class="highlight">'.$u[Date].'</option>';
with css to go along with it



<head>
<style type="text/css">
<!--
.highlight {
color: #0000ff ;
background-color: #f00 ;
-->
</style>
</head>


a line that you dont want highlighted will look like this

echo '<option value="'.$u[Date].'">'.$u[Date].'</option>';


when you do your query, you will have to find out which groups have new users to approve (i assume that means your 'approved field = 0') and for each of those groups you will output the highlight code.


I dont have time to do up a query for it but it the logic for the drop down will be somthing like..



echo '<select name="date">';

while($u = mysql_fetch_array($users))
{

if($newUsers>0)
echo '<option value="'.$u[Date].'" class="highlight">'.$u[Date].'</option>';
else
echo '<option value="'.$u[Date].'">'.$u[Date].'</option>';
}

echo '</select>';



hope that made some sense. i didnt test any of the code so there may be errors in there but i think that might help u get to where u want to be