Jump to content

gmcalp

Members
  • Posts

    19
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

gmcalp's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, I figured it out (with a little help from my brother-in-law). Here is what we did: <?php foreach ($row as $key => $val) { if ($key == "added") break; // because that means we past the last line we wanted displayed this way. if ($val != "") { if (! strcmp($key,'url')) { echo "<div class=\"trow-jobs\"><div class=\"tcell_1\"><strong>" . replaceTableTitle($key) . ":</strong></div><div class=\"tcell_2\"><a href=\"http://$val\" target=\"_blank\" class=\"popup\">http://$val</a></div></div>\n"; } elseif (! strcmp($key,'contactemail')) { echo "<div class=\"trow-jobs\"><div class=\"tcell_1\"><strong>" . replaceTableTitle($key) . ":</strong></div><div class=\"tcell_2\"><a href=\"mailto:$val\">$val</a></div></div>\n"; } else { echo "<div class=\"trow-jobs\"><div class=\"tcell_1\"><strong>" . replaceTableTitle($key) . ":</strong></div><div class=\"tcell_2\">".$val."</div></div>\n"; } ?>
  2. I understand I could do it that way, but I would like it parsed automatically with the rest of the script, within the foreach loop so each of the two rows are displayed in order like it is now. <?php foreach ($row as $key => $val) { if ($key == "added") break; // because that means we past the last line we wanted displayed this way. if ($val != "") echo "<div class=\"trow-jobs\"><div class=\"tcell_1\"><strong>" . replaceTableTitle($key) . ":</strong></div><div class=\"tcell_2\">".$val."</div></div>\n"; } ?> Here is the output of that script: http://www.bmet.org/job-listings/ . As you can see, the two fields (URL and Contact Email) are not click-able links as I would like them to be.
  3. Good evening all, I hope your Friday is going well. A few months back premiso helped me out with a script in this thread. His help was greatly appreciated, and it got me up and running with a better script. Now I am back with one question, can anyone help me figure out a way to parse two of the database fields to automatically output as click-able links? I am hoping to be able to do this without REGEX, but if that's the only way to go, then I guess that'll have to do. The two fields would be: row['url] and row['contactemail']. Here is the code of the script: else { while ($row = mysql_fetch_assoc($result)) { $row['added'] = date("m/d/y", strtotime($row['added'])); // convert newline characters to HTML break tag ( <br /> ) $row['description'] = nl2br($row['description']); $row['qualifications'] = nl2br($row['qualifications']); $row['preferred'] = nl2br($row['preferred']); $row['howtoapply'] = nl2br($row['howtoapply']); echo "<h3>".$row['title']."</h3>\n"; //table format echo "<div class=\"table\">\n"; echo "<div class=\"trow-jobs\">\n"; echo "<div class=\"tcell_1\"><strong>Title:</strong></div><div class=\"tcell_2\">".$row['title']."</div>\n"; echo "</div>\n"; echo "<div class=\"trow-jobs\">\n"; echo "<div class=\"tcell_1\"><strong>Employer:</strong></div><div class=\"tcell_2\">".$row['employer']."</div>\n"; echo "</div>\n"; foreach ($row as $key => $val) { if ($key == "added") break; // because that means we past the last line we wanted displayed this way. if ($val != "") echo "<div class=\"trow-jobs\"><div class=\"tcell_1\"><strong>" . replaceTableTitle($key) . ":</strong></div><div class=\"tcell_2\">".$val."</div></div>\n"; } echo "</div>\n"; echo "<div>(Added on: " .$row['added']. ")</div>\n"; echo "<br/><br/>\n"; } } function replaceTableTitle($title) { switch (strtolower($title)) { case 'fte': return "FTE"; case 'howtoapply': return "How To Apply"; case 'url': return "URL"; case 'contactname': return "Contact Name"; case 'contactphone': return "Contact Phone"; case 'contactemail': return "Contact E-mail"; break; } // if we get here just upercase the first word return ucfirst($title); } mysql_close(); As always, any help is much appreciated.
  4. gmcalp

    /cpanel

    that should be http://forums.cpanel.net
  5. an example: mail("yourname@yourdomain.com","Subject Line Text Here",$message,"From: ".$email.",$headers,");
  6. Here's the delete from table that I have in one of my scripts: while ($row = mysql_fetch_array($result)) { $jobid = $row['id']; $jobtitle = $row['title']; $added = $row['added']; $empl = $row['employer']; echo '<p>' . $jobtitle . ", " . $empl . ": " . $added . ' <a href="' . $_SERVER['PHP_SELF'] . '?deletejob=' . $jobid . '">' . 'Delete this job</a></p>';} } // If a job has been deleted, // remove it from the database. if (isset($_GET['deletejob'])) { $jobid = $_GET['deletejob']; $sql = "DELETE FROM jobs WHERE id=$jobid"; if (@mysql_query($sql)) { echo "<b>Job Deleted!<br>You'll be redirected to Home Page after (4) Seconds"; #header("location: deleted.php"); echo "<meta http-equiv=Refresh content=4;url=".$_SERVER['PHP_SELF'].">"; # $_SERVER['PHP_SELF']; Edit it as you need.
  7. nl2br means: new line (carriage return) to <br/> here's an example of how I have used it: // convert newline characters to HTML break tag ( <br /> ) $desc = nl2br($desc);
  8. Here's a contact form that I use on one of my websites, maybe you could modify yours to work with this code: The HTML (just take out the CSS, unless you would like me to send that to you as well): <form action='forms/contact/process.php' method='post' enctype='multipart/form-data' name="Contact" id="Contact" class="cmxform"> <p>Please complete the form below. Mandatory fields marked <em>*</em></p> <fieldset> <legend>Contact Information</legend> <ol> <li><label for="First">First:<em>*</em></label> <input type="text" name='First' id='First' tabindex='1' /></li> <li><label for="Last">Last:<em>*</em></label> <input type="text" name='Last' id='Last' tabindex='2' /></li> <li><label for="Email">E-Mail:<em>*</em></label> <input type="text" name='Email' id='Email' tabindex='3' /></li> <li><label for="Phone">Phone:</label> <input type="text" name='Phone' id='Phone' tabindex='4' /></li> <li><label for="Address">Address:</label> <input type="text" name='Address' id='Address' tabindex='5' /></li> <li><label for="City">City:</label> <input type="text" name='City' id='City' tabindex='6' /></li> <li><label for="State">State:</label> <select size='1' name='State' id='State' tabindex='7'> <option value="">Select Below</option><option value="AL">Alabama</option> <option value="AK">Alaska</option><option value="AZ">Arizona</option> <option value="AR">Arkansas</option><option value="CA">California</option> <option value="CO">Colorado</option><option value="CT">Connecticut</option> <option value="DE">Delaware</option><option value="FL">Florida</option> <option value="GA">Georgia</option><option value="HI">Hawaii</option> <option value="ID">Idaho</option><option value="IL">Illinois</option> <option value="IN">Indiana</option><option value="IA">Iowa</option> <option value="KS">Kansas</option><option value="KY">Kentucky</option> <option value="LA">Louisiana</option><option value="ME">Maine</option> <option value="MD">Maryland</option><option value="MA">Massachusetts</option> <option value="MI">Michigan</option><option value="MN">Minnesota</option> <option value="MS">Mississippi</option><option value="MO">Missouri</option> <option value="MT">Montana</option><option value="NE">Nebraska</option> <option value="NV">Nevada</option><option value="NH">New Hampshire</option> <option value="NJ">New Jersey</option><option value="NM"> New Mexico </option> <option value="NY">New York</option><option value="NC">North Carolina</option> <option value="ND">North Dakota</option><option value="OH">Ohio</option> <option value="OK">Oklahoma</option><option value="OR">Oregon</option> <option value="PA">Pennsylvania</option><option value="PR">Puerto Rico</option> <option value="RI">Rhode Island</option><option value="SC">South Carolina</option> <option value="SD"> South Dakota </option><option value="TN">Tennessee</option> <option value="TX">Texas</option> <option value="UT">Utah</option> <option value="VT">Vermont</option><option value="VA">Virginia</option> <option value="WA">Washington</option><option value="DC">Washington, D.C.</option> <option value="WV">West Virginia</option><option value="WI">Wisconsin</option> <option value="WY">Wyoming </option></select></li> <li><label for="Zip">Zip: <em>*</em></label> <input type="text" name='Zip' id='Zip' tabindex="8" /></li> <li> <fieldset> <legend>Please leave your comments below:<em>*</em></legend> <label for="Comments">Comments:</label> <textarea name='comments' id='Comments' rows="7" cols="45" tabindex='9'></textarea> </fieldset> </li> </ol> <p class="small">By submitting this form with your telephone number you are consenting for xxxxxxx and all authorized representatives to contact you even if your name is on a Federal or State "Do not call List".</p> <p class="small">Thank you for submitting your information. I will be in contact with you by phone or email.</p> <p><input name="submit" type="submit" value='Submit Form' /> <input name="reset" type="reset" value='Reset Form' /></p> </fieldset> </form> Here's the processor.php: <?php include("db_config.php"); function pt_register() { $num_args = func_num_args(); $vars = array(); if ($num_args >= 2) { $method = strtoupper(func_get_arg(0)); if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV')) { die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV'); } $varname = "HTTP_{$method}_VARS"; global ${$varname}; for ($i = 1; $i < $num_args; $i++) { $parameter = func_get_arg($i); if (isset(${$varname}[$parameter])) { global $$parameter; $$parameter = ${$varname}[$parameter]; } } } else { die('You must specify at least two arguments'); } } $errors=0; $error="The following errors occured while processing your form input.<ul>"; pt_register('POST','First'); pt_register('POST','Last'); pt_register('POST','Email'); pt_register('POST','Phone'); pt_register('POST','Address'); pt_register('POST','City'); pt_register('POST','State'); pt_register('POST','Zip'); pt_register('POST','comments'); $comments=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $comments);if($First=="" || $Last=="" || $Email=="" || $comments=="" ){ $errors=1; $error.="<li>You did not enter one or more of the required fields. Please go back and try again."; } if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$Email)){ $error.="<li>Invalid email address entered"; $errors=1; } $email = 'yourname@yourdomain.com'; $ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; if($errors==1) echo $error; else{ $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/")); $message="Name: ".$First." ".$Last." Email: ".$Email." Phone: ".$Phone." Address: ".$Address." City: ".$City." State: ".$State." Zip: ".$Zip." Comments: ".$comments." Submitted from IP: ".$ip." "; $First = mysql_escape_string($_POST['First']); $Last = mysql_escape_string($_POST['Last']); $Email = mysql_escape_string($_POST['Email']); $Phone = mysql_escape_string($_POST['Phone']); $Address = mysql_escape_string($_POST['Address']); $City = mysql_escape_string($_POST['City']); $State = mysql_escape_string($_POST['State']); $Zip = mysql_escape_string($_POST['Zip']); $comments = mysql_escape_string($_POST['comments']); $message = htmlspecialchars($message); $headers = "MIME-Version: 1.0"; $headers .= "Content-type: text/plain"; mail("yourname@yourdomain.com","New contact information submitted at your website",$message,"From: ".$email.",$headers,"); $link = mysql_connect("$DHost","$DUser","$DPass"); mysql_select_db("$DBase",$link); $query="insert into contacts (First,Last,Email,Phone,Address,City,State,Zip) values ('".$First."','".$Last."','".$Email."','".$Phone."','".$Address."','".$City."','".$State."','".$Zip."')"; mysql_query($query); header("Refresh: 0;url=http://www.yourdomain.com/sent.htm"); ?> <?php } ?>
  9. It seems kinda risky to be using a shared host for government websites, don't you think? I have been with Dreamhost for 4 years now and couldn't be happier (I know a lot of people haven't been). It's only 10.95/mo and they have lots of great features... Now, to get back on topic, it could be your contact forms, but it's kinda hart to tell if you don't post the code for us to see.
  10. I know that my host has had that problem in the past, so, yeah... it could be the reason.
  11. I went ahead and used the first one and it works fabulously! Thank you sir for all your help!
  12. Sure it does: http://www.google.com/search?hl=en&q=CRON+Jobs&btnG=Google+Search&aq=f&oq=
  13. So, for subsequent changes, would it be like this? function replaceTableTitle($title) { switch (strtolower($title)) { case 'howtoapply': return "How To Apply"; case 'url': return "URL"; //ETC break; // etc } OR like this: function replaceTableTitle($title) { switch (strtolower($title)) { case 'howtoapply': return "How To Apply"; break; case 'url': return "URL"; break; // etc
  14. from your first example, this should work: <?php echo "Username: ".$whateverdatayouwant."\n"; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.