PHP - Need To Write Html To Csv But Also Insert Variable In Part Of The Html Code
I have a form that users input user name, password, and email... all writes to csv fine. My problem is I need to concatenate a a string with a variable and some html code will preserving the html when written to the csv..
I need the csv to be this username,password,email,user,category,text with http://sub.domain..com/splash/,something,something here's what i have Code: [Select] <?php if($_POST['formSubmit'] == "Submit") $varUserName = $_POST['username']; $varPW = $_POST['PW']; $varEmail = $_POST['email']; { $fs = fopen("testcsv.csv","a"); fputcsv($fs, array($varUserName,$varPW,$varEmail,"user","title",",category","some text '<a href="http://$varUserName.url.com/splash/>site.com</a>',)); fclose($fs); exit; } ?> and of course I'm getting Parse error: syntax error, unexpected T_STRING, expecting ')' on line 9 Similar TutorialsDear Friends, I am alot before doing the mixed content of php and HTML in single variable in PHP.. I could not get the data even though there is not SYNTAX error.. please look my code and advise
$htmlcontent .=" <tr> <td colspan=\"8\">".$details."></td> </tr>"; for($k=0;$k<count($reg_years[$details]);$k++) { $year = (int)($reg_years[$details][$k]); $singlecount[$year] = array_filter($result[$details],function($details1) use ($year){ return ($details1['reg_year'] == $year && $details1['bench_type'] == 1); }); $divisioncount[$year] = array_filter($result[$details],function($details2) use ($year){ return ($details2['reg_year'] == $year && $details2['bench_type'] == 2); }); $fullcount[$year] = array_filter($result[$details],function($details3) use ($year){ return ($details3['reg_year'] == $year && $details3['bench_type'] >= 3); }); $rpcount[$year] = array_filter($result[$details],function($rp) use ($year){ return ($rp['reg_year'] == $year && $rp['bench_type'] == 'RP'); }); $mjccount[$year] = array_filter($result[$details],function($mjc) use ($year){ return ($mjc['reg_year'] == $year && $mjc['bench_type'] == 'MJC'); }); $cocount[$year] = array_filter($result[$details],function($co) use ($year){ return ($co['reg_year'] == $year && $co['bench_type'] == 'X'); }); $total = 0; $total = (int)(count($singlecount[$year])+count($divisioncount[$year])+count($fullcount[$year])+count($rpcount[$year])+count($mjccount[$year])+count($cocount[$year])); $htmlcontent .=" <tr> <td>".$year."</td> <td align=\"center\"> if(count($singlecount[$year])>0) { echo (count($singlecount[$year])); } else { echo "-"; } </td> <td align=\"center\"> if(count($divisioncount[$year])>0) { ".count($divisioncount[$year])." } else { "-" } </td> <td align=\"center\"> if (count($fullcount[$year]) > 0) { echo (count($fullcount[$year])); } else { echo "-"; } </td > < td align =\"center\"> if(count($rpcount[$year])>0) { echo (count($rpcount[$year])); } else { echo " - "; } </td> <td align=\"center\"> if(count($mjccount[$year])>0) { echo (count($mjccount[$year])); } else { echo " - "; } </td> <td align=\"center\"> if(count($cocount[$year])>0) { echo (count($cocount[$year])); } else { echo " - "; } </td> <td align=\"center\"> echo $total; </td> </tr>"; } } $htmlcontent .= "</tbody></table>"; $mpdf = new \Mpdf\Mpdf(); $mpdf->WriteHTML($htmlcontent); $mpdf->Output(); Waiting for FAST reply
Thanks Anes I have a submit.php file that includes the following jQuery code: <script> [...] request.done(function( json ) { jQuery('input[name=thumbnail-url]').val(json.thumbnail_url); jQuery('input[name=job_title]').val(json.title); jQuery('textarea[name=htmlcode]').val(json.html); [...] </script> I need to remove jQuery('textarea[name=htmlcode]').val(json.html); and pass the "json.html" value into a PHP variable in another php file (functions.php). The code in the functions.php file is already there. The thing i need to do (and i am seriously struggling with it) is placing the value of json.html into a $phpvariable that i can then call from the function.php file. Do you need any more info for this issue? Thanks. 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> I would like to be able to use this
<img src="user/<?=$log_username. '/' . $main_image;?>" width="130" height="150" id="pic5"/>to work within php and i am having a had time doing so . Any ideas? $log_username refers to the users specific username folder within the main users folder html source code looks like this ,but i need to reference this within a PHP code block not html <img src="user/lexi/pic.png" width="130" height="150" id="pic5">any ideas? thanks guys Hi
I want to echo out something when I post the value of a radio button and this value matches the same name of a html file. How can I formulate my code to achieve that?
What I have so far:
<?php if (isset($_POST['submitradio'])) { $selected_dir = $_POST['radio1']; echo substr($selected_dir, 0, -4); echo '<img src="'.$selected_dir.'" />'; } ?>So far I get for example the name of the image(order.gif) and the image order. gif. What I now want is to formulate my code so that I can say if I have an image called "order.gif" and a file called "order.html" that I can then echo out some thing. I don't want to actually name the image or the html file. I just want to say if I have two different file types that start with the same name then I can echo out what ever. How can I do that? I'm trying to submit html/php code through an html form and then insert it into a mysql database. I've got the following code so far (without the insert into database query), however when I submit the form I get pushed through to my 403 page. If i comment out the textarea that contains the code I am trying to submit, then it goes through fine. Any ideas? Code: [Select] <? if (isset($_POST['optone'])) {$optone=$_POST['optone']; $opttwo=$_POST['opttwo'];} if (isset($_POST['type'])) {if ($_POST['type']=='Theory') {$optone=1;} if ($_POST['type']=='Demo') {$optone=2;} $opttwo=$_POST['module'];} ?> <h3>Module administration</h3> <script> function setOptions(chosen) { var selbox = document.myform.opttwo; selbox.options.length = 0; if (chosen == " ") { selbox.options[selbox.options.length] = new Option('Please select an option first',' '); document.myform.go.disabled=true; } if (chosen == "1") { selbox.options[selbox.options.length] = new Option('Module 1','1'); selbox.options[selbox.options.length] = new Option('Module 2','2'); selbox.options[selbox.options.length] = new Option('Module 3','3'); selbox.options[selbox.options.length] = new Option('Module 4','4'); selbox.options[selbox.options.length] = new Option('Module 5','5'); selbox.options[selbox.options.length] = new Option('Module 6','6'); selbox.options[selbox.options.length] = new Option('Module 7','7'); selbox.options[selbox.options.length] = new Option('Module 8','8'); selbox.options[selbox.options.length] = new Option('Module 9','9'); selbox.options[selbox.options.length] = new Option('Module 10','10'); document.myform.go.disabled=false; } if (chosen == "2") { selbox.options[selbox.options.length] = new Option('Module 1','1'); selbox.options[selbox.options.length] = new Option('Module 2','2'); selbox.options[selbox.options.length] = new Option('Module 3','3'); selbox.options[selbox.options.length] = new Option('Module 4','4'); selbox.options[selbox.options.length] = new Option('Module 5','5'); selbox.options[selbox.options.length] = new Option('Module 6','6'); selbox.options[selbox.options.length] = new Option('Module 7','7'); selbox.options[selbox.options.length] = new Option('Module 8','8'); selbox.options[selbox.options.length] = new Option('Module 9','9'); selbox.options[selbox.options.length] = new Option('Module 10','10'); document.myform.go.disabled=false; } } </script> <br /> <center> <form name="myform" method='post'> Edit: <select id="optone" name="optone" size="1" onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);" > <option value=" " >--Choose--</option> <option value="1" >Theory</option> <option value="2" >Demo</option> </select> <select name="opttwo" size="1"> <option value=" " selected="selected">Please select an option first</option> </select> <input type='submit' name='go' id='go' value='Go' disabled='disabled'/> </form> </center> <br /><br /> <? if (isset($opttwo)) { if ($optone==1) {$query = "SELECT info,userscompleted,last_user,enabled FROM theorydata WHERE TheoryID=".$opttwo; $typestr='Theory'; $texthelp='Code must be entered in HTML';} if ($optone==2) {$query = "SELECT info,userscompleted,last_user,enabled FROM demodata WHERE DemoID=".$opttwo; $typestr='Demo'; $texthelp='Code must be entered in PHP';} $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $query2="SELECT full_name FROM users WHERE id=".$row['last_user']; $result2 = mysql_query($query2) or die(mysql_error()); $row2 = mysql_fetch_array($result2); ?> <form method='post' > <table> <tr> <td align='center'> Type: </td> <td> <input type='text' name='type' readonly='readonly' value="<? echo $typestr; ?>" /> </td> </tr> <tr> <td align='center'> Module: </td> <td> <input type='text' name='module' readonly='readonly' value="<? echo $opttwo; ?>" /> </td> </tr> <tr> <td align='center' > Enabled? </td> <td> <select name='enabled'> <option value='yes' <? if ($row['enabled'] == '1') {echo "selected='selected'";}?> >Yes</option> <option value='no' <? if ($row['enabled'] == '0') {echo "selected='selected'";}?> >No</option> </select> </td> </tr> <tr> <td align='center'> Code: </td> <td> <center><font color='red'><? echo $texthelp; ?></font></center> <textarea name='info' rows=35 cols=80><? echo htmlentities($row['info']); ?></textarea> </td> </tr> <tr> <td align='center' > Users completed: </td> <td> <input type='text' name='userscompleted' value="<? echo $row['userscompleted']; ?>" size=4/> </td> </tr> <tr> <td align='center' > Last user: </td> <td> <input type='text' name='last_user' readonly='readonly' value="<? echo $row2['full_name']; ?>" /> </td> </tr> <tr> <td></td> <td align='center'> <input type='submit' value='Edit'/> </td> </tr> </table> </form> <? }//close isset(opttwo) ?> I have a table that has a cell that I've made editable:
echo "<td contenteditable='true'>" . $row['Comments'] . "</td>";Which is cool I guess, but it doesn't go anywhere from there. I'd like to make it so that upon changing, it links back to an SQL UPDATE query that I define. Is this possible through some sort of onChange function? I'm reading over this book and I came across something that looked very odd:
public function DisplayHeader() { ?> <table width="100%" cellpadding="12" cellspacing="0" border="0"> <tr bgcolor ="black"> <td align ="left"><img src = "logo.gif" /></td> <td> <h1>TLA Consulting Pty Ltd</h1> </td> <td align ="right"><img src = "logo.gif" /></td> </tr> </table> <?php }In the function it closes a php tag, uses raw html that is rendered as is on the page, and then returns back to opening the php tag. I understand why it is being done. It is easier to write raw html here than to echo it in a php block, but it just looks odd. Anyone actually use this technique? I am trying to build a news feed which shows the first 100 characters of news copy. I have it working to paste in the full text but am not sure how to insert only the first 100 characters. Code: [Select] <?php while($news_row=mysql_fetch_array($news)) { echo " <div class=\"news_box\"> <h3><a href=\"html/news.html\" rel=\"shadowbox; width=800; height=400;\">".$news_row['news_title']."</a> </h3> ".$news_row['news_copy']." </div>"; } ?> Hi,
I have a text area field on one of my forms in order for people to post articles, however, it doesn't work when I try and post HTML through it. It works if I post normal text. Also, PHP won't give me an error, it just doesn't insert it?
<?php if ($_POST['add']) { $title = addslashes($_POST['title']); $image = htmlspecialchars($_POST['image']); $source = mysql_real_escape_string($_POST['source']); $active = $_POST['active']; $feature = $_POST['feature']; $cat_id = $_POST['cat_id']; $content = htmlspecialchars($_POST['content']); $months = array( "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ); $date = date('d', time()) . ' ' . $months[date('n', time())] . ' ' . date('Y', time()); if ($title == NULL || $image == NULL || $content == NULL) { echo '<br /><br /><center>Please, fill all inputs</center><br /><br />'; } else { $add = "INSERT INTO `news` cat_id='$cat_id', title='$title', image='$image', content='$content', date='$date', author='".$user['admin']."', authorid='".$user['id']."', source='$source', active='$active', twitter='".$user['twitter']."', featured='$feature'" or die(mysql_error()); $sql = mysql_query($add); $addgrowl = "INSERT INTO `growl` (toid, message) VALUES ('$id', 'Your article is now online!')"; $sql = mysql_query($addgrowl); echo '<script type="text/javascript"> window.location = "articles.php" </script> '; } } ?>Help :-( Hello, can any1 show me how to insert the following in db Code: [Select] <?php include('dbconnect.php'); include('simple_html_dom.php'); $html = file_get_dom('test3.php'); foreach($html->find('h2') as $heading) { //echo $heading; foreach ($heading->find('a') as $link) { $item_title = md5($link); echo $link."<br/>"; $sql = "INSERT INTO articles(article_id, article_link) VALUES($item_title, $link)"; $result = mysql_query($sql); } } ?> what i want to do is insert every link in the db, but this is not working. The output is ok but the insert doesnt work. Any help please?? Hi, I have got a working HTMLarea input form. And using a form, it will input the data from the HTMLarea into a mysql database table. But, the formatting breaks the MySQL query. How can I parse the information so this wouldnt happen? The exact error is: Code: [Select] 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' content in: [INSERT into zen_blog (id, content, active) VALUES ('', content , )!] If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields. 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!"; ?> I’m trying to insert from a multiple option form into MySQL. I’ve tried numerous methods and have had issues such as blank entries being inserted for each specified column, to the last value selected from the form being inserted multiple times, but I never get the desired outcome. Any guidance on how to insert from this type of HTML form? I know that there are issues regarding SQL injection - I'll worry about that later. I'd like to understand how to insert data from this kind of HTML form into MySQL, as i can't seem to find any guidance. There's plenty on how to insert from a standard HTML form i.e. where either every value is selected or left blank, but each entry corresponds to a column in MySQL which either receives a value or NULL. I'm really struggling with when a user can select more than one option from a list. Quote
<form action ='insert.php' method='POST'>
Here’s one option I’ve tried for PHP Quote
<?php
{ { } $conn->close(); ?>
Hi Guys, I have a textarea on a html page with XXX amount of lines. How can I in php insert a separate mysqlrow for EACH line on the html textarea? Thanks G Hi all!!! I could really use some help. I'm burning my brain out trying to figure out the easiest way to go about this. Here is what I am trying to do (in a nutshell) so I could really use full coding examples. I need to create a text area with simple formatting tools such as Bold, Italics, Underline, Bullets, and Numbering. After formatting the text with only those available formatting tools, everything in the text area needs to be converted into html tags. After the conversion, the HTML data that is create is submitted into a single field into a SQL database. Any help will be greatly appreciated!!! I'm creating a report page and can't figure out how to retrieve multiple rows from a table and display them in html. There are 5 data elements in each row and I'm thinking that using a form in the html might be the best way as I'm totally ignorant about tables in html. I'm a newbie to php and can't figure out how to accomplish this. Here's the code that I have so far: <?php $filename = NULL; session_start(); // start of script every time. // setup a path for all of your canned php scripts $php_scripts = '../php/'; // a folder above the web accessible tree // load the pdo connection module require $php_scripts . 'PDO_Connection_Select.php'; //******************************* // Begin the script here // Connect to the database if (!$con = PDOConnect("foxclone")): { echo "Failed to connect to database" ; exit; } else: { $sql = 'SELECT COUNT(IP_ADDRESS) FROM download WHERE FILENAME IS NOT NULL'; $sql1 = 'Update download t2, ip_lookup t1 set t2.country = t1.country, t2.area = t1.area, t2.city = t1.city where ((t2.IP_ADDRESS) = (t1.start_ip) OR (t2.IP_ADDRESS) > (t1.start_ip)) AND ((t2.IP_ADDRESS) = (t1.end_ip) OR (t2.IP_ADDRESS) < (t1.end_ip)) AND (t2.FILENAME is not null and t2.country is null)'; $sql2 = 'SELECT (IP_ADDRESS, FILENAME, country, area, city) from download where FILENAME is not null'; // Update the table $stmt = $con->prepare($sql1); $stmt->execute(); // Get count of rows to be displayed in table $stmt = $con->prepare($sql); $stmt->execute() ; $cnt = $stmt->fetch(PDO::FETCH_NUM); // retrieve one row at a time $i = 1; while($i <= $cnt){ $stmt = $con->prepare($sql2); $row->execute(array('')); // Do I need an array here? // from here on, I'm lost $i++; I'd appreciate any guidance you can provide or understandable tutorials you can point me to. Larry Hi, Hope somebody can help me because I am relatively new to PHP and I am currently unsure how to implement the following: Let's assume I have a table like this id_number, name, data1, data2. When displayed on HTML page: Column id_number should be hidden. Column name is a link. When you click on this column then value stored in id_number should be used in a query to database. Result should be displayed below the link on the same page. When clicked again data should hide. I have some idea how to toggle visibility with a simple javascript function. How do i populate the table with hidden data and then extract it later on? Any help or suggestions are appreciated. Thanks. Quote <?php $var = "http://www.google.com" ; ?> <iframe id="I1" name="I1" src= http://www.google.com style="width: 1186px; height: 1346px; float: middle"> Your browser does not support inline frames or is currently configured not to display inline frames. </iframe></div> Instead of the bold parts, I want the frame to show what $var links to, but as I have closed ?PHP, it will not return the link. Any help on how to make it go to $var? |