Jump to content

jimmyelewis

Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jimmyelewis's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I need to pull the first 150 or so characters from a MySQL database. I only want link tags to show up in the substring of the database. What I coded so far basically looks from the 150th character to some offset from that in the string without tags and searches the string with links tags looking for that. This works unless in between the 150 character to the offset a link occurs. Does anyone know how to fix this or a better way to go about doing this? Example that would be false: stringWithoutTags(150th +offset):"this is just an example" stringWithLinkTags:"...this is just <a href="">just an example<a>" $infoLength = 150; // amount of chars to show in news list $stringWithOutTags = strip_tags($a[5]); $stringWithLinkTags = strip_tags($a[5],'<a>'); if(strlen($stringWithOutTags)>$infoLength){ $infoLength = strpos($stringWithOutTags,' ',$infoLength-1); //go to the next space offset of $infoLength so a word isn't cut off for($i=20;$i>0;$i--){ //how much to string to compare to the string with link tags if(strlen($stringWithOutTags)>($infoLength+$i)){ $offset = $i; //sets the amount of the string to compare to $i = 0; } } $linksLength = strpos($stringWithLinkTags,substr($stringWithOutTags,$infoLength,$offset)); //finds the first post of the space plus the comparing part of the string with links tags to the string with out tags if($linksLength===false) $linksLength = strlen($stringWithLinkTags); //Problem here if the substring happens to over lap a link tag. } else{ $linksLength = strlen($stringWithLinkTags); } $stringWithLinkTags = substr($stringWithLinkTags,0,$linksLength);
  2. I'm trying to use regular expression to remove some of the non-standard tags from into that is copyed from Microsoft Word to a text area.  So far I have: [code] $search = array( '/<city[^>]*>(.*?)<\/city[^>]*>/is', '/<place[^>]*>(.*?)<\/place[^>]*>/is', '/mso-[^"]*|mso-[^;]*mso-[^"]*/is', '/<formulas>(.*?)<\/formulas>/is', '/o:[^=]*="[^"]*"/is' ); $replace = array( '$1', '$1', '', '', '' ); echo preg_replace($search,$replace,$row['contents']); [/code] One of the the values for $row['contents'] is: [code] <p class="MsoNormal"><span class="EmailStyle41"><font face="Arial" color="#003300" size="2"><span style="FONT-SIZE: 10pt">The Semiconductor Power and Electronics Center (SPEC) welcomes Dr. Engelbert Hetzmannseder as he&nbsp;presents an overview of&nbsp;the Eaton Corporation focused on the Eaton Electric Group and an overview of the mission and capabilities of the&nbsp; <place w:st="on"> <placename w:st="on">Eaton</placename> <placename w:st="on">Innovation</placename> <placetype w:st="on">Center in Milwaukee, Wisconsin</placetype> </place> . </span></font></span></p> <span class="EmailStyle41"><font face="Arial" color="#003300" size="2"><span style="FONT-SIZE: 10pt"> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><strong style="mso-bidi-font-weight: normal"><span style="FONT-SIZE: 14pt; mso-bidi-font-size: 10.0pt"><font color="#000000"><font face="Times New Roman">The Speaker</font></font></span></strong></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><strong style="mso-bidi-font-weight: normal"><span style="FONT-SIZE: 14pt; mso-bidi-font-size: 10.0pt"><font color="#000000"><font face="Times New Roman">Engelbert Hetzmannseder</font></font></span></strong></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><strong style="mso-bidi-font-weight: normal"><span style="FONT-SIZE: 14pt; mso-bidi-font-size: 10.0pt"></span></strong></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><strong style="mso-bidi-font-weight: normal"><span style="FONT-SIZE: 14pt; mso-bidi-font-size: 10.0pt"></span></strong><font size="3"><font color="#000000"><font face="Times New Roman"><strong style="mso-bidi-font-weight: normal">Engelbert Hetzmannseder</strong> was born in Klaffer, <place w:st="on">Upper Austria</place> .<span style="mso-spacerun: yes">&nbsp; </span>He received his Dipl.-Ing. (B.S., M.S., 1990) and Dr. techn. (Ph.D., 1994) degree in Electrical Engineering from the Technical University of Vienna, Austria.<span style="mso-spacerun: yes">&nbsp; </span>Since February 1995 he has been with Eaton Corporation / <placename w:st="on">Innovation</placename> <placetype w:st="on">Center</placetype> in <place w:st="on"><city w:st="on">Milwaukee</city>, <state w:st="on">WI</state>, </place> , involved with fundamental and applied research on contacts, switching arc phenomena, and arc fault detection for industrial, aerospace, and automotive products.<span style="mso-spacerun: yes">&nbsp; </span>He holds 8 patents and published 20 papers at international conferences.<span style="mso-spacerun: yes">&nbsp; </span></font></font></font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><font size="3"><font color="#000000"><font face="Times New Roman"><span style="mso-spacerun: yes"></span><br />Since 2000 he has been Technology Manager of the Electrical Architecture &amp; Systems department at the <place w:st="on"> <placename w:st="on">Eaton</placename> <placename w:st="on">Innovation</placename> <placetype w:st="on">Center</placetype> </place> .<span style="mso-spacerun: yes">&nbsp; </span>Capabilities of the EAS group include:</font></font></font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.35in; TEXT-INDENT: -0.2in; LINE-HEIGHT: normal; mso-list: l0 level1 lfo1"><span style="COLOR: black; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><span style="mso-list: Ignore"><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="Times New Roman" color="#000000" size="3">Electric Power Management</font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.35in; TEXT-INDENT: -0.2in; LINE-HEIGHT: normal; mso-list: l0 level1 lfo1"><span style="COLOR: black; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><span style="mso-list: Ignore"><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="Times New Roman" color="#000000" size="3">Power electronic, Power quality, and power conversion architectures</font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.35in; TEXT-INDENT: -0.2in; LINE-HEIGHT: normal; mso-list: l0 level1 lfo1"><span style="COLOR: black; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><span style="mso-list: Ignore"><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="Times New Roman" color="#000000" size="3">Diagnostics &amp; prognostics of electrical components and systems</font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.35in; TEXT-INDENT: -0.2in; LINE-HEIGHT: normal; mso-list: l0 level1 lfo1"><span style="COLOR: black; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><span style="mso-list: Ignore"><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="Times New Roman" color="#000000" size="3">Electro-mechanical switching technologies, Arc &amp; plasma science, Contact physics</font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.35in; TEXT-INDENT: -0.2in; LINE-HEIGHT: normal; mso-list: l0 level1 lfo1"><span style="COLOR: black; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><span style="mso-list: Ignore"><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="Times New Roman" color="#000000" size="3">Power systems modeling: magnetic, electric, thermal, electro-mechanical</font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.35in; TEXT-INDENT: -0.2in; LINE-HEIGHT: normal; mso-list: l0 level1 lfo1"><span style="COLOR: black; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"><span style="mso-list: Ignore"><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="Times New Roman" color="#000000" size="3">Mechanism synthesis and modeling</font></p> <p class="MsoHeader" style="MARGIN: 24pt 0in 0pt; LINE-HEIGHT: normal; tab-stops: .5in"> <p><font face="Times New Roman" color="#000000" size="3">&nbsp; <stroke joinstyle="miter"></stroke> <formulas> <f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f> </formulas> <path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path> <lock v:ext="edit" aspectratio="t"></lock><shape id="_x0000_s1026" style="MARGIN-TOP: 48.4pt; Z-INDEX: 1; MARGIN-LEFT: 401.55pt; WIDTH: 157.1pt; POSITION: absolute; HEIGHT: 213.55pt" type="#_x0000_t75"><imagedata o:title="ENGELBERT 2 005 head" src="file:///C:\DOCUME~1\jakirk\Local%20Settings\Temp\msohtml1\01\clip_image001.jpg"></imagedata></shape> <stroke joinstyle="miter"></stroke> <formulas> <f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f> </formulas> <path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path> <lock v:ext="edit" aspectratio="t"></lock><shape id="_x0000_s1026" style="MARGIN-TOP: 48.4pt; Z-INDEX: 1; MARGIN-LEFT: 401.55pt; WIDTH: 157.1pt; POSITION: absolute; HEIGHT: 213.55pt" type="#_x0000_t75"><imagedata o:title="ENGELBERT 2 005 head" src="file:///C:\DOCUME~1\jakirk\Local%20Settings\Temp\msohtml1\01\clip_image001.jpg"></imagedata></shape></font></p> </p> <p class="MsoNormal"> <p>&nbsp;</p> </p> </span></font></span> [/code] Whats returned from the preg_replace: [code] <p class="MsoNormal"><span class="EmailStyle41"><font face="Arial" color="#003300" size="2"><span style="FONT-SIZE: 10pt">The Semiconductor Power and Electronics Center (SPEC) welcomes Dr. Engelbert Hetzmannseder as he&nbsp;presents an overview of&nbsp;the Eaton Corporation focused on the Eaton Electric Group and an overview of the mission and capabilities of the&nbsp; <placename w:st="on">Eaton Innovation Center in Milwaukee, Wisconsin </place> . </span></font></span></p> <span class="EmailStyle41"><font face="Arial" color="#003300" size="2"><span style="FONT-SIZE: 10pt"> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><strong style=""><span style="FONT-SIZE: 14pt; "><font color="#000000"><font face="Times New Roman">The Speaker</font></font></span></strong></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><strong style=""><span style="FONT-SIZE: 14pt; "><font color="#000000"><font face="Times New Roman">Engelbert Hetzmannseder</font></font></span></strong></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><strong style=""><span style="FONT-SIZE: 14pt; "></span></strong></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><strong style=""><span style="FONT-SIZE: 14pt; "></span></strong><font size="3"><font color="#000000"><font face="Times New Roman"><strong style="">Engelbert Hetzmannseder</strong> was born in Klaffer, Upper Austria .<span style="">&nbsp; </span>He received his Dipl.-Ing. (B.S., M.S., 1990) and Dr. techn. (Ph.D., 1994) degree in Electrical Engineering from the Technical University of Vienna, Austria.<span style="">&nbsp; </span>Since February 1995 he has been with Eaton Corporation / Innovation Center in Milwaukee, <state w:st="on">WI</state>, , involved with fundamental and applied research on contacts, switching arc phenomena, and arc fault detection for industrial, aerospace, and automotive products.<span style="">&nbsp; </span>He holds 8 patents and published 20 papers at international conferences.<span style="">&nbsp; </span></font></font></font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><font size="3"><font color="#000000"><font face="Times New Roman"><span style=""></span><br />Since 2000 he has been Technology Manager of the Electrical Architecture &amp; Systems department at the <placename w:st="on">Eaton Innovation Center </place> .<span style="">&nbsp; </span>Capabilities of the EAS group include:</font></font></font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.35in; TEXT-INDENT: -0.2in; LINE-HEIGHT: normal; "><span style="COLOR: black; FONT-FAMILY: Symbol; "><span style=""><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="Times New Roman" color="#000000" size="3">Electric Power Management</font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.35in; TEXT-INDENT: -0.2in; LINE-HEIGHT: normal; "><span style="COLOR: black; FONT-FAMILY: Symbol; "><span style=""><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="Times New Roman" color="#000000" size="3">Power electronic, Power quality, and power conversion architectures</font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.35in; TEXT-INDENT: -0.2in; LINE-HEIGHT: normal; "><span style="COLOR: black; FONT-FAMILY: Symbol; "><span style=""><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="Times New Roman" color="#000000" size="3">Diagnostics &amp; prognostics of electrical components and systems</font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.35in; TEXT-INDENT: -0.2in; LINE-HEIGHT: normal; "><span style="COLOR: black; FONT-FAMILY: Symbol; "><span style=""><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="Times New Roman" color="#000000" size="3">Electro-mechanical switching technologies, Arc &amp; plasma science, Contact physics</font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.35in; TEXT-INDENT: -0.2in; LINE-HEIGHT: normal; "><span style="COLOR: black; FONT-FAMILY: Symbol; "><span style=""><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="Times New Roman" color="#000000" size="3">Power systems modeling: magnetic, electric, thermal, electro-mechanical</font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.35in; TEXT-INDENT: -0.2in; LINE-HEIGHT: normal; "><span style="COLOR: black; FONT-FAMILY: Symbol; "><span style=""><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="Times New Roman" color="#000000" size="3">Mechanism synthesis and modeling</font></p> <p class="MsoHeader" style="MARGIN: 24pt 0in 0pt; LINE-HEIGHT: normal; tab-stops: .5in"> <p><font face="Times New Roman" color="#000000" size="3">&nbsp; <stroke joinstyle="miter"></stroke> <path  gradientshapeok="t" ></path> <lock v:ext="edit" aspectratio="t"></lock><shape id="_x0000_s1026" style="MARGIN-TOP: 48.4pt; Z-INDEX: 1; MARGIN-LEFT: 401.55pt; WIDTH: 157.1pt; POSITION: absolute; HEIGHT: 213.55pt" type="#_x0000_t75"><imagedata  src="file:///C:\DOCUME~1\jakirk\Local%20Settings\Temp\msohtml1\01\clip_image001.jpg"></imagedata></shape> <stroke joinstyle="miter"></stroke> <path  gradientshapeok="t" ></path> <lock v:ext="edit" aspectratio="t"></lock><shape id="_x0000_s1026" style="MARGIN-TOP: 48.4pt; Z-INDEX: 1; MARGIN-LEFT: 401.55pt; WIDTH: 157.1pt; POSITION: absolute; HEIGHT: 213.55pt" type="#_x0000_t75"><imagedata  src="file:///C:\DOCUME~1\jakirk\Local%20Settings\Temp\msohtml1\01\clip_image001.jpg"></imagedata></shape></font></p> </p> <p class="MsoNormal"> <p>&nbsp;</p> </p> </span></font></span> [/code] Things like: [code] <placename w:st="on">Eaton Innovation Center in Milwaukee, Wisconsin </place> <placename w:st="on">Eaton Innovation Center </place> [/code] remain while the others are replaced.  I think that it might have something with those tags been embed in other tags, I've tried different things but I'm not sure what to do.
  3. I just tried that and it still adds it even if it doesnt end in .gif.
  4. I changed it to the following code; however, it still adds it to the database no matter what tool_icon ends in. [code] if (isset($_POST['submit'])) { //handle the form if(isset($_POST["tool_icon"]) && strpos($_POST["tool_icon"], ".gif") != FALSE) {   //enter stuff into database //Opens database connection $dbc = mysql_connect('host', 'user', 'pass'); //Selects database mysql_select_db('db'); //Define the query $query = "INSERT INTO admin_tools (tool_name, tool_icon, tool_link, tool_cat) VALUES ('{$_POST['tool_name']}', '{$_POST['tool_icon']}', '{$_POST['tool_link']}', '{$_POST['tool_cat']}')"; //Runs the query if (mysql_query ($query)) {     echo 'The tool has been added.';     } else {     echo '<p>Could not add the tool because <b>' . mysql_error() . '</b>.  The query was ' .$query . '.</p>';     }     mysql_close();     }     else {   //echo the form again     echo ' <p>Please include image extension.</p> <form action="index.php" method="post"> <p>Tool Name: <input type="text" name="tool_name" size="40" maxsize="50" value="' . $_POST['tool_name'] . '"/></p> <p>Tool Icon Name: <input type="text" name="tool_icon" size="40" maxsize="50" value="' . $_POST['tool_icon'] . '"/></p> <p>Tool Link: <input type="text" name="tool_link" size="40" maxsize="150" value="' . $_POST['tool_link'] . '"/></p> <p>Tool Category:     <select name="tool_cat">     <option value="Inventory">Inventory</option>     <option value="Network Tools">Network Tools</option>     <option value="Reference">Reference</option>     <option value="User Account Tools">User Account Tools</option>     <option value="Web Tools">Web Tools</option>     <option value="' . $_POST['tool_cat'] . '" selected="selected">' . $_POST['tool_cat'] . '</option>     </select></p> <input type="submit" name="submit" value="Add Tool" /> </form>';     }     } else { // Display form echo '<form action="index.php" method="post"> <p>Tool Name: <input type="text" name="tool_name" size="40" maxsize="50" /></p> <p>Tool Icon Name: <input type="text" name="tool_icon" size="40" maxsize="50" /></p> <p>Tool Link: <input type="text" name="tool_link" size="40" maxsize="150" /></p> <p>Tool Category:     <select name="tool_cat">     <option value="Inventory">Inventory</option>     <option value="Network Tools">Network Tools</option>     <option value="Reference">Reference</option>     <option value="User Account Tools">User Account Tools</option>     <option value="Web Tools">Web Tools</option>     </select></p> <input type="submit" name="submit" value="Add Tool" /> </form>'; } [/code]
  5. Hey I have the following code. I would like for it to check to see if a form has been submitted and if it has then to check the tool_icon variable to make sure the user included an image extension. Right now it displays the form and it doesn't matter if the varible ends in .gif it adds it to the database anyway. What's wrong in my code? Thanks. [code] if (isset($_POST['submit'])) { //handle the form //Opens database connection $dbc = mysql_connect('host', 'user', 'pass'); //Selects database mysql_select_db('dbname'); //Define the query $query = "INSERT INTO admin_tools (tool_name, tool_icon, tool_link, tool_cat) VALUES ('{$_POST['tool_name']}', '{$_POST['tool_icon']}', '{$_POST['tool_link']}', '{$_POST['tool_cat']}')"; //Runs the query if (pregi_match(".gif$", $_POST['tool_icon'])){ if (mysql_query ($query)) {     echo 'The tool has been added.';     } else {     echo '<p>Could not add the tool because <b>' . mysql_error() . '</b>.  The query was ' .$query . '.</p>';     }     mysql_close();     }     else{     echo ' <p>Please include image extension.</p> <form action="index.php" method="post"> <p>Tool Name: <input type="text" name="tool_name" size="40" maxsize="50" value="' . $_POST['tool_name'] . '"/></p> <p>Tool Icon Name: <input type="text" name="tool_icon" size="40" maxsize="50" value="' . $_POST['tool_icon'] . '"/></p> <p>Tool Link: <input type="text" name="tool_link" size="40" maxsize="150" value="' . $_POST['tool_link'] . '"/></p> <p>Tool Category:     <select name="tool_cat">     <option value="Inventory">Inventory</option>     <option value="Network Tools">Network Tools</option>     <option value="Reference">Reference</option>     <option value="User Account Tools">User Account Tools</option>     <option value="Web Tools">Web Tools</option>     <option value="' . $_POST['tool_cat'] . '" selected="selected">' . $_POST['tool_cat'] . '</option>     </select></p> <input type="submit" name="submit" value="Add Tool" /> </form>';     }     }     else { // Display form echo '<form action="index.php" method="post"> <p>Tool Name: <input type="text" name="tool_name" size="40" maxsize="50" /></p> <p>Tool Icon Name: <input type="text" name="tool_icon" size="40" maxsize="50" /></p> <p>Tool Link: <input type="text" name="tool_link" size="40" maxsize="150" /></p> <p>Tool Category:     <select name="tool_cat">     <option value="Inventory">Inventory</option>     <option value="Network Tools">Network Tools</option>     <option value="Reference">Reference</option>     <option value="User Account Tools">User Account Tools</option>     <option value="Web Tools">Web Tools</option>     </select></p> <input type="submit" name="submit" value="Add Tool" /> </form>'; } [/code]
  6. [!--quoteo(post=357781:date=Mar 23 2006, 05:23 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Mar 23 2006, 05:23 PM) [snapback]357781[/snapback][/div][div class=\'quotemain\'][!--quotec--] you want to check BEFORE the form is submited corect?? [/quote] Yes, because it adds the icon name to a mysql database.
  7. Hey, I have the following code [code] if (mysql_query ($query)) {     echo 'The tool has been added.';     } else {     echo '<p>Could not add the tool because <b>' . mysql_error() . '</b>.  The query was ' .$query . '.</p>';     }     mysql_close(); } // Display form ?> <form action="index.php" method="post"> <p>Tool Name: <input type="text" name="tool_name" size="40" maxsize="50" /></p> <p>Tool Icon Name: <input type="text" name="tool_icon" size="40" maxsize="50" /></p> <p>Tool Link: <input type="text" name="tool_link" size="40" maxsize="150" /></p> <p>Tool Category:     <select name="tool_cat">     <option value="Inventory">Inventory</option>     <option value="Network Tools">Network Tools</option>     <option value="Reference">Reference</option>     <option value="User Account Tools">User Account Tools</option>     <option value="Web Tools">Web Tools</option>     </select></p> <input type="submit" name="submit" value="Add Tool" /> </form> [/code] If I wanted to check to see that tool_icon ends with .gif how would I do that and if it doesn't end in .gif where would I echo to the use to please end tool icon name with .gif.
  8. What I'm trying to do is list some infomation from mysql into a 3 column table. Here's what I have. [code]            echo '<div class="title">' . $row['cat_name'] . '</div>';             $query2 = 'SELECT * FROM admin_tools ORDER BY tool_num ASC';             if($r=mysql_query($query2)) {                 echo '<table>';                 while ($row2 = mysql_fetch_array($r)) {                         echo '<tr>';                         $count=0;                         while ($count<3){                         echo '<td>';                         if($row2['tool_icon']){$a='<a href="' . $row2['tool_link'] . '"><img src="' . $row2['tool_icon'] . '" border="0" /> </a>';}                         else {$a='&nbsp;';}                         echo $a . '<a href="' . $row2['tool_link'] . '"><br />' . $row2['tool_name'] . '</a><br /></td>';                         $count++;                         }                         echo '</tr>';                     }                         echo '</table';                 } [/code] Instead of printing each database entry into a new table cell until it reaches 3 and going to the next table row. It prints the each database entry on a new row and mirrows that column to the next 2. What have I written wrong in my code.
  9. Hey I've made a database in mysql which has several different fields one containing the name of the categories i have on the site. I'm trying to code the page so that it does the correct category name this is what i have. Nav. Bar [code]if ($results = mysql_query ($query))     {         //Retrieves and prints every record         while ($row = mysql_fetch_array ($results))         {             echo '<li><a class="nav" href="' . 'index.php?cat_num=' . $row['cat_num'] . '">' . $row['cat_name'] . '</a></li>';         }     } [/code] Content of Category [code]if (isset($_GET['cat_num'])) { //makes sure that the code is only executed when the option variable is present $query = 'SELECT cat_name FROM admin_cat'; $results = mysql_query ($query); $row = mysql_fetch_array ($results);     switch ($_GET['cat_num']) {         case '1':             echo '<div class="title">' . $row['cat_name'] . '</div>';         break;         case '2':             echo '<div class="title">' . $row['cat_name'] . '</div>';         break;         case '3':             echo '<div class="title">' . $row['cat_name'] . '</div>';         break;     } } else {             echo '<div class="title">' . $row['cat_name'] . '</div>';    } [/code] When i click on each link it shows the same category name and i'm not sure how to get it to display a certain field based on another field in the database. Thanks for any help.
×
×
  • 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.