Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

It's propably a simple problem, but its causing a headache

General discussions related to php

Moderators: macek, egami, gesf

It's propably a simple problem, but its causing a headache

Postby karlosantana » Mon Jun 04, 2012 1:47 pm

Right hello and thank you for having me on the forum. If you look here (the login is at the bottom of the page) You will notice that the delete button for a row is under column 1, it shouldn't do that! The script for the page is below, I will include the CSS too. Thanks in advance!
Code: Select all
view.php
<?php

//Get database credentials
require 'config.php';

// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
//select the database
mysql_select_db($dbname) or die('Cannot select database');

require 'header.php';

$query = "SELECT * FROM table1;";

$result = mysql_query($query) or die(mysql_error());

//Count the number of rows returned
$count = mysql_num_rows($result);

//Table header
echo "<div><table id=\"tableheader\" bgcolor=\"#4382b5\">\n";
echo "<tr>\n";
echo "<td>&nbsp;Column 1:</td>\n";
echo "<td>&nbsp;Column 2:</td>\n";
echo "<td>&nbsp;Column 3:</td>\n";
echo "<td>&nbsp;Column 4:</td>\n";
echo "<td>&nbsp;Column 5:</td>\n";
echo "</tr>";
echo "</table></div>";
if ($count !== 0) {
         while($row = mysql_fetch_array($result)) {
            echo "<div class=\"addform\"><form method='get' action=\"update.php\">\n";
            echo "   <input type=\"text\" value=\"".$row[column1]."\" name=\"column1\">\n";
            echo "   <input type=\"text\" name=\"column2\" value=\"".$row[column2]."\"/>\n";
            echo "   <input type=\"text\" name=\"column3\" value=\"".$row[column3]."\"/>\n";
            echo "   <input type=\"text\" name=\"column4\" value=\"".$row[column4]."\"/>\n";
            echo "   <input type=\"text\" name=\"column5\" value=\"".$row[column5]."\"/>\n";
            echo "   <input type=\"image\" src=\"images/update.png\" alt=\"Update Row\" class=\"update\" title=\"Update Row\">\n";
            echo "<a href=\"delete.php?column1=".$row[column1]."\"><img title='Delete Row' alt=\"Delete\" class='del' src='images/delete.png'/></a></form></div>\n";
         }
      echo "</table><br />\n";
   } else {
      echo "<b><center>NO DATA</center></b>\n";
   }
   echo "<div>Add Row:</div>\n";
   echo "<div class=\"addform\"><form method='get' action=\"add.php\">\n".
   "   <input type=\"text\" name=\"column1\"/>\n".
   "   <input type=\"text\" name=\"column2\"/>\n".
   "   <input type=\"text\" name=\"column3\"/>\n".
   "   <input type=\"text\" name=\"column4\"/>\n".
   "   <input type=\"text\" name=\"column5\"/>\n".
   "   <input type=\"image\" src=\"images/add.png\" alt=\"Add Row\" class=\"update\" title=\"Add Row\">\n".
   "</form></div>";
?>
<div>
<br />
<b>Legend:</b>
<br />
<img alt="Add" src="images/add.png"> Add a row after entering the correct information.<br />
<img alt="Update" src="images/update.png"> Update a row after editing it.<br />
<img alt "Delete" src="images/delete.png"> Delete a row.<br />
</div>
</body>
</html>


Code: Select all
Style.css
body

{
   color: black;
   background-color: #FFFFFF;
   font-family: Verdana, sans-serif;
   font-size: 10pt;
   font: bold 11px/1.5em Verdana;
}

table

{

   width: 690px;
   border-collapse: collapse;
   padding: 0px 0px 0px 0px;
   font-size: 10pt;
   color: white;

}

td

{

   padding: 1px 0px 0px 0px;
   text-decoration: none;
   font-size: 10pt;
   width: 150px;

}

input

{

   position: relative;
   left: 4px;
   font-family: Verdana, sans-serif;
   padding: 0px 0px 0px 0px;
   text-decoration: none;
   font-size: 10pt;
   width: 130px;

}

a, img

{

   padding: 0px;
   color: black;
   text-decoration: none;
   border-width: 0px;
   font-family: Verdana;
   font-size: 10pt;

}

.del

{

   position: relative;
   top: 2px;
   left: 6px;
   padding: 0px;
   border: 0px;
   margin: 0px;
}

.update

{

   position: relative;
   top: 2px;
   left: 6px;
   padding: 0px;
   border: 0px;
   margin: 0px 3px 0 0;
   height: 16px;
   width: 16px;

}

.add

{

   margin: 5px 5px 5px 0px;
   width: 110px;
   
}

.button

{

   width: 60px;

}

.addform

{

   width: 720px;
   margin-bottom: -14px;
   padding: 0px 0 0 0;
   
}

.empnum

{

   width: 60px

}

h1 {
   font-family:Verdana, Arial, Helvetica, sans-serif;
   font-size:16px;
   font-weight:bold;
   margin:0;
   padding:0;
   }

hr {
   border:none;
   border-top:1px solid #CCCCCC;
   height:1px;
   margin-bottom:25px;
   }
   
#tabs {
   float:left;
   width:100%;
   background:#efefef;
   font-size:93%;
   line-height:normal;
   border-bottom:1px solid #666;
   }

#tabs ul {
   margin:0;
   padding:10px 10px 0 50px;
   list-style:none;
   }

#tabs li {
   display:inline;
   margin:0;
   padding:0;
   }

#tabs a {
   float:left;
   background:url("tableft.gif") no-repeat left top;
   margin:0;
   padding:0 0 0 4px;
   text-decoration:none;
   }

#tabs a span {
   float:left;
   display:block;
   background:url("tabright.gif") no-repeat right top;
   padding:5px 15px 4px 6px;
   color:#666;
   }

/* Commented Backslash Hack hides rule from IE5-Mac \*/
#tabs a span {float:none;}

/* End IE5-Mac hack */
#tabs a:hover span {
   color:#FFF;
   }

#tabs a:hover {
   background-position:0% -42px;
   }

#tabs a:hover span {
   background-position:100% -42px;
   }


Again thanks in advance
Kyle
karlosantana
New php-forum User
New php-forum User
 
Posts: 3
Joined: Mon Jun 04, 2012 1:40 pm

Re: It's propably a simple problem, but its causing a headac

Postby Emy » Mon Jun 04, 2012 10:01 pm

check the width and the height ot the table
Emy
New php-forum User
New php-forum User
 
Posts: 16
Joined: Sat Jun 02, 2012 8:16 pm

Re: It's propably a simple problem, but its causing a headac

Postby ejsexton82 » Tue Jun 05, 2012 2:39 am

This might work:

Code: Select all
.addform {
    white-space: nowrap;
}
User avatar
ejsexton82
New php-forum User
New php-forum User
 
Posts: 86
Joined: Mon Jun 04, 2012 10:05 pm
Location: Ankara, Turkey

Re: It's propably a simple problem, but its causing a headac

Postby karlosantana » Tue Jun 05, 2012 3:11 pm

Well nowrap worked, but its made all my text boxes empty :( whats going on? Stupid piece of code!
karlosantana
New php-forum User
New php-forum User
 
Posts: 3
Joined: Mon Jun 04, 2012 1:40 pm

Re: It's propably a simple problem, but its causing a headac

Postby karlosantana » Tue Jun 05, 2012 3:23 pm

Tinker and you will find! Sorted it, mixture of both and found my sql was faced lol Cheers Guys!
Kyle
karlosantana
New php-forum User
New php-forum User
 
Posts: 3
Joined: Mon Jun 04, 2012 1:40 pm


Return to PHP General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.