Jump to content

MySql Print if field is not empty isset


richiejones24

Recommended Posts

Having a bit of a problem with the code below, I am trying to get it the print the html code if the MySql field is not empty but its not working. Any ideas guy?  thanks 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
$uincookie = $_COOKIE["uin"];
require("./include/mysqldb.php");
$con = mysql_connect("$dbhost","$dbuser","$dbpass");

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("$dbame", $con);
$result = mysql_query("SELECT * FROM Reg_Profile_images WHERE uin ='$uincookie'");

$i=1;
while($rows = mysql_fetch_array($result)){

if (isset($row[image_zero]))
{
print "<p> </p>
<table width=\"0\" border=\"0\">
  <tr>
    <td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>
        <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td>
      </tr>
      <tr>
        <td><form id=\"form3\" name=\"form1\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button3\" id=\"button3\" value=\"Delete Picture\" />
          </div>
          </label>
        </form></td>
      </tr>
      <tr>
        <td><form id=\"form4\" name=\"form2\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button3\" id=\"button4\" value=\"Make Primary\" />
          </div>
          </label>
        </form></td>
      </tr>
    </table></td>\n";
}
if (isset($row[image_one]))
{
print "<td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>
        <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td>
      </tr>
      <tr>
        <td><form id=\"form5\" name=\"form1\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button4\" id=\"button5\" value=\"Delete Picture\" />
          </div>
          </label>
        </form></td>
      </tr>
      <tr>
        <td><form id=\"form6\" name=\"form2\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button4\" id=\"button6\" value=\"Make Primary\" />
          </div>
          </label>
        </form></td>\n";
}
if (isset($row[image_two]))
{
print " </tr>
    </table></td>
    <td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>
        <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td>
      </tr>
      <tr>
        <td><form id=\"form7\" name=\"form1\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button5\" id=\"button7\" value=\"Delete Picture\" />
          </div>
          </label>
        </form></td>
      </tr>
      <tr>
        <td><form id=\"form8\" name=\"form2\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button5\" id=\"button8\" value=\"Make Primary\" />
          </div>
          </label>
        </form></td>\n";
}
if (isset($row[image_three]))
{
print " </tr>
    </table></td>
    <td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>
        <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td>
      </tr>
      <tr>
        <td><form id=\"form9\" name=\"form1\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button6\" id=\"button9\" value=\"Delete Picture\" />
          </div>
          </label>
        </form></td>
      </tr>
      <tr>
        <td><form id=\"form10\" name=\"form2\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button6\" id=\"button10\" value=\"Make Primary\" />
          </div>
          </label>
        </form></td>\n";
}
if (isset($row[image_four]))
{
print " </tr>
    </table></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
</table>
<p> </p>
<table width=\"0\" border=\"0\">
  <tr>
    <td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>
        <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td>
      </tr>
      <tr>
        <td><form id=\"form\" name=\"form1\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button\" id=\"button\" value=\"Delete Picture\" />
          </div>
          </label>
        </form></td>
      </tr>
      <tr>
        <td><form id=\"form2\" name=\"form2\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button\" id=\"button2\" value=\"Make Primary\" />
          </div>
          </label>
        </form></td>\n";
}
if (isset($row[image_five]))
{
print " </tr>
    </table></td>
    <td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>
        <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td>
      </tr>
      <tr>
        <td><form id=\"form11\" name=\"form1\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button\" id=\"button11\" value=\"Delete Picture\" />
          </div>
          </label>
        </form></td>
      </tr>
      <tr>
        <td><form id=\"form12\" name=\"form2\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button\" id=\"button12\" value=\"Make Primary\" />
          </div>
          </label>
        </form></td>\n";
}
if (isset($row[image_six]))
{
print "</tr>
    </table></td>
    <td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>
        <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td>
      </tr>
      <tr>
        <td><form id=\"form13\" name=\"form1\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button\" id=\"button13\" value=\"Delete Picture\" />
          </div>
          </label>
        </form></td>
      </tr>
      <tr>
        <td><form id=\"form14\" name=\"form2\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button\" id=\"button14\" value=\"Make Primary\" />
          </div>
          </label>
        </form></td>\n";
}
if (isset($row[image_seven]))
{
print " </tr>
    </table></td>
    <td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>
        <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td>
      </tr>
      <tr>
        <td><form id=\"form15\" name=\"form1\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button\" id=\"button15\" value=\"Delete Picture\" />
          </div>
          </label>
        </form></td>
      </tr>
      <tr>
        <td><form id=\"form16\" name=\"form2\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button\" id=\"button16\" value=\"Make Primary\" />
          </div>
          </label>
        </form></td>\n";
}
if (isset($row[image_eight]))
{
print " </tr>
    </table></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
</table>
<p> </p>
<table width=\"0\" border=\"0\">
  <tr>
    <td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>
        <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td>
      </tr>
      <tr>
        <td><form id=\"form17\" name=\"form1\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button2\" id=\"button17\" value=\"Delete Picture\" />
          </div>
          </label>
        </form></td>
      </tr>
      <tr>
        <td><form id=\"form18\" name=\"form2\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button2\" id=\"button18\" value=\"Make Primary\" />
          </div>
          </label>
        </form></td>\n";
}
if (isset($row[image_nine]))
{
print "</tr>
    </table></td>
    <td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>
        <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td>
      </tr>
      <tr>
        <td><form id=\"form19\" name=\"form1\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button2\" id=\"button19\" value=\"Delete Picture\" />
          </div>
          </label>
        </form></td>
      </tr>
      <tr>
        <td><form id=\"form20\" name=\"form2\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button2\" id=\"button20\" value=\"Make Primary\" />
          </div>
          </label>
        </form></td>\n";
}
if (isset($row[image_ten]))
{
print "</tr>
    </table></td>
    <td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>
        <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td>
      </tr>
      <tr>
        <td><form id=\"form21\" name=\"form1\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button2\" id=\"button21\" value=\"Delete Picture\" />
          </div>
          </label>
        </form></td>
      </tr>
      <tr>
        <td><form id=\"form22\" name=\"form2\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button2\" id=\"button22\" value=\"Make Primary\" />
          </div>
          </label>
        </form></td>\n";
}
if (isset($row[image_eleven]))
{
print "</tr>
    </table></td>
    <td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>
        <td><img src=\"37658_1324208185514_1240161074_30749958_5597262_n.jpg\" alt=\"\" width=\"156\" height=\"166\" /></td>
      </tr>
      <tr>
        <td><form id=\"form23\" name=\"form1\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button2\" id=\"button23\" value=\"Delete Picture\" />
          </div>
          </label>
        </form></td>
      </tr>
      <tr>
        <td><form id=\"form24\" name=\"form2\" method=\"post\" action=\"\">
          <label>
          <div align=\"center\">
            <input type=\"submit\" name=\"button2\" id=\"button24\" value=\"Make Primary\" />
          </div>
          </label>
        </form></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>\n";
}

  //if($i %4 == 0) { echo '</tr><tr>'; } // this will create the line separator by inserting a row when the $i is dividable by 4
}
?>
</table>
<p> </p>
<p> </p>
</body>
</html>

Link to comment
Share on other sites

The only thing I can see at a glance is, you need to make sure your tags are properly closed, especially when working with tables.  For example, you have multiple conditions, but they do not start out the same. 

 

if (isset($row[image_one]))
{
print "<td><table width=\"112\" height=\"129\" border=\"0\">
      <tr>

 

if (isset($row[image_two]))
{
print " </tr>
    </table></td>

 

Another thing is,  your are not taking advantage of the while loop.  Almost everything is hardcoded so what's the point in using your loop?  And tell us, what exactly are you trying to accomplish with this logic.  Then maybe we can point you in the right direction.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.