Current location: Hot Scripts Forums » Programming Languages » PHP » php tabcontainer


php tabcontainer

Reply
  #1 (permalink)  
Old 07-22-10, 10:49 AM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 122
Thanks: 2
Thanked 0 Times in 0 Posts
php tabcontainer

How can insert a php tabcontainer in which the container data came from mysql db
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-22-10, 12:20 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
You will have to explain further.
Maybe show some code?
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-22-10, 09:03 PM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 122
Thanks: 2
Thanked 0 Times in 0 Posts
php tabcontainer

ok i have a shopping cart in which when a click on to add my product i want also a part in which shows a tabcontainer. There will be tree tabs and in each tab container relevant information about the product, that information came from a table called prod_details ( prod_details, prod_warning, prod_directions) something like this

Buy Stain Away Plus Denture Cleanser online at CVS.com

this is my code so far
PHP Code:

<?php

   $prodid 
$_GET['id'];

   echo 
"<h6>Add item to cart</h6>\n";

   
$query "SELECT description, price from products where prodid = $prodid";
   
$result mysql_query($query);

   
$row=mysql_fetch_array($resultMYSQL_ASSOC);

   
$description $row['description'];
   
$price $row['price'];
   
$quantity 1;

   echo 
"<form action=\"index.php\" method=\"post\">\n";

 echo 
"<table align=\"center\" width=\"100%\" cellpadding=\"2\" border=\"0\">\n";
    echo 
"<tr>
             <td colspan = \"5\">
$description</td>
             <td>Qty</td><td>Add</td>
         </tr>\n"
;
   echo 
"<tr>
            <td></td>\n"
;
      echo 
"<td><img src=\"showimage.php?id=$prodid\" width=\"80\" height=\"60\"></td>
            <td>$</td>
            <td>
$price</td>\n";
      echo 
"<td><input type=\"text\" name=\"quantity\" value=\"$quantity\" size=\"3\"</td>\n";

   echo 
"<input type=\"hidden\" name=\"content\" value=\"addtocart\">\n";
   echo 
"<input type=\"hidden\" name=\"prodid\" value=\"$prodid\">\n";

echo 
"<td><input type=\"image\" src=\"http://www.hotscripts.com/forums/images/icon_32x32_purchase.gif\" value=\"Add to cart\"></td>
       </tr>\n"
;

   echo 
"</table>\n";
echo 
"</form>\n";


?>

Last edited by job0107; 07-22-10 at 09:10 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-23-10, 12:11 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
This will give you a rough idea on how to go about it.
I just used plain text for the tabs and wrote some Javascript to deal with them.
But you could just as easily use images instead or maybe use images for the backgrounds.
Anyway, here is the code.
PHP Code:

<?php
$prodid 
$_GET['id'];

// connect to mysql server and select a database //
$host "";       // enter mysql host name here //
$user "";       // enter mysql user name here //
$password "";   // enter mysql password here //
$db "";         // enter mysql database name here //
mysql_connect($host,$user,$password); // connect to mysql server //
mysql_select_db($db); // select mysql database //

// query products table and fetch results //
$query "SELECT description, price from products where prodid = $prodid";
$result mysql_query($query);
$row=mysql_fetch_assoc($result);
$description $row['description'];
$price $row['price'];
$quantity 1;

