wiggst3r Posted October 3, 2008 Share Posted October 3, 2008 Hi I have a table, with several rows. Each row is pulled from the db and then styled globally. I have the following columns in the db: catid, briefed, job, category, needed, timeofday, status, orderid, importancy I can edit a rows details, via a script and what I'm looking to do is: If a row has the importancy of '1' style that row with another colour. I have this as my code so far: <div id="listContainer"> <? foreach($list as $item) { // display eddited row and edit row form if(isset($_GET['state']) && $_GET['state'] == 'edit' && $_GET['catid'] == $item['catid']) { ?> <form action="save-digital.php" name="insert_priority" method="post"> <table> <tr> <td><input class="catid" name="catid" type="hidden" id="catid" value="<? echo $item['catid']; ?>"/></td> <td><input class="briefed" name="briefed" type="text" id="briefed" value="<? echo $item['briefed']; ?>"/></td> <td><input class="job" name="job" type="text" id="job" value="<? echo $item['job']; ?>"/></td> <td><input class="category" name="category" type="text" id="category" value="<? echo $item['category']; ?>"/></td> <td> <select name="needed" id="needed" class="needed"> <option value="<? echo $item['needed']; ?>" <?php if (isset($missing) && $_POST['needed'] == '') { ?> selected="selected" <?php } ?> ><? echo $item['needed']; ?></option> <option value="Mon" <?php if (isset($missing) && $_POST['needed'] == 'Mon') { ?> selected="selected" <?php } ?> >Mon</option> <option value="Tues" <?php if (isset($missing) && $_POST['needed'] == 'Tues') { ?> selected="selected" <?php } ?> >Tues</option> <option value="Weds" <?php if (isset($missing) && $_POST['needed'] == 'Weds') { ?> selected="selected" <?php } ?> >Weds</option> <option value="Thurs" <?php if (isset($missing) && $_POST['needed'] == 'Thurs') { ?> selected="selected" <?php } ?> >Thurs</option> <option value="Fri" <?php if (isset($missing) && $_POST['needed'] == 'Fri') { ?> selected="selected" <?php } ?> >Fri</option> <option value="Ongoing" <?php if (isset($missing) && $_POST['needed'] == 'Ongoing') { ?> selected="selected" <?php } ?> >Ongoing</option> <option value="w/c" <?php if (isset($missing) && $_POST['needed'] == 'w/c') { ?> selected="selected" <?php } ?> >w/c</option></td> </select> <td> <select name="timeofday" id="timeofday" class="timeofday"> <option value="<? echo $item['timeofday']; ?>" <?php if (isset($missing) && $_POST['timeofday'] == '') { ?> selected="selected" <?php } ?> ><? echo $item['timeofday']; ?></option> <option value="am" <?php if (isset($missing) && $_POST['timeofday'] == 'am') { ?> selected="selected" <?php } ?> >am</option> <option value="pm" <?php if (isset($missing) && $_POST['timeofday'] == 'pm') { ?> selected="selected" <?php } ?> >pm</option> <option value="1st" <?php if (isset($missing) && $_POST['timeofday'] == '1st') { ?> selected="selected" <?php } ?> >1st</option> <option value="2nd" <?php if (isset($missing) && $_POST['timeofday'] == '2nd') { ?> selected="selected" <?php } ?> >2nd</option> <option value="3rd" <?php if (isset($missing) && $_POST['timeofday'] == '3rd') { ?> selected="selected" <?php } ?> >3rd</option> <option value="4th" <?php if (isset($missing) && $_POST['timeofday'] == '4th') { ?> selected="selected" <?php } ?> >4th</option> <option value="5th" <?php if (isset($missing) && $_POST['timeofday'] == '5th') { ?> selected="selected" <?php } ?> >5th</option> <option value="6th" <?php if (isset($missing) && $_POST['timeofday'] == '6th') { ?> selected="selected" <?php } ?> >6th</option> <option value="7th" <?php if (isset($missing) && $_POST['timeofday'] == '7th') { ?> selected="selected" <?php } ?> >7th</option> <option value="8th" <?php if (isset($missing) && $_POST['timeofday'] == '8th') { ?> selected="selected" <?php } ?> >8th</option> <option value="9th" <?php if (isset($missing) && $_POST['timeofday'] == '9th') { ?> selected="selected" <?php } ?> >9th</option> <option value="10th" <?php if (isset($missing) && $_POST['timeofday'] == '10th') { ?> selected="selected" <?php } ?> >10th</option> <option value="11th" <?php if (isset($missing) && $_POST['timeofday'] == '11th') { ?> selected="selected" <?php } ?> >11th</option> <option value="12th" <?php if (isset($missing) && $_POST['timeofday'] == '12th') { ?> selected="selected" <?php } ?> >12th</option> <option value="13th" <?php if (isset($missing) && $_POST['timeofday'] == '13th') { ?> selected="selected" <?php } ?> >13th</option> <option value="14th" <?php if (isset($missing) && $_POST['timeofday'] == '14th') { ?> selected="selected" <?php } ?> >14th</option> <option value="15th" <?php if (isset($missing) && $_POST['timeofday'] == '15th') { ?> selected="selected" <?php } ?> >15th</option> <option value="16th" <?php if (isset($missing) && $_POST['timeofday'] == '16th') { ?> selected="selected" <?php } ?> >16th</option> <option value="17th" <?php if (isset($missing) && $_POST['timeofday'] == '17th') { ?> selected="selected" <?php } ?> >17th</option> <option value="18th" <?php if (isset($missing) && $_POST['timeofday'] == '18th') { ?> selected="selected" <?php } ?> >18th</option> <option value="19th" <?php if (isset($missing) && $_POST['timeofday'] == '19th') { ?> selected="selected" <?php } ?> >19th</option> <option value="20th" <?php if (isset($missing) && $_POST['timeofday'] == '20th') { ?> selected="selected" <?php } ?> >20th</option> <option value="21st" <?php if (isset($missing) && $_POST['timeofday'] == '21st') { ?> selected="selected" <?php } ?> >21st</option> <option value="22nd" <?php if (isset($missing) && $_POST['timeofday'] == '22nd') { ?> selected="selected" <?php } ?> >22nd</option> <option value="23rd" <?php if (isset($missing) && $_POST['timeofday'] == '23rd') { ?> selected="selected" <?php } ?> >23rd</option> <option value="24th" <?php if (isset($missing) && $_POST['timeofday'] == '24th') { ?> selected="selected" <?php } ?> >24th</option> <option value="25th" <?php if (isset($missing) && $_POST['timeofday'] == '25th') { ?> selected="selected" <?php } ?> >25th</option> <option value="26th" <?php if (isset($missing) && $_POST['timeofday'] == '26th') { ?> selected="selected" <?php } ?> >26th</option> <option value="27th" <?php if (isset($missing) && $_POST['timeofday'] == '27th') { ?> selected="selected" <?php } ?> >27th</option> <option value="28th" <?php if (isset($missing) && $_POST['timeofday'] == '28th') { ?> selected="selected" <?php } ?> >28th</option> <option value="29th" <?php if (isset($missing) && $_POST['timeofday'] == '29th') { ?> selected="selected" <?php } ?> >29th</option> <option value="30th" <?php if (isset($missing) && $_POST['timeofday'] == '30th') { ?> selected="selected" <?php } ?> >30th</option> <option value="31st" <?php if (isset($missing) && $_POST['timeofday'] == '31st') { ?> selected="selected" <?php } ?> >31st</option> </select> </td> <td> <select name="status" id="status" class="status"> <option value="<? echo $item['status']; ?>" <?php if (isset($missing) && $_POST['status'] == '') { ?> selected="selected" <?php } ?> ><? echo $item['status']; ?></option> <option value="With Us" <?php if (isset($missing) && $_POST['status'] == 'us') { ?> selected="selected" <?php } ?> >With Us</option> <option value="With Client" <?php if (isset($missing) && $_POST['status'] == 'client') { ?> selected="selected" <?php } ?> >With Client</option> <option value="With Creative" <?php if (isset($missing) && $_POST['status'] == 'creative') { ?> selected="selected" <?php } ?> >With Creative</option> </select> <td> <td> <select name="importancy" id="importancy" class="importancy"> <option value="<? echo $item['importancy']; ?>" <?php if (isset($missing) && $_POST['importancy'] == '') { ?> selected="selected" <?php } ?> ><? echo $item['importancy']; ?></option> <option value="1" <?php if (isset($missing) && $_POST['importancy'] == '1') { ?> selected="selected" <?php } ?> >Yes</option> <option value="0" <?php if (isset($missing) && $_POST['importancy'] == '0') { ?> selected="selected" <?php } ?> >No</option> </select> <td> <td class="gap"></td> <td><input type="image" name="submit" value="submit" style="margin-top: 4px; margin-right: 5px;" src="../images/sm-tick-box.jpg" class="save" alt="Save Edit" title="Save Row" /></td> <td><input type="image" style="margin-top: 0px; margin-right: 8px;" src="../images/delete_image.jpg" class="cancel" alt="Cancel Edit" title="Cancel Edit" ></td> </tr> </table></form> <?php } else { //display normal row ?> <div id="item_<?=$item['catid'];?>"> <p class="briefed"><?=$item['briefed'];?></p> <p class="job_number"><?=$item['job'];?></p> <p class="category"><?=$item['category'];?></p> <p class="needed"><?=$item['needed'];?> <?=$item['timeofday'];?></p> <p class="status"><?=$item['status'];?></p> <p class="order_id"><?=$item['orderid'];?></p> <p class="link"><a href="digital_asda.php?state=edit&catid=<?=$item['catid']?>"><img src="../images/edit_image.jpg" height="20" border="0" alt="Edit Row" title="Edit Row" /></a></p> <p class="delete"><a href="delete_row-digital.php?catid=<?=$item['catid']?>"><img src="../images/trash-empty.jpg" height="20" border="0" alt="Delete Row" title="Delete Row" /></a></p> </div> <? } } ?> Any ideas on how I can do this? Link to comment https://forums.phpfreaks.com/topic/126878-change-td-row-depending-on-mysql-query/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.