PHP - How To Display Checkbox Group As Part Of If Statement
Can someone show me the correct code to display a group of checkbox values as part of an if statement? For example: in Programme One, lesson 100, lesson 310 and lesson 102 are available. In Programme Two, lesson 302, lesson 201, and lesson 102 are available. The "lesson types" are a checkbox group. I need to output the lesson types depending on whether they are part of Programme One or Two, along with other variables such as instructor student ratio.
I put the following code together where field_lessons is the checkbox group; <?php if ($fieldsObjects['field_type']->data == "Programme One") { print '<p class="details_heading03">Instructor Student Ratio</p>'; echo $fieldsFormatted['field_student_ratio']. '<br />'; foreach ($fieldsObjects['field_lessons']->data as $name => $value) { echo $value; echo "<br/>"; } else { echo "no"; } ?> I have also tried using this statement: <?php if ($fieldsObjects['field_type']->data == "Programme One") { print '<p class="details_heading03">Instructor Student Ratio</p>'; echo $fieldsFormatted['field_student_ratio']. '<br />'; echo (isset($fieldsObjects['field_lessons']->data) && is_array($fieldsObjects['field_lessons']->data)) ? } else { echo "no"; } ?> I am new to php, and I am customising a template which is part of Sobi2, which has been installed as a component of Joomla! (CMS)? Thank you jo Similar TutorialsHi, I am using check box group in my php form, The user can choose multiple answers, if he choose 3 answers and the form is submitted only one answer is displayed in mysql Code: [Select] GetSQLValueString($_POST['father'], "text"), any help please? Thanks Need some help here! I want to build a friendgroup - I have a full working friendsystem. My ide is this. I got a list of friends, make a group named Test. Put selected friends in there, make another group and put another friends in there. Some idees how to do that with prepared statements?? I search for tutorials, but couldn't find any. Any suggestions? The functions I need is this: 1. Make group 2. Add friend to group 3. Show group with selected friends 4. Rename groups 5. Move friend from one group to another 6. Delete group with all friends inside 7. Delete a empty group 8. Option to search for friends inside a group Tutorial, free source code - everything would help to solve this mystery ! So far is this the code I made, and didn't work at all public function create_friendgroup($profileownerid, $friends = NULL, $name) { $sql = "SELECT fg_friends_id FROM friend_groups WHERE fg_member_id = '$profileownerid' LIMIT 1"; if($stmt = $this->conn->prepare($sql)) { $stmt->execute(); $stmt->bind_result($friend); $stmt->fetch(); $stmt->close(); } if($friend != null) { $ua = explode(",", $friend); $ua = array_unique($ua); foreach ($ua as $u) { if($u !=NULL && $u !=$profileownerid) { $oldusers .= "{$u},"; } } } $newusers = $profileownerid; if ($oldusers != null) { $newusers .= "," . $oldusers; } $sql = "INSERT INTO friend_groups(fg_member_id,fg_friends_id, fg_name, fg_created_date) VALUES (?,?,?,?)"; $date = date("d-m-Y H:i"); if($stmt = $this->conn->prepare($sql)) { $stmt->bind_param('iiss',$profileownerid,$friends = trim($newusers, ","), $name,$date); $stmt->execute(); $stmt->close(); } } K.F Hi, i have written a section of code for my website and i have been trying to get it to work but whatever i try it will not work Here is the code Code: [Select] $upgrade_user = mysql_query("SELECT * FROM user_info WHERE id='$id'"); while($row = mysql_fetch_array($upgrade_user)){ $real_balance = $row["$balance"]; $real_rank = $row["$rank"]; } echo $real_balance; if($real_rank == 'merchant' && $real_balance > '500'){ $n1x = '<a href="upgrades_info.php?userid=$id&rank=noble"><img src="images/noble.jpg" width="170" height="200" /></a>'; } else { $n1x = '<img src="images/noblex.jpg" width="170" height="200" />'; } It should outbut the first if, but instead it keeps displaying the else, i have checked the $real_rank and it matches merchant and the $real_balance is over 500. Any ideas? I am guessing its a simple error in the way i have written it, but i can't seem to get it to work. Thanks I am new to PHP and am currently learning the ropes. I have writen some code to insert a line into a mySQL database. I have created 3 fields in the mySQL database and am passing values two them. I can use a declared variable to pass information to the filed ID (Index filed in mySQL) but if I use a variable to pass purely text values the database is not updated. mysql_query( "INSERT INTO $tbl_name (category_Name, ID, test) VALUES ($category, $internalId, $category2)" ); If I replace the variables with specific text, the rows are added successfully. mysql_query( "INSERT INTO $tbl_name (category_Name, ID, test) VALUES ('werwerwer', $internalId, 'werrr')" ); It must be something stupid, I am sure. Full code below ob_start(); $host="localhost:8888"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="expenses"; // Database name $tbl_name="expense_category"; // Table name $category="test3"; $internalId="7"; $category2="test3"; // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); mysql_query( "INSERT INTO $tbl_name (category_Name, ID, test) VALUES ('werwerwer', $internalId, 'werrr')" ); echo "Done now 6!"; ?> Let's say I have a variable called $big_paragraph I want to display the variable IF it contains the word "hello". The word may or may not be there AND it could be anywhere in that paragraph (separated by a space before and after it to signify that it is a word). So I can't use substr since it assumes I know the position. Thanks. The program is working for part of the data . It can display in the CSS and HTML code, however, the other data can not display . I do not why . They are same structure . Please tell me the reason. Thank you very much. I have done this successfully in the past, but this time not working. I have 4 different html sections and I only want the individual section to display if a variable is set or is set to a specified term. But this code shows all of the sections no matter what, even though I'm using if() and elseif(). This code sample is the whole page, excuse the length, but only way to fix what I am doing wrong. <head> <?php require_once ('includes/auth.php'); require_once ('includes/config.php'); require_once ('includes/connect.php'); $action = $_POST['action']; $agencyid = $_POST['agencyid']; function clean($str) { $str = @trim($str); if (get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } if (isset($_POST['next1'])) { $fieldrep = clean($_POST['fieldrep']); $agencytype = clean($_POST['typeofagency']); $agencyent = clean($_POST['typeofent']); $exclusive = clean($_POST['exclusivity']); $capcarrier = clean($_POST['formcapt']); $contdate = clean($_POST['contdate']); $agencyname = clean($_POST['agencyname']); $physstr = clean($_POST['physstr']); $physcity = clean($_POST['physcity']); $physstate = clean($_POST['physstate']); $physzip = clean($_POST['physzip']); $physcount = clean($_POST['physcounty']); $mailstr = clean($_POST['mailstr']); $mailcity = clean($_POST['mailcity']); $mailstate = clean($_POST['mailstate']); $mailzip = clean($_POST['mailzip']); $mailcount = clean($_POST['mailcounty']); $fedtaxid = clean($_POST['fedtaxid']); $w9payto = clean($_POST['w9payto']); $agencylic = clean($_POST['agencylic']); $busphone = clean($_POST['bustele']); $busfax = clean($_POST['busfax']); $eandocar = clean($_POST['eocarrier']); $eandopolnum = clean($_POST['eopolnum']); $agencyemail = clean($_POST['agencyemail']); $website = clean($_POST['agencywebsite']); $car1name = clean($_POST['topcar1']); $car1prem = clean($_POST['topcardol1']); $car2name = clean($_POST['topcar2']); $car2prem = clean($_POST['topcardol2']); $car3name = clean($_POST['topcar3']); $car3prem = clean($_POST['topcardol3']); $car4name = clean($_POST['topcar4']); $car4prem = clean($_POST['topcardol4']); $car5name = clean($_POST['topcar5']); $car5prem = clean($_POST['topcardol5']); $perline = clean($_POST['perslineper']); $comline = clean($_POST['commlineper']); $lifeline = clean($_POST['lifelineper']); $sccar1 = clean($_POST['carrier1']); $sccar2 = clean($_POST['carrier2']); $sccar3 = clean($_POST['carrier3']); $sccar4 = clean($_POST['carrier4']); $sccar5 = clean($_POST['carrier5']); $choicepoint = clean($_POST['choicepoint']); $clientinfo = "INSERT INTO agency SET fieldrep = '$fieldrep', agencytype = '$agencytype', agencyent = '$agencyent', exclusive = '$exclusive', capcarrier = '$capcarrier', contdate = '$contdate', agencyname = '$agencyname', physstr = '$physstr', physcity = '$physcity', physstate = '$physstate', physzip = '$physcount', mailstr = '$mailstr', mailcity = '$mailcity', mailstate = '$mailstate', mailzip = '$mailzip', mailcount = '$mailcount', fedtaxid = '$fedtaxid', w9payto = '$w9payto', agencylic = '$agencylic', busphone = '$busphone', busfax = '$busfax', eandcar = '$eandcar', eandopolnum = '$eandopolnum', agencyemail = '$agencyemail', website = '$website', car1name = '$car1name', car1prem = '$car1prem', car2name = '$car2name', car2prem = '$car2prem', car3name = '$car3name', car3prem = '$car3prem', car4name = '$car4name', car4prem = '$car4prem', car5name = '$car5name', car5prem = '$car5prem', perline = '$perline', comline = '$comline', lifeline = '$lifeline', sccar1 = '$sccar1', sccar2 = '$sccar2', sccar3 = '$sccar3', sccar4 = '$sccar4', sccar5 = '$sccar5', choicepoint = '$choicepoint'"; $newclient = mysql_query($clientinfo) or die(mysql_error()); $agencyid = mysql_insert_id(); } if (isset($_POST['next2'])) { $name = clean($_POST['name']); $title = clean($_POST['emptype']); $ownership = clean($_POST['ownership']); $yrsins = clean($_POST['yrsins']); $profdesig = clean($_POST['profdesig']); $resstr = clean($_POST['resstr']); $rescity = clean($_POST['rescity']); $resstate = clean($_POST['resstate']); $reszip = clean($_POST['reszip']); $rescounty = clean($_POST['rescounty']); $social = clean($_POST['social']); $dob = clean($_POST['dob']); $tele = clean($_POST['tele']); $inslicense = clean($_POST['inslicense']); $emptype = clean($_POST['emptype']); $agencyid = clean($_POST['agencyid']); $empinsert = mysql_query("INSERT INTO employees SET name = '$name', title = '$title', ownership = '$ownership', yrsins = '$yrsins', profdesig = '$profdesig', resstr = '$resstr', rescity = '$rescity', resstate = '$resstate', reszip = '$reszip', rescounty = '$rescounty', social = '$social', dob = '$dob', tele = '$tele', inslicense = '$inslicense', emptype = '$emptype', agencyid = '$agencyid'")or die(mysql_error()); } if(isset($_POST['addemp'])) { $name = clean($_POST['name']); $title = clean($_POST['emptype']); $ownership = clean($_POST['ownership']); $yrsins = clean($_POST['yrsins']); $profdesig = clean($_POST['profdesig']); $resstr = clean($_POST['resstr']); $rescity = clean($_POST['rescity']); $resstate = clean($_POST['resstate']); $reszip = clean($_POST['reszip']); $rescounty = clean($_POST['rescounty']); $social = clean($_POST['social']); $dob = clean($_POST['dob']); $tele = clean($_POST['tele']); $inslicense = clean($_POST['inslicense']); $emptype = clean($_POST['emptype']); $agencyid = clean($_POST['agencyid']); $empinsert = mysql_query("INSERT INTO employees SET name = '$name', title = '$title', ownership = '$ownership', yrsins = '$yrsins', profdesig = '$profdesig', resstr = '$resstr', rescity = '$rescity', resstate = '$resstate', reszip = '$reszip', rescounty = '$rescounty', social = '$social', dob = '$dob', tele = '$tele', inslicense = '$inslicense', emptype = '$emptype', agencyid = '$agencyid'")or die(mysql_error()); } if (isset($_POST['submit'])) { $captive = clean($_POST['captive']); $mgastruc = clean($_POST['mgastruc']); $pastdue = clean($_POST['pastdue']); $suits = clean($_POST['suits']); $crimes = clean($_POST['crimes']); $suspensions = clean($_POST['suspensions']); $submitfinal = mysql_query("UPDATE agency SET captive = '$captive', mgastruc = '$mgastruc', pastdue = '$pastdue', suits = '$suits', crimes = '$crimes', suspensions = '$suspensions', completed = 'Yes' WHERE ID = '$agencyid'") or die(mysql_error()); } ?> </head> <body> <div id="containerfull"><!-- Use"containerfull" for 100% width. For fixed width, use "container980", "container760" or "container600" (the number is the layout width in pixels). --> <div id="header"> <h1><a href="http://www.yoursite.com/"><img width="400" height="100" src="images/logo.jpg" /></a></h1> </div> <div id="menu"> <ul> <li><a href="index.html">Home</a></li> <li><a class="current" href="signup.html">Signup a Producer</a></li> </ul> </div> <?php if (isset($_POST['next1'])) { ?> <div id="main"> <div id="containerfull"> <h3>D. Employee Information</h3> <table> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <p> <tr> <td>Owner Name</td><td colspan="9"><input type="text" size="50" maxlength="75" name="name" tabindex="1" /></td> </tr> <tr> <td>Employee Type</td><td><select size="1" name="emptype" tabindex="2"> <option value="Owner">Owner</option> <option value="Employee">Employee</option> </select></td> </tr> <tr> <td>% Ownership</td><td> </td><td><input type="text" size="3" maxlength="3" name="ownership" tabindex="2" /></td><td> </td><td>Years In Insurance</td><td><input type="text" size="3" maxlength="3" name="yrsins" tabindex="3" /></td><td> </td><td>Professional Designations</td><td><input type="text" size="25" maxlength="50" name="profdesig" tabindex="4" /></td> </tr> <tr> <td>Resident Address</td><td colspan="8"><input type="text" size="50" maxlength="75" name="resstr" tabindex="5" /></td> </tr> <tr> <td> </td><td>City</td><td><input type="text" size="20" maxlength="45" name="rescity" tabindex="6" /></td><td>State</td> <td> <select tabindex="6" name="resstate" size="1" tabindex="10"> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="DC">DC</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select> </td><td>Zip</td><td><input type="text" size="10" maxlength="10" name="reszip" tabindex="8" /></td><td>County</td><td><input type="text" size="25" maxlength="45" name="rescounty" tabindex="9" /></td> </tr> <tr> <td>Social Security #</td><td><input type="text" size="11" maxlength="11" name="social" tabindex="10" /></td><td> </td><td>Date Of Birth</td><td><input type="text" size="10" maxlength="10" name="dob" tabindex="11" /></td><td>Home Telephone</td><td><input type="text" size="12" maxlength="12" name="tele" tabindex="12" /></td> </tr> <input type="hidden" value="<?php echo $agencyid; ?>" name="agencyid" /> <input type="hidden" value="addemp" name="action" /> <tr> <td><input type="submit" value="Add Employee" name="addemp" tabindex="12" /></td><td><input type="submit" value="Next" name="next2" tabindex="13" /></td> </tr> </form> </table> <?php } elseif (isset($_POST['next2'])) { ?> <div id="main"> <div id="containerfull"> <h3>F. Questions</h3> <table> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <tr> <td>1. Is agent/agency affiliated with ANY captive entity or carrier?</td><td><select size="1" name="captive" tabindex="1"> <option value="No">No</option> <option value="Yes">Yes</option> </select></td> </tr> <tr> <td>2. Is agent/agency affiliated with ANY MGA structure?</td><td><select size="1" name="mgastruc" tabindex="2"> <option value="No">No</option> <option value="Yes">Yes</option> </select></td> </tr> <tr> <td>3. Any account current or unearned commission balances past due to any company?</td><td><select size="1" name="pastdue" tabindex="3"> <option value="No">No</option> <option value="Yes">Yes</option> </select></td> </tr> <tr> <td>4. Any judgements or suits pending against the Agency?</td><td><select size="1" name="suits" tabindex="4"> <option value="No">No</option> <option value="Yes">Yes</option> </select></td> </tr> <tr> <td>5. Have you or anyone in your Agency ever been convicted of a felony crime in any state or federal court?</td><td><select size="1" name="crimes" tabindex="5"> <option value="No">No</option> <option value="Yes">Yes</option> </select></td> </tr> <tr> <td>6. Any license suspensions in the past five years?</td><td><select size="1" name="suspensions" tabindex="6"> <option value="No">No</option> <option value="Yes">Yes</option> </select></td> </tr> <tr> <td><label for="explainyes">Explain any yes answers:</label><textarea cols="60" rows="10" wrap="VIRTUAL" maxlength="1000" name="explainyes" tabindex="7"></textarea></td> </tr> <tr> <td><h3>G. Checklist (Please include the following paperwork when submitting to corporate office)</h3></td> </tr> <input type="hidden" value="submit" name="action" /> <input type="hidden" value="<?php echo $agencyid; ?>" name="agencyid" /> <tr> <td><input type="submit" value="Submit" name="submit" tabindex="8" /></td> </tr> </form> </table> <?php } elseif (isset($_POST['adduser'])) { ?> <div id="containerfull"> <div class="left"> <p> <table> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <tr> <td>Employee List</td> </tr> <?php $emplistquery = mysql_query("SELECT * FROM employees WHERE agencyid = '$agencyid'") or die(mysql_error()); while ($emplist = mysql_fetch_array($emplistquery)) { ?> <tr> <td>Name:</td><td><?php echo $emplist['name']; ?></td><td>Title:</td><td><?php echo $emplist['title']; ?></td> </tr> <?php } ?> </table> </p> </div> <div class="clear"> </div> </div> <div id="main"> <div id="containerfull"> <h3>D. Employee Information</h3> <table> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <p> <tr> <td>Owner Name</td><td colspan="9"><input type="text" size="50" maxlength="75" name="name" tabindex="1" /></td> </tr> <tr> <td>Employee Type</td><td><select size="1" name="emptype" tabindex="2"> <option value="Owner">Owner</option> <option value="Employee">Employee</option> </select></td> </tr> <tr> <td>% Ownership</td><td> </td><td><input type="text" size="3" maxlength="3" name="ownership" tabindex="2" /></td><td> </td><td>Years In Insurance</td><td><input type="text" size="3" maxlength="3" name="yrsins" tabindex="3" /></td><td> </td><td>Professional Designations</td><td><input type="text" size="25" maxlength="50" name="profdesig" tabindex="4" /></td> </tr> <tr> <td>Resident Address</td><td colspan="8"><input type="text" size="50" maxlength="75" name="resstr" tabindex="5" /></td> </tr> <tr> <td> </td><td>City</td><td><input type="text" size="20" maxlength="45" name="rescity" tabindex="6" /></td><td>State</td> <td> <select tabindex="6" name="resstate" size="1" tabindex="10"> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="DC">DC</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select> </td><td>Zip</td><td><input type="text" size="10" maxlength="10" name="reszip" tabindex="8" /></td><td>County</td><td><input type="text" size="25" maxlength="45" name="rescounty" tabindex="9" /></td> </tr> <tr> <td>Social Security #</td><td><input type="text" size="11" maxlength="11" name="social" tabindex="10" /></td><td> </td><td>Date Of Birth</td><td><input type="text" size="10" maxlength="10" name="dob" tabindex="11" /></td><td>Home Telephone</td><td><input type="text" size="12" maxlength="12" name="tele" tabindex="12" /></td> </tr> <input type="hidden" value="<?php echo $agencyid; ?>" name="agencyid" /> <td><input type="submit" value="Cancel & Next" name="next2" tabindex="12"/></td><td><input type="submit" value="Add Employee" name="addemp" tabindex="13" /></td><td><input type="submit" value="Next" name="next2" tabindex="14" /></td> </form> </table> <?php } elseif (isset($_POST['submit'])) { ?> <table> <form action="print.php" method="POST"> <tr> <td>Information Submitted</td> </tr> <tr> <td>Print</td><td><select size="1" name="printname" tabindex="1"> <option value="Application">Application</option> <option value="Agreement">Agreement</option></td> </tr> <input type="hidden" value="<?php echo $agencyid; ?>" name="agencyid" /> <input type="hidden" value="submit" name="action" /> <tr> <td><input type="submit" value="Print" name="print" tabindex="2" /></td> </tr> </form> </table> <?php } else { ?> <div id="feature"> <div class="left"> <p> <table> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <tr> <td>Field Rep:</td><td><input type="text" size="25" maxlength="40" name="fieldrep" tabindex="1" /></td> </tr> <tr> <td>Type of Agency:</td><td><input type="text" size="25" maxlength="40" name="typeofagency" tabindex="2" /></td> </tr> <tr> <td>Type of Entity:</td><td><input type="text" size="25" maxlength="40" name="typeofent" tabindex="3" /></td> </tr> </table> </p> </div> <div class="right"> <p> <table> <tr> <td align="right">Exclusivity:</td><td><input type="text" size="25" maxlength="40" name="exclusivity" tabindex="4" /></td> </tr> <tr> <td align="right">Former Captive Carrier:</td><td><input type="text" size="25" maxlength="40" name="formcapt" tabindex="5" /></td> </tr> <tr> <td align="right">Contract Date:</td><td><input type="text" size="25" maxlength="40" name="contdate" tabindex="6" /></td> </tr> </table> </p> </div> <div class="clear"> </div> </div> <div id="main"> <div id="containerfull"> <h3>A. Agency Information</h3> <p> <table> <tr> <td>Agency Name</td><td colspan="4"><input name="agencyname" type="text" size="65" maxlength="65" tabindex="6" /></td> </tr> <tr> <td>Physical Address</td><td colspan="2"><input type="text" size="25" maxlength="50" name="physstr" tabindex="7" /></td><td>City</td><td><input type="text" size="25" maxlength="40" name="physcity" tabindex="7" /></td> </tr> <tr> <td> </td><td>State</td><td> <select tabindex="6" name="physstate" size="1" tabindex="8"> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="DC">DC</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select></td><td>Zip</td><td><input type="text" size="5" maxlength="10" name="physzip" tabindex="9" /></td><td>County</td><td><input type="text" size="20" maxlength="40" name="physcounty" tabindex="10" /></td> </tr> <tr> <td>Mailing Address</td><td colspan="2"><input type="text" size="25" maxlength="50" name="mailstr" tabindex="7" /></td><td>City</td><td><input type="text" size="25" maxlength="40" name="mailcity" tabindex="7" /></td> </tr> <tr> <td> </td><td>State</td><td> <select tabindex="6" name="mailstate" size="1" tabindex="8"> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="DC">DC</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select></td><td>Zip</td><td><input type="text" size="5" maxlength="10" name="mailzip" tabindex="9" /></td><td>County</td><td><input type="text" size="20" maxlength="40" name="mailcounty" tabindex="10" /></td> </tr> <tr> <td>Federal Tax ID</td><td colspan="2"><input type="text" size="11" maxlength="11" name="fedtaxid" tabindex="11" />(99-9999999)</td><td>W9 Pay to Name</td><td colspan="2"><input type="text" size="25" maxlength="40" name="w9payto" tabindex="12" /></td> </tr> <tr> <td>Agency License Number</td><td><input type="text" size="15" maxlength="15" name="agencylic" /></td> </tr> <tr> <td>Business Telephone</td><td colspan="2"><input type="text" size="25" maxlength="25" name="bustele" tabindex="13" /></td><td>Business Fax</td><td><input type="text" size="25" maxlength="25" name="busfax" tabindex="14" /></td> </tr> <tr> <td>E&O Carrier</td><td colspan="2"><input type="text" size="25" maxlength="50" name="eocarrier" tabindex="14" /></td><td>Policy #</td><td colspan="2"><input type="text" size="25" maxlength="40" name="eopolnum" tabindex="15" /></td> </tr> <tr> <td>Agency Email Address</td><td colspan="4"><input type="text" size="40" maxlength="50" name="agencyemail" tabindex="16" /></td> </tr> <tr> <td>Website Address</td><td colspan="4"><input type="text" size="60" maxlength="75" name="agencywebsite" tabindex="17" /></td> </tr> <tr> <td colspan="10"><h3>B. Top 5 Carriers You Represent Now, Include Premium</h3></td> </tr> <tr> <td colspan="2">1. <input type="text" size="30" maxlength="45" name="topcar1" tabindex="18" /></td><td colspan="2">$ <input type="text" size="30" maxlength="45" name="topcardol1" tabindex="19" /></td> </tr> <tr> <td colspan="2">2. <input type="text" size="30" maxlength="45" name="topcar2" tabindex="20" /></td><td colspan="2">$ <input type="text" size="30" maxlength="45" name="topcardol2" tabindex="21" /></td> </tr> <tr> <td colspan="2">3. <input type="text" size="30" maxlength="45" name="topcar3" tabindex="22" /></td><td colspan="2">$ <input type="text" size="30" maxlength="45" name="topcardol3" tabindex="23" /></td> </tr> <tr> <td colspan="2">4. <input type="text" size="30" maxlength="45" name="topcar4" tabindex="24" /></td><td colspan="2">$ <input type="text" size="30" maxlength="45" name="topcardol4" tabindex="25" /></td> </tr> <tr> <td colspan="2">5. <input type="text" size="30" maxlength="45" name="topcar5" tabindex="26" /></td><td colspan="2">$ <input type="text" size="30" maxlength="45" name="topcardol5" tabindex="27" /></td> </tr> <tr> <td colspan="10"><h3>Percentage of Business Written</h3></td> </tr> <tr> <td align="right">Personal Lines</td><td>%<input type="text" size="3" maxlength="3" name="perslineper" tabindex="28" /></td><td align="right">Commercial Lines</td><td>%<input type="text" size="3" maxlength="3" name="commlineper" tabindex="29" /></td><td align="right">Life/Health</td><td>%<input type="text" size="3" maxlength="3" name="lifelineper" tabindex="30" /></td> </tr> <tr> <td colspan="10"><h3>C. Carriers to be provided through</h3></td> </tr> <tr> <td colspan="10">1.<select size="1" name="carrier1" tabindex="31"> </select></td> </tr> <tr> <td colspan="10">2.<select size="1" name="carrier2" tabindex="32"> <option selected="selected"></option> </select></td> </tr> <tr> <td colspan="10">3.<select size="1" name="carrier3" tabindex="33"> <option selected="selected"></option> </select></td> </tr> <tr> <td colspan="10">4.<select size="1" name="carrier4" tabindex="34"> <option selected="selected"></option> </select></td> </tr> <tr> <td colspan="10">5.<select size="1" name="carrier5" tabindex="35"> <option selected="selected"></option> </select></td> <tr> <td colspan="10"><h3>ChoicePoint Node ID</h3><input type="text" size="40" maxlength="40" name="choicepoint" tabindex="36" /></td> </tr> </tr> <tr><td><input type="submit" value="Next" name="next1" tabindex="37" /></td></tr> </table> <?php } ?> </p> <div class="clear"> </div> </div> <div class="clear"> </div> </div> Hi, I am using a PHP's preg_match() to search through string, and displaying its pattern, but want to display only part of it. E.g. looks like Code: [Select] preg_match('/shape=\'.*\'/sU',$value,$matches); The search displays " class='PHPfreaks' " From the search I would like to display only the part highlighted in bold. " '/shape=\'.*\'/sU' " So the final value to be displayed should be " PHPfreaks " Regards, Abhishek I know that there is a way to this with javascript, but I don't know how it would work. I am much more familiar with php so I figured I would ask here to see if anyone might have a good php solution. I'm trying to have a form text field display depending on whether or not the user checks a specific box, but I'm not sure where to start. I've searched around but I didn't find anything that would help. Basically I want to have a checkbox that asks if the user would like to link their account to an email address. If the checkbox is selected, a textbox will then appear on the page for them to enter an email address. Can anyone point me in the right direction on where to start? Thanks for your help. Hi, having problems getting checkboxes to display all reuslts when a user selects more than one check box say in the category section and one in the location section - see page http://www.partyco.co.uk/event-and-party-venues/ - submit to see reults page: I managed to get it to display reults if the user only seletc either a right or left column option OR one of each - BUT not when thet select multiple categories and one location - and ideas how to do this ? putting it into an array perhaps - but how - new to some of this.... here is the code for the reults page: Code: [Select] <?php $location = $_POST[location]; $category = $_POST[category]; ?> <?php $Link = mysql_connect("xxxxxxxxx", "xxxxxxxxx", "xxxxxxxx") or die(mysql_error()); mysql_select_db("xxxxxxxx") or die(mysql_error()); // selects db listings when location not given if (empty($location)) { $query = "SELECT * FROM venues WHERE category = '$category' order by title"; $result = mysql_query($query) or die(mysql_error()); // selects db listings when category not given } elseif(empty($category)) { $query = "SELECT * FROM venues WHERE location = '$location' order by title"; $result = mysql_query($query) or die(mysql_error()); // selects db listings when both given }else { $query = "SELECT * FROM venues WHERE category = '$category' and location = '$location' order by title"; $result = mysql_query($query) or die(mysql_error()); } while($row = mysql_fetch_array($result)){ echo "<div class=\"resultsShort\" style=\"margin-bottom:10px;\">"; echo "<h2 id=\"resultsHeading\">"; echo $row['title']; echo "</h2>"; echo "<p class\"resultspara\">". nl2br($row['description']). "</p>"; echo "<h4 style=\"margin:5px 0 0 0; padding:0;\">Contact details</h4>"; echo "<p class\"resultspara\">". nl2br($row['contact']). "</p>"; echo "<div style=\"float:left; width:124px; height:40px; margin:10px 15px 0 0;\">"; echo "<a href=\"/party-supplier-resources/email-supplier.php?title=". $row['title']. "&email=" . $row['email']. "&location=" . $row['location']. "&category=" . $row['category']. "\" title=\"contact this venue here\">"; echo "<img src=\"/images/email-supplier.jpg\" width=\"124\" align=\"right\" height=\"35\" alt=\"contact this supplier button\" border=\"0\" /></a>"; echo "</div>"; echo "</div>"; } ?> <?php include("../include/shareLinks.php"); ?> <div id="popupContact"> <a id="popupContactClose" title="close this window">close x</a> <h1>Supplier Directory Enquiry Form</h1> <?php include("../include/enquiryform.php"); ?> </div> <div id="backgroundPopup"></div> <?php mysql_close ($Link); ?> Any help appreciated! Aaron MOD EDIT: [code] . . . [/code] BBCode tags added. Hey guys, I can't wrap my head around how to make this work right... I have three tables: Code: [Select] CREATE TABLE `games` ( `g_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(150) DEFAULT NULL, PRIMARY KEY (`g_id`)); CREATE TABLE IF NOT EXISTS `game_player` ( `r_id` int(11) NOT NULL AUTO_INCREMENT, `p_id` int(11) DEFAULT NULL, `g_id` int(11) DEFAULT NULL, `bool` int(1) NOT NULL DEFAULT '0', PRIMARY KEY (`r_id`)); CREATE TABLE IF NOT EXISTS `players` ( `p_id` int(11) NOT NULL AUTO_INCREMENT, `playerid` varchar(150) NOT NULL, PRIMARY KEY (`p_id`), UNIQUE KEY `playerid` (`playerid`)); The players table is my list of users, and they're tied to the list of games via the game_player table. So here's my issue... I'm trying to show the full list of games, and then check mark each record where the player does play it. This is what I have so far - it shows all the games, but it's not checking the boxes. Code: [Select] $result = mysql_query("SELECT * FROM games") or die(mysql_error()); while($row = mysql_fetch_array($result)) { $newquery = "SELECT * FROM game_player, players WHERE game_player.p_id = players.p_id AND game_player.g_id = ".$row['g_id']. " AND players.playerid = {$userid}"; $query = mysql_query($newquery) or die(mysql_error()); if($query['bool'] == 1) { $set_checked = " CHECKED"; } else{ $set_checked = ""; } echo "<input type=\"checkbox\" name=\"box1\" value=\"".$query['g_id']."\"" . $set_checked . "/>".$row['name']."<br />\n"; } Code: [Select] <? $out = preg_replace('/^(.{701}[^.]*).*/i','$1.',$detrsltnewsrow[news_desc]); echo $out; ?> </td></tr><tr><td colspan="2" class="para" style="padding-left:10px;"> <?= substr(stripslashes(trim($detrsltnewsrow[news_desc])),701) ?> </td></tr> I have the above snippet.. The first php statement, basically grasp the first 701 characters with the closet next stop "." character and out puts it. then out puts the HTML tags I have a problem with the second statement. I want to output anything after what has been outputted by: Code: [Select] <? $out = preg_replace('/^(.{701}[^.]*).*/i','$1.',$detrsltnewsrow[news_desc]); echo $out; ?> So need the correct syntax for Code: [Select] <?= substr(stripslashes(trim($detrsltnewsrow[news_desc])),701) ?> Currently it breaks at exactly the 701 character, want it to continue from the sentence the first code ended in. My query gets the results and orders by one of the fields. Once I get the MySQL results I would like to find the first entry that has a letter as the first character of the same field that the list was ordered by, then split the results in to two parts and swap them. So that the results that have a letter at the start of the same sorted field are as the begining and the results that have the numbers as the start at the end of the array. But also so that the array works the same way as the original results string, so i can use say $results['mysqlfield'] Hi... I have query in highlighting null data using this code: Code: [Select] <?php include 'config.php'; $currentEmpID = $_SESSION['empID']; if(!isset($_POST['Regsubmit_'])){ $DATE1 = $_GET['Regfirstinput']; $DATE2 = $_GET['Regsecondinput']; $sql = "SELECT DISTINCT IF(ISNULL(a.LOG_IN), 'rdc', '') AS LOGIN_CLASS, IF(ISNULL(a.LOG_OUT), 'rdc', '') AS LOGOUT_CLASS, a.EMP_ID, CONCAT(LASTNAME, ', ' , FIRSTNAME) AS FULLNAME, a.LOG_IN, a.LOG_OUT FROM $ATTENDANCE.attendance_build AS a JOIN $ADODB_DB.employment em ON (a.EMP_ID = em.EMP_NO AND em.STATUS IN ('Reg Operatives', 'Reg Staff')) WHERE LOG_IN BETWEEN '$DATE1' AND '$DATE2' OR ISNULL(LOG_IN) OR ISNULL(LOG_OUT)"; $DTR = $conn3->GetAll($sql); $smarty->assign('attendance', $DTR); } $smarty->display('header_att.tpl'); $smarty->display('RegAttendance.tpl'); $smarty->display('footer.tpl'); ?> and here is the tpl code: Code: [Select] {section name=att loop=$attendance} <tr> <td colspan="2">{$attendance[att].EMP_ID}</td> <td colspan="2">{$attendance[att].FULLNAME}</td> <td colspan="2" class="{$attendance[att].LOGIN_CLASS}">{$attendance[att].LOG_IN|date_format:"%d-%m-%Y %I:%M %p"}</td> <td colspan="2" class="{$attendance[att].LOGOUT_CLASS}">{$attendance[att].LOG_OUT|date_format:"%d-%m-%Y %I:%M %p"}</td> </tr> {sectionelse} <tr><td colspan="1">No DATA</td></tr> {/section} this code highlight the null value of login or logout or both. this is the css: Code: [Select] .rdc {background-color:#ff0000;} Now, I need to revised my query statement, because i have separate code for adding attendance if the employee has no attendance or no login or no logout. I just want to happen is if the employee is already add his attendance in NRS table or should I said if the LOG_IN in attendance table is equal to TIME_IN in NRS table the data will have a color yellow. For Example: I have this data in attendance table: EMP_ID = 012012 LOG_IN = NULL LOG_OUT = 2011-12-12 13:35:00 I will his attendance in NRS table to have his attendance: EMP_NO = 012012 TIME_IN = 2011-12-12 05:35:00 TIME_OUT = 2011-12-12 13:35:00 In my above query the LOG_IN has a background color of RED. I want to happen is if I add his attendance in NRS the EMP_NO, LOG_IN, LOGOUT will have a color to notice that it is already have in NRS. Because theirs a scenario that the employee has no login or no logout or both. Feel free to ask me if my explanation is not clear to you. Thank you in advance Hi all, does anyone know how to perform this, or if it's even possible? I need every 6th row to be a GROUP BY of the following 5 rows, they all share a common group_id so that's what the GROUP BY is performed on. 1. GROUP BY group_id 2. item #1 3. item #2 4. item #3 5. item #4 6. item #5 7. GROUP BY group_id 8. item #6 ... and so on Hi, I have database, screenshot attached. I have to print all records of attendance sort by ID and have sum group by ID. How to know or figure out when the IDÂ changes so that i can show the total for that ID. Bare with me please and try to show me where is my mistake! Code: <?Php include('session.php'); include('dbcon.php'); ?> <html> <head> <link rel="stylesheet" type="text/css" href="bootstrap.css"> </head> <body> <div class="container"> <div class="row"> <div class="col m-auto"> <div class="card mt-5"> <table class="table table-bordered"> <tr> <input type="button" onClick="window.print()" value="Print The Report"/> <td>OracleID</td> <td>Name</td> <td>Designation</td> <td>Clocking In Time</td> <td>Clocking Out Time</td> <td>Duration</td> </tr> <?php $isdone = -1; $query = "select * from attendance_records where isdone= '".$isdone."' order by OracleID"; $result = mysqli_query($con, $query); $query2 = "SELECT sec_to_time(SUM(timestampdiff(SECOND, ClockingInDate, ClockingOutDate))) as total from attendance_records group by OracleID"; $result2 = mysqli_query($con, $query2); while ($row = mysqli_fetch_assoc($result)) { $userid = $row['OracleID']; $name = $row['Name']; $des = $row['Des']; $clockingindate = $row['ClockingInDate']; $clockingoutdate = $row['ClockingOutDate']; $duration = $row['Duration']; $t=time(); $curdate = date("d-m-Y",$t); $curTime = date("g:i:s A",$t); ?> <tr> <td><?php echo $userid ?></td> <td><?php echo $name ?></td> <td><?php echo $des ?></td> <td><?php echo $clockingindate ?></td> <td><?php echo $clockingoutdate ?></td> <td><?php echo $duration ?></td> </tr> <?php } while($row2 = mysqli_fetch_assoc($result2)) { $totals= $row2['total']; echo '<td><h5>Total Attendance Time:</h5></td>'; echo '<td>'; echo $totals; echo '</td>'; } echo '<tr>'; echo 'Report created by ', $_SESSION['user_id2'], ' on ', $curdate, ' at ', $curTime; echo '</tr>'; ?> </table> <a href="home.php" width="100%">Click here to go back to Main Menu</a> </div> </div> </div> </div> </body> </html> and screenshot of result is attached. I have the totals but not at the end of each OracleID, it is at the end of the report. Thanks.
I am trying to get a group by to work but for some reason it will only display one output. Not sure what the problem is. Code: [Select] mpid mpyear mpmonth mpday mptitle 4 2012 3 2 Text stuff here 3 2012 3 1 Day 1 stuff here 2 2012 2 28 Feb stuff here 1 2011 12 27 First post test here So what I am trying to do is sort out per year month ie: 2012 3 Text stuff here Day 1 stuff here 2 Feb stuff here 2011 12 First post test here That is what I eventually want it to look like, but first thing I need to do is get atleast the mptitle to group first. Code: [Select] $query = "SELECT * FROM monsterpost group BY 'mpmonth'"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo $row['mptitle']; echo "<br />"; } ?> I'm having issues with the following: Code: [Select] <?php session_start(); $_SESSION['username']=$_POST['username']; $_SESSION['password']=$_POST['password']; if($_SESSION['username']=="username" && $_SESSION['password']=="password"){ if($_GET['product']=="add"){ $content.=' <p><label>Product Name:</label> <input type="text" name="product_name" size="30" /> <label>Product Price:</label> <input type="text" name="product_price" size="5" /> </p> <p><label>Product Category:</label> <input type="text" name="product_category" size="30" /></p> <p><label>Product Link:</label> <input type="text" name="product_link" size="30" /></p> <p><label>Product Image:</label> <input type="text" name="product_image" size="30" /></p> <p><label>Product Tag:</label> <input type="text" name="product_tag" size="30" /></p> <p><label>Product Keywords:</label> <input type="text" name="keyword" size="30" /></p> <p><label>Product Features:</label><br /> <textarea name="product_features" rows="10" cols="60"></textarea> </p> <p><label>Product Pros:</label><br /> <textarea name="product_pros" rows="5" cols="30"></textarea> </p> <p><label>Product Cons:</label><br /> <textarea name="product_cons" rows="5" cols="30"></textarea> </p> <p><label>Product Description:</label><br /> <textarea name="product_description" rows="10" cols="60"></textarea> </p> <p><label>Product Notes:</label><br /> <textarea name="product_notes" rows="5" cols="30"></textarea> </p> '; $logout='<div><a href="./acp_admincp.php?log-out">Log-Out</a></div>'; } elseif($_GET['product']=="view"){ } else{ $content.=' <a href="./admincp.php?product=add">Add New Product</a> <br /> <a href="./admincp.php?product=view">View Products</a> '; } } elseif(isset($_GET['log-out'])){ session_start(); session_unset(); session_destroy(); header("Location: ./admincp.php"); } else{ $content=' <form action="./admincp.php" method="post"> <p><label>Username:</label> <input type="text" name="username" size="30" />'; $content.='</p> <p><label>Password:</label> <input type="password" name="password" /></p>'; $content.='<p><input type="submit" value="Submit" name="Submit" /></p> </form>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <base href="http://ghosthuntersportal.com/" /> <title>Ghost Hunter's Portal - Admin Control Panel</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="verify-v1" content="" /> <meta name="keywords" content="ghost, hunters, hunter, ghosts, spirit, spirits, paranormal, investigation, investigator, investigators, k2, emf, meter, kii" /> <meta name="description" content="Ghost Hunters Potal. Parnormal research equipment store." /> <meta name="author" content="Andrew McCarrick" /> <meta name="robots" content="index, follow" <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <img src="./logo.png" alt="Ghost Hunter's Portal Admin Control Panel" /> <br /> <div style="color: #AA44AA; font-size: 26px; margin-top: -30px; margin-left: 125px;">Admin Control Panel</div> <?php echo $logout; echo $content; ?> </body> </html> I can log-in, and get to the page with the two links on it. However, once I click one of the links it falls back to the log-in page, and it ends up being a never ending loop. It's doing this: Log-In --> Page with links ---> Log-In page again Should be doing this: Log-In --> Page with links --> Add Product page or View Products page I can never get into the the actual sub page. Just to be clear, the address bar actually shows product=add or product=view, but it still shows the log-in page. Hi all, I have a script that is essentially a log file of all preious versions of an article (versioning) You can see the script I am talking about in action at: http://danielrhyshardy.com/AWT/forumadmin.php What I would like to do is, instead of displaying the title of each instance (you will see there are two instances named "apple", as they are two previous versions of an article), I would like to display that title once, and then all of the instances of that title be displayed below. I hope that makes sense. Here is the code Code: [Select] <? $sql = "SELECT id,title,message,date_added FROM messages2 ORDER BY id "; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); while(list($id,$title,$message,$date_added)=mysql_fetch_row($result)){ echo '<div style="color:#bb0000;width:250px;text-align:center;float:left;margin-left:15px;margin-bottom:15px;padding-bottom:20px;"><b>'.$title.'<br>'.$date_added.'</b> <input id="'.$message.'" type="radio" name="admin[]" value="'.$id.'" onclick="javascript:document.form22.car.value=this.id" > </font></div>'."\n"; } ?> I would use something like Code: [Select] if ($title = "apple") { but this would obviously not work for new posts, unless I wanted to constantly update my code. I am sure there is a simple way to achieve this. Perhaps someone can tell me!? Thanks in advance Dan |