// query prod_details table and fetch results //
$query "SELECT prod_details, prod_warning, prod_directions from prod_details where prodid = $prodid";
$result mysql_query($query);
$row=mysql_fetch_assoc($result);
$prod_details $row["prod_details"];
$prod_warning $row["prod_warning"];
$prod_directions $row["prod_directions"];
?>
<html>
<head>
<style>
#tab_container{
   padding:10px;
   background:#eef;
   width:700px;
}
#tab1,#tab2,#tab3{
   float:left;
   padding:5px;
   padding-left:10px;
   padding-right:10px;
   border-right:1px solid #ccf;
   width:120px;
   text-align:center;
}
#body_container{
   padding:10px;
   background:#fff;
}
.b{
   background:#fff;
   display:none;
}
.btn1{
   cursor:pointer;
   background:#aaf;
}
.btn2{
   background:#fff;
}
</style>
<script>
function init_tab_container() {
   document.getElementById("b1").style.display = "block";
}
function select_tab(obj) {
   var id = obj.id;
   var b1 = document.getElementById("b1");
   var b2 = document.getElementById("b2");
   var b3 = document.getElementById("b3");
   var tab1 = document.getElementById("tab1");
   var tab2 = document.getElementById("tab2");
   var tab3 = document.getElementById("tab3");
   tab1.className = "btn1";
   tab2.className = "btn1";
   tab3.className = "btn1";
   tab1.style.cursor = "pointer";
   tab2.style.cursor = "pointer";
   tab3.style.cursor = "pointer";
   obj.style.cursor = "text";
   obj.style.textDecoration = "none";
   obj.className = "btn2";
   b1.style.display = "none";
   b2.style.display = "none";
   b3.style.display = "none";
   if(id == "tab1"){b1.style.display = "block";}
   if(id == "tab2"){b2.style.display = "block";}
   if(id == "tab3"){b3.style.display = "block";}
}
function decorate_tab(obj) {
   if(obj.className == "btn1"){obj.style.textDecoration = "underline";}
}
</script>
</head>
<body onload="init_tab_container()">
<h6>Add item to cart</h6>
<form action="index.php" method="post">
 <input type="hidden" name="content" value="addtocart">
 <input type="hidden" name="prodid" value="<?php echo $prodid?>">
 <table align="center" width="100%" cellpadding="2" border="0">
  <tr>
   <td colspan="5"><?php echo $description?></td>
   <td>Qty</td>
   <td>Add</td>
  </tr>
  <tr>
   <td></td>
   <?php echo '<td colspan="2"><img src="showimage.php?id=$prodid" width="80" height="60"></td>'?>
   <td align="right">$</td>
   <td><?php echo $price?></td>
   <td><input type="text" name="quantity" value="<?php echo $quantity?>" size="3"</td>
   <td><input type="image" src="http://www.hotscripts.com/forums/images/icon_32x32_purchase.gif" value="Add to cart"></td>
  </tr>
 </table>
</form>
<div id="tab_container">
 <div id="tab1" class="btn2" onclick="select_tab(this)" onmouseover="decorate_tab(this)" onmouseout="this.style.textDecoration = 'none'">Product Details</div>
 <div id="tab2" class="btn1" onclick="select_tab(this)" onmouseover="decorate_tab(this)" onmouseout="this.style.textDecoration = 'none'">Directions</div>
 <div id="tab3" class="btn1" onclick="select_tab(this)" onmouseover="decorate_tab(this)" onmouseout="this.style.textDecoration = 'none'">Warning</div>
 <br style="clear:both;" />
 <div id="body_container">
  <div id="b1" class="b"><?php echo $prod_details?></div>
  <div id="b2" class="b"><?php echo $prod_directions?></div>
  <div id="b3" class="b"><?php echo $prod_warning?></div>
 </div>
</div>
</body>
</html>
__________________
Jerry Broughton

Last edited by job0107; 07-23-10 at 12:16 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-23-10, 11:51 AM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 122
Thanks: 2
Thanked 0 Times in 0 Posts
Thank you very much!!!!!!!!
Now i have another question, How upload a pdf and ms word file into a database and then retrieve the files for upload????
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 07-24-10, 12:26 AM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 122
Thanks: 2
Thanked 0 Times in 0 Posts
I cant get the data from mysql its is something wrong here, please help me
PHP Code:

<?php

$prodid 
$_GET['id'];
$host "localhost";       // enter mysql host name here //
$user "riteaid";       // enter mysql user name here //
$password "riteaid";   // enter mysql password here //
$db "riteaidinventory";         // enter mysql database name here //
mysql_connect($host,$user,$password); // connect to mysql server //
mysql_select_db($db); // select mysql database //

   
echo "<h6>Add item to cart</h6>\n";

   
$query "SELECT description, price from products where prodid = $prodid";
   
$result mysql_query($query);

   
$row=mysql_fetch_array($resultMYSQL_ASSOC);

   
$description $row['description'];
   
$price $row['price'];
   
