Jump to content

FourEyes

Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.cadmancc.com

Profile Information

  • Gender
    Not Telling
  • Location
    Michigan

FourEyes's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=383985:date=Jun 14 2006, 04:52 PM:name=tidalik)--][div class=\'quotetop\']QUOTE(tidalik @ Jun 14 2006, 04:52 PM) [snapback]383985[/snapback][/div][div class=\'quotemain\'][!--quotec--] Why are you calling [code]<?php[/code] again? It's already open... Have you just tried just removing the <?php, ?> & second echo? [/quote] I did. No change, I still have a blank page. [!--quoteo(post=383992:date=Jun 14 2006, 05:32 PM:name=effigy)--][div class=\'quotetop\']QUOTE(effigy @ Jun 14 2006, 05:32 PM) [snapback]383992[/snapback][/div][div class=\'quotemain\'][!--quotec--] Have a look at heredoc (see signature). [/quote] I read it. I don't see how this applies to my situation. [!--quoteo(post=384088:date=Jun 15 2006, 02:58 AM:name=JP128)--][div class=\'quotetop\']QUOTE(JP128 @ Jun 15 2006, 02:58 AM) [snapback]384088[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code]echo "<tr><td>" . $medical[$plan_id][$k] . "</td><td><input name=\"field" . $k . " size=45 value=\"<?php echo isset($_POST[\'View\'])?$row[\'customer_address1\']:\'\';?>\"></td></tr>";[/code] Lets break this down... I have a question. Are you trying to add something to the name? name=field$k? Also, if you want to echo something, why not just turn it into a variable? $new_variable = "isset($_POST[\'View\'])?$row[\'customer_address1\']:\'\';?>\"></td></tr>"; I also agree with tidalik... How come you are re-opening the <?php tag? That doesn't make sense to me. idk, maybe I am wrong, but that is what I may do... I am new to php, trying to learn a lot, but when it comes to these things, I may be wrong. So, I hope I helped in any way? [/quote] Okay, re-opening PHP was ignorant on my part. Also, to solve the problem, I did as you suggest, which is put the variables into other variables that won't require quotes. It's not elegant, but it works. I just thought there was a less brute-force way. [code]      $aa = $_POST['View'];       $bb = $row['customer_address1'];       echo "<tr><td>" . $medical[$plan_id][$k] . "</td><td><input name=\"field" . $k . " size=45 value=\"isset($aa)?$bb:\'\';\"></td></tr>";[/code] Thank you all for your suggestons.
  2. Here is the code: [code]<?php session_start(); header("Cache-control: private"); $person_id = $_SESSION['page']; $customer_id = $_SESSION['stamp']; $c = $_SESSION['c']; $m1 = $_SESSION['m1']; $m2 = $_SESSION['m2']; $plan_id = $_POST['Plans']; $medical = array(array()); include 'header.html'; # Connect to MySQL $connection = @mysql_connect("localhost", "??", "??") or die("Could not connect to MySQL."); # Select the specified database. $result = @mysql_select_db("sfb", $connection) or die("Could not select the requested database."); ?> <table width=175 border=0 align="left" cellpadding=0 cellspacing=0> <tr align="left" valign="top" nowrap>   <td width=175 valign="top" nowrap><img src="../images/NAV-pic.jpg" border=0></td> </tr><tr align="left" valign="top" nowrap>   <td align="left" nowrap><a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','NAV-home-on.gif',0)"><img src="../images/NAV-home.gif" alt="home" name="Image6" border=0></a></td> </tr><tr align="left" valign="top" nowrap>   <td align="left" nowrap><a href="products.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image7','','NAV-products-on.gif',0)"><img src="../images/NAV-products.gif" alt="Products & Services" name="Image7" border=0></a></td> </tr><tr align="left" valign="top" nowrap>   <td align="left" nowrap><a href="csa.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image19','','NAV-service-on.gif',0)"><img src="../images/NAV-service-on.gif" alt="Customer Service Area" name="Image19" border=0></a></td> </tr><tr align="left" valign="top" nowrap>   <td align="left" nowrap><a href="quotes.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image9','','NAV-quotes-on.gif',0)"><img src="../images/NAV-quotes.gif" alt="Online Quotes" name="Image9" border=0></a></td> </tr><tr align="left" valign="top" nowrap>   <td align="left" nowrap><a href="free.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image17','','NAV-info-on.gif',0)"><img src="../images/NAV-info.gif" alt="Free Information" name="Image17" border=0></a></td> </tr><tr align="left" valign="top" nowrap>   <td align="left" nowrap><a href="about.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image18','','NAV-about-on.gif',0)"><img src="../images/NAV-about.gif" alt="About Us" name="Image18" width=175 height=24 border=0></a></td> </tr>     </table> <?php $self = $_SERVER['PHP_SELF']; echo ("<form action=\"$self\" method=\"post\">"); ?> <h2><?php echo $c;?><br>Add/Edit/Delete Major Medical Plan</h2>     <select name="Plans" size=5> <?php $query = "select * from medical order by plan_name"; $result = mysql_query($query,$connection) or die ("Could not find any plans."); while ($row = mysql_fetch_assoc($result)) {   $id = $row['plan_id'];   if ($id == $plan_id) {     echo ("  <option selected value=");   } else {     echo ("  <option value=");   }   echo $id . ">" . $row['plan_name'] . " ~ " . $row['carrier'];   if ($row['network'] == "Y") {     echo " ~ Network</option>\n";   } else {     echo " ~ Non-network</option>\n";   }   $j = 0;   foreach ($row as $info) {     $medical[$id][$j] = $info;     $j++;   } } ?> </select><br> Select a plan, then click, <input type="submit" name="View" value="View Plan Details"><br><br> <table width=595 border=0 cellpadding=0 cellspacing=0> <?php if ($plan_id > 0) {   if ($medical[$plan_id][3] == "Y") {     echo "<tr><td>" . $medical[$plan_id][$k] . "</td></tr>";   } else {     for ($k=4;$k<$j;$k=$k+7) {       echo "<tr><td>" . $medical[$plan_id][$k] . "</td><td><input name=\"field" . $k . " size=45 value=\"<?php echo isset($_POST['View'])?$row['customer_address1']:\'\';?>\"></td></tr>";     }   } } else {   for ($k=4;$k<$j;$k=$k+7) {     echo "<tr><td>" . $medical[0][$k] . "</td></tr>";   } } ?> </table> <!--#include virtual="footer.html" --> [/code] The problem is in the line: [code]      echo "<tr><td>" . $medical[$plan_id][$k] . "</td><td><input name=\"field" . $k . " size=45 value=\"<?php echo isset($_POST[\'View\'])?$row[\'customer_address1\']:\'\';?>\"></td></tr>";[/code] The last pair of \' cause no problem, but all of the other \' cause the parser to halt (I think that's the right way to say it - nothing appears on the Web page). I know that I can put $_POST['View'] and $row['customer_address1'] into variables outside of this echo statement and be done with the problem, but I'd like to learn how to do this correctly, rather than just make it work. What do I do to make the code work correctly?
  3. [!--quoteo(post=383002:date=Jun 12 2006, 06:41 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ Jun 12 2006, 06:41 PM) [snapback]383002[/snapback][/div][div class=\'quotemain\'][!--quotec--] change this: while ($row = mysql_fetch_array($result)) { to this: while ($row = mysql_fetch_assoc($result)) { Read up in the manual why! [/quote] <sound of hand slapping forehead> From the PHP manual page on mysql_fetch_array: Parameters result The result resource that is being evaluated. This result comes from a call to mysql_query(). result_type The type of array that is to be fetched. It's a constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, and the default value of MYSQL_BOTH. Road hypnosis. I use mysql_fetch_array all the time, and just got so used to it I didn't *think* about using another fetch option. Thank you, ToPlay
  4. I am reading data out of a MySQL table. I know there are 144 fields per record, and I've checked the data to ensure this is the case. However, when I read the values into an array, I end up with 288 elements in my array. Array element 0 is duplicated in element 1, 2 is duplicated in 3, etc. What's causing this and how do I stop it? <?php session_start(); header("Cache-control: private"); $person_id = $_SESSION['page']; $customer_id = $_SESSION['stamp']; $c = $_SESSION['c']; $m1 = $_SESSION['m1']; $m2 = $_SESSION['m2']; $medical = array(array()); include 'header.html'; # Connect to MySQL $connection = @mysql_connect("localhost", "???", "???") or die("Could not connect to MySQL."); # Select the specified database. $result = @mysql_select_db("sfb", $connection) or die("Could not select the requested database."); ?> <table width=175 border=0 align="left" cellpadding=0 cellspacing=0> <tr align="left" valign="top" nowrap> <td width=175 valign="top" nowrap><img src="../images/NAV-pic.jpg" border=0></td> </tr><tr align="left" valign="top" nowrap> <td align="left" nowrap><a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','NAV-home-on.gif',0)"><img src="../images/NAV-home.gif" alt="home" name="Image6" border=0></a></td> </tr><tr align="left" valign="top" nowrap> <td align="left" nowrap><a href="products.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image7','','NAV-products-on.gif',0)"><img src="../images/NAV-products.gif" alt="Products & Services" name="Image7" border=0></a></td> </tr><tr align="left" valign="top" nowrap> <td align="left" nowrap><a href="csa.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image19','','NAV-service-on.gif',0)"><img src="../images/NAV-service-on.gif" alt="Customer Service Area" name="Image19" border=0></a></td> </tr><tr align="left" valign="top" nowrap> <td align="left" nowrap><a href="quotes.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image9','','NAV-quotes-on.gif',0)"><img src="../images/NAV-quotes.gif" alt="Online Quotes" name="Image9" border=0></a></td> </tr><tr align="left" valign="top" nowrap> <td align="left" nowrap><a href="free.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image17','','NAV-info-on.gif',0)"><img src="../images/NAV-info.gif" alt="Free Information" name="Image17" border=0></a></td> </tr><tr align="left" valign="top" nowrap> <td align="left" nowrap><a href="about.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image18','','NAV-about-on.gif',0)"><img src="../images/NAV-about.gif" alt="About Us" name="Image18" width=175 height=24 border=0></a></td> </tr> </table> <?php $self = $_SERVER['PHP_SELF']; echo ("<form action=\"$self\" method=\"post\">"); ?> <h2><?php echo $c;?><br>Add/Edit/Delete Major Medical Plan</h2> <select name="Plans" size=5> <?php $query = "select * from medical order by plan_name"; $result = mysql_query($query,$connection) or die ("Could not find any plans."); $i = 0; while ($row = mysql_fetch_array($result)) { $id = $row['plan_id']; if ($id == $_POST['Plans']) { echo (" <option selected value="); } else { echo (" <option value="); } echo $id . ">" . $row['plan_name'] . " ~ " . $row['carrier']; if ($row['network'] == "Y") { echo " ~ Network</option>\n"; } else { echo " ~ Non-network</option>\n"; } $j = 0; foreach ($row as $info) { $medical[$i][$j] = $info; $j++; } $i++; } ?> </select><br> Select a plan, then click, <input type="submit" name="View" value="View Plan Details"><br><br> <table width=595 border=0 cellpadding=0 cellspacing=0> <?php echo $medical[0][2],$medical[1][2]; echo $medical[0][3],$medical[1][3]; # The two lines above produce the same results = Badness. for ($k=4;$k<$j;$k=$k+7) { echo "<tr><td>" . $medical[0][$k] . "</td></tr>"; } ?> </table> <!--#include virtual="footer.html" -->
×
×
  • 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.