$quantity 1;
   
   
// query prod_details table and fetch results //
$query "SELECT prod_details, prod_warning, prod_directions from prod_details where prodid = $prodid";
$result mysql_query($query);
$row=mysql_fetch_assoc($result);
$prod_details $row["prod_details"];
$prod_warning $row["prod_warning"];
$prod_directions $row["prod_directions"];

?>
<?php
echo "<html>\n";
echo 
"<head>\n";
   echo 
"<body onload=\"init_tab_container()\">";
   echo 
"<form action=\"index.php\" method=\"post\">\n";

 echo 
"<table align=\"center\" width=\"100%\" cellpadding=\"2\" border=\"0\">\n";
    echo 
"<tr>
             <td colspan = \"8\"><font color=\"#FF0000\"><font size=\"3\"><strong>
$description</strong></font></td>
         </tr>\n"
;
   echo 
"<tr>
            <td rowspan=\"2\"><img src=\"showimage.php?id=
$prodid\" width=\"80\" height=\"60\"></td>\n";

      echo 
"
            <td><font color=\"#FF0000\"><font size=\"2\"><strong>$</strong></font></td>
            <td colspan = \"3\"><font color=\"#FF0000\" ><font size=\"2\"><strong>
$price</strong></font></td>
            </tr>\n"
;
            echo
"<tr>
               <td><strong>Qty</strong></td>
               <td><input type=\"text\" name=\"quantity\" value=\"
$quantity\" size=\"3\"</td>\n";
   echo 
"<input type=\"hidden\" name=\"content\" value=\"addtocart\">\n";
   echo 
"<input type=\"hidden\" name=\"prodid\" value=\"$prodid\">\n";

echo 
"<td><input type=\"image\" src=\"http://www.hotscripts.com/forums/images/coldwater-creek-add.gif\" value=\"Add to cart\"></td>
       </tr>\n"
;

   echo 
"</table>\n";
echo 
"</form>\n";
echo
"<p><p><p>\n";
echo
"<b>\n";
echo 
"<div id=\"tab_container\">\n";
echo 
" <div id=\"tab1\" class=\"btn2\" onclick=\"select_tab(this)\" onmouseover=\"decorate_tab(this)\" onmouseout=\"this.style.textDecoration = 'none'\">Details</div>\n";
echo 
" <div id=\"tab2\" class=\"btn1\" onclick=\"select_tab(this)\" onmouseover=\"decorate_tab(this)\" onmouseout=\"this.style.textDecoration = 'none'\">Directions</div>\n";
echo 
" <div id=\"tab3\" class=\"btn1\" onclick=\"select_tab(this)\" onmouseover=\"decorate_tab(this)\" onmouseout=\"this.style.textDecoration = 'none'\">Warning</div>\n";

echo 
" <br style=\"clear:both;\" />\n";
echo 
" <div id=\"body_container\">\n";
echo 
"  <div id=\"b1\" class=\"b\"><?php echo $prod_details; ?></div>\n";
echo 
"  <div id=\"b2\" class=\"b\"><?php echo $prod_directions; ?></div>\n";
echo 
"  <div id=\"b3\" class=\"b\"><?php echo $prod_warning; ?></div>\n";

echo 
" </div>\n";
echo 
" </div>\n";
echo 
"</div>\n";
echo 
"</body>\n";
echo 
"</html>";

?>

Last edited by job0107; 07-25-10 at 07:32 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 07-24-10, 01:47 AM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 122
Thanks: 2
Thanked 0 Times in 0 Posts
i got it to work, but now i cant retrieve the image!!!!! this is the code, i been trying everything but not results


<td> <?php echo '<img src="showimage.php?id=$prodid" width="80" height="60"></td>'; ?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 07-25-10, 07:41 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Quote:
Originally Posted by williamh26 View Post
I cant get the data from mysql its is something wrong here, please help me
PHP Code:

<?php

$prodid 
$_GET['id'];
$host "";       // enter mysql host name here //
$user "";       // enter mysql user name here //
$password "";   // enter mysql password here //
$db "";         // enter mysql database name here //
mysql_connect($host,$user,$password); // connect to mysql server //
mysql_select_db($db); // select mysql database //

   
echo "<h6>Add item to cart</h6>\n";

   
$query "SELECT description, price from products where prodid = $prodid";
   
$result mysql_query($query);

   
$row=mysql_fetch_array($resultMYSQL_ASSOC);

   
$description $row['description'];
   
$price $row['price'];
   
$quantity 1;
   
   
// query prod_details table and fetch results //
$query "SELECT prod_details, prod_warning, prod_directions from prod_details where prodid = $prodid";
$result mysql_query($query);
$row=mysql_fetch_assoc($result);
$prod_details $row["prod_details"];
$prod_warning $row["prod_warning"];
$prod_directions $row["prod_directions"];

?>
<?php
echo "<html>\n";
echo 
"<head>\n";
   echo 
"<body onload=\"init_tab_container()\">";
   echo 
"<form action=\"index.php\" method=\"post\">\n";

 echo 
"<table align=\"center\" width=\"100%\" cellpadding=\"2\" border=\"0\">\n";
    echo 
"<tr>
             <td colspan = \"8\"><font color=\"#FF0000\"><font size=\"3\"><strong>
$description</strong></font></td>
         </tr>\n"
;
   echo 
"<tr>
            <td rowspan=\"2\"><img src=\"showimage.php?id=
$prodid\" width=\"80\" height=\"60\"></td>\n";

      echo 
"
            <td><font color=\"#FF0000\"><font size=\"2\"><strong>$</strong></font></td>
            <td colspan = \"3\"><font color=\"#FF0000\" ><font size=\"2\"><strong>
$price</strong></font></td>
            </tr>\n"
;
            echo
"<tr>
               <td><strong>Qty</strong></td>
               <td><input type=\"text\" name=\"quantity\" value=\"
$quantity\" size=\"3\"</td>\n";
   echo 
"<input type=\"hidden\" name=\"content\" value=\"addtocart\">\n";
   echo 
"<input type=\"hidden\" name=\"prodid\" value=\"$prodid\">\n";

echo 
"<td><input type=\"image\" src=\"http://www.hotscripts.com/forums/images/coldwater-creek-add.gif\" value=\"Add to cart\"></td>
       </tr>\n"
;

   echo 
"</table>\n";
echo 
"</form>\n";
echo
"<p><p><p>\n";
echo
"<b>\n";
echo 
"<div id=\"tab_container\">\n";
echo 
" <div id=\"tab1\" class=\"btn2\" onclick=\"select_tab(this)\" onmouseover=\"decorate_tab(this)\" onmouseout=\"this.style.textDecoration = 'none'\">Details</div>\n";
echo 
" <div id=\"tab2\" class=\"btn1\" onclick=\"select_tab(this)\" onmouseover=\"decorate_tab(this)\" onmouseout=\"this.style.textDecoration = 'none'\">Directions</div>\n";
echo 
" <div id=\"tab3\" class=\"btn1\" onclick=\"select_tab(this)\" onmouseover=\"decorate_tab(this)\" onmouseout=\"this.style.textDecoration = 'none'\">Warning</div>\n";

echo 
" <br style=\"clear:both;\" />\n";
echo 
" <div id=\"body_container\">\n";
echo 
"  <div id=\"b1\" class=\"b\"><?php echo $prod_details; ?></div>\n";
echo 
"  <div id=\"b2\" class=\"b\"><?php echo $prod_directions; ?></div>\n";
echo 
"  <div id=\"b3\" class=\"b\"><?php echo $prod_warning; ?></div>\n";

echo 
" </div>\n";
echo 
" </div>\n";
echo 
"</div>\n";
echo 
"</body>\n";
echo 
"</html>";

?>
I assume your fetching the data from the products table ok?
If not, check to see if there is a value in $prodid.

If all the data is correct from the products table query,
then your probably saying that you aren't getting any results from the prod_details table.

The query I put together for the prod_details table was just an educated guess.
I of course was assuming that you have a prodid column in the prod_details table.
If you don't then the query won't work.

If all my assumptions so far are correct, and you aren't getting any results from the prod_details table, then what are the columns in the prod_details table?
There must be some way to tell what product details go to which product.
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 11:17 AM
help with error messages.. please APuppyDog PHP 2 10-06-06 12:09 AM
PHP Downside--Solutions? Amulet PHP 10 07-15-05 09:26 AM


All times are GMT -5. The time now is 01:25 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.