43 users online (1 members and 42 guests)  


  Results 1 to 6 of 6

Related

  1. Helsihki calling    Forum: Introduce Yourself
    Replies: 2
  2. Calling all Javascript'ers....    Forum: Internet Services
    Replies: 0
  3. Hollland calling    Forum: Introduce Yourself
    Replies: 1
  4. calling a table    Forum: Website Scripts Forum
    Replies: 12
  1. #1
    knightjt02's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2003
    Posts
    22

    Question I Need Help Setup A Table in PHP For Calling Different PRODUCTS ?

    Ok what i like to do is in my php page it list a table but calling the Different products down the page like this.
    1
    2
    3
    But what i like to do is calling for Different products like this.
    | 1 | 2 | 3 |
    | 4 | 5 | 6 |
    Can this be done like this with the Script i got it is php this is it.



    PHP:--------------------------------------------------------------------------------
    PHP Code:
    <script language="php">
    function 
    getCatlist($catID){
    global 
    $docroot$adminLink$imageProdFolder,  $prodShortDescENG,$prodLongDescENG,$prodOptions,$prodSize,$prodPrice,$host,$dbase,$dbuser,$dbpass,$ppalAccount,$defaultcatID,$cartId,$catID;
    global 
    $gbpound$eurocash$usdollar$gbpoundcost$eurocashcost$usdollarcost$itemcount$updater;

    echo 
    "<table border=\"0\" cellpadding=\"5\"><tr><td><a href=\"java script:history.go(-1);\"><br>&lt;-- go back</a></p></td></tr></table>";
    echo 
    "<table border=\"0\" width=\"100%\"><tr><td width=\"100%\"><hr size=\"1\" color=\"#EAF4FF\"></td></tr></table>";



    $i 0;
    $db mysql_connect($host$dbuser$dbpass);
    mysql_select_db($dbase,$db);
    $result mysql_query("SELECT * FROM product WHERE CategoryID like '$catID%' and ProductDisabled like '0' ORDER BY ProductShortDescriptionENG LIMIT 0,50",$db);

      while (
    $myrow mysql_fetch_array($result)) {
        
    $prodID $myrow["ProductID"];
        
    $prodOptions $myrow["ProductOptions"];
        
    $prodPrice $myrow["ProductPrice"];
        
    $prodImg $myrow["ProductImageURL"];
        
    $prodThumbImg $myrow["ProductImageThmbURL"];    
        
    $prodShortDescENG $myrow["ProductShortDescriptionENG"];
        
    $prodLongDescENG $myrow["ProductLongDescriptionENG"];    
        
    $prodLongDescENGL $myrow["ProductLongDescriptionENG"];
        if(
    strlen($prodLongDescENG) > 350) {
        
    $prodLongDescENG substr($prodLongDescENGL0350);
        if(
    strstr($prodLongDescENG,">")!="")
        
    $lasthtml strlen($prodLongDescENG)-strpos(strrev($prodLongDescENG),">");
        else
        
    $lasthtml 350;    
        
    $prodLongDescENG substr($prodLongDescENG0$lasthtml);
        }
        
    $prodweight =  $myrow["ProductWeight"];  
        
        
        
    $gbpoundcost $prodPrice $gbpound;
        
    $gbpoundcost number_format($gbpoundcost2"."",");
        
    $usdollarcost $prodPrice $usdollar;
        
    $usdollarcost number_format($usdollarcost2"."",");
        
    $eurocashcost $prodPrice $eurocash;
        
    $eurocashcost number_format($eurocashcost2"."",");  

          
    // display list of items if there are records to display


       
    echo "<table border=\"0\" width=\"100%\"><tr><td width=\"200\">";
       
    printf("<form action=\"cart.php\" method=\"post\">");
       
    printf("<input type=\"hidden\" name=\"action\" value=\"add_item\">"); 
       
    printf("<input type=\"hidden\" name=\"itemId\" value=\"$prodID\">");
       
    printf("<input type=\"hidden\" name=\"shortdesc\" value=\"$prodShortDescENG\">");
       
    printf("<input type=\"hidden\" name=\"prodThumbImg\" value=\"$prodThumbImg\">");
       
    printf("<input type=\"hidden\" name=\"prodprice\" value=\"$prodPrice\">");
       
    printf("<input type=\"hidden\" name=\"cartId\" value=\"$cartId\">");
       
    printf("<input type=\"hidden\" name=\"catId\" value=\"$prodweight\">");        
       
       
    printf("<a href=\"index.php?prodID=$prodID\"><img border=\"0\" src=\"$imageProdFolder/$prodThumbImg\"");
       
    printf("alt=\"View $prodShortDescENG in detail.\"  onerror=\"this.src='images/empty.gif'\"></a></td><td>");

       
    printf("<b><font color=\"#0000FF\" size=\"1\" style=\"text-decoration: underline; font-weight: bold\"><a href=\"index.php?prodID=$prodID\">$prodShortDescENG   [detail]</a></font></b><br>$prodLongDescENG ...</b></font></a><br>");
       
       
    printf("<br><b><font color=\"#15B4FF\" size=\"2\">$ $usdollarcost</font></b>");
       
    printf("<font face=\"verdana\" color=\"#CCCCCC\" size=\"1\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;£ $gbpoundcost &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;€ $eurocashcost</font>");
       
    if(isset(
    $_COOKIE["adminID"]))
    {
    echo 
    "&nbsp;&nbsp;&nbsp;<a href=\"adminshop/index.php?searchcrit=ProductID&prodID=$prodID\">edit</a></font><br>";
    // echo "&nbsp;&nbsp;&nbsp;<a href=\"webComm.php?$dbase|product|ProductID|$prodID\" target=\"appframe\">AppQ</a></font><br>";

    }
    else
    {
    echo 
    "<br>";
    }     
       
       
    printf("<font face=\"Arial\" size=\"1\" color=\"#CCCCCC\">Ref:  $prodID</font><br>");
       


    //   printf("<b><font color=\"#15B4FF\" size=\"2\">$ $prodPrice&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></b><font face=\"Arial\" size=\"1\" color=\"#CCCCCC\">Ref:  $prodID<br>");
         
      
       
    printf("<b><font color=\"#0000FF\" size=\"1\">Qty:&nbsp;</font><select size=\"1\" name=\"qty\"><option value=\"1\">1</option><option value=\"2\">2</option><option value=\"3\">3</option><option value=\"4\">4</option><option value=\"5\">5</option></select>&nbsp;");
       


                  
    $cartisdone "0";
                  if((
    $prodOptions != "noQvalue") ||  (strlen($prodOptions) > 2)){
                  include 
    "$docroot"/adminshop/adminapp/optionrules.php";
                  }else {
                          
    printf("<input type=\"hidden\" name=\"itemoptions\" value=\"noQvalue\">");
                     }
                  

       
    printf("&nbsp;&nbsp;<input type=\"submit\" value=\"Add to Cart\" name=\"a1\"></form>\n"); 
       
    printf("</td></tr></table>");
       echo 
    "<table border=\"0\" width=\"100%\"><tr><td width=\"100%\"><hr size=\"1\" color=\"#EAF4FF\"></td></tr></table>";

    }
                  
    mysql_free_result($result);
              
    mysql_close($db);
    echo 
    "<table border=\"0\" cellpadding=\"5\"><tr><td><a href=\"java script:history.go(-1);\"><br>&lt;-- go back</a></p>";




    }

    </script>
    -------------------------------------------------------------------------------- 


    HERE THE HTML CODE I LIKT TO USE


    <TABLE width="50%" border="0" cellspacing="0" cellpadding="0">
    <TR>
    <TD>
    <TABLE BGCOLOR="#FFFFFF" width="100%" border="0" cellspacing="10" cellpadding="1">
    <TR>
    <TD ALIGN="CENTER">
    <IMG SRC="laptopsmall.GIF" ALIGN="middle"><BR><BR>
    <A HREF="#"><FONT CLASS="fontpagetext"><b>Product Name</b></FONT><BR>
    <FONT CLASS="fontpageprice">Price:----</FONT></A></td>
    <TD ALIGN="CENTER">
    <IMG SRC="laptopsmall.GIF" ALIGN="middle"><BR><BR>
    <A HREF="#"><FONT CLASS="fontpagetext"><b>Product Name</b></FONT><BR>
    <FONT CLASS="fontpageprice">Price:----</FONT></A></td>
    <TD ALIGN="CENTER">
    <IMG SRC="laptopsmall.GIF" ALIGN="middle"><BR><BR>
    <A HREF="#"><FONT CLASS="fontpagetext"><b>Product Name</b></FONT><BR>
    <FONT CLASS="fontpageprice">Price:----</FONT></A></td>
    </TR></TABLE>

    If this can be done i like to know how to call Different Products?
    I try ever thing i can't gite it to work all i'am giting is like it is now.
    Can anyone help me out?

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    sure. Use a $counter variable, and when it reaches a multiple of three then echo out </tr><tr>.

    This should start a new row.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    knightjt02's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2003
    Posts
    22

    Question I Need Help Setup A Table in PHP For Calling Different PRODU

    Ok I'am new to this what do you mean?

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    I am guessing you did not write the script yourself then? And do you have much experience of PHP?
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    knightjt02's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2003
    Posts
    22

    Question I Need Help Setup A Table in PHP For Calling Different PRODUCTS ?

    No I did not write the script and not much.

  6. #6
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Okey-doke.

    To start with, do you want to learn more PHP? Its worth doing, as you could write your own script from scratch that works exactly the way you wish.

    What I (vaguely) suggested was based around that fact that the script above loops through all the records in the database, and producing output for each record.

    PHP Code:
     while ($myrow mysql_fetch_array($result)) {
    // HTML OUTPUT ETC GOES HERE

    Now a counter would be a variable that is incremented every time the loops goes round -

    PHP Code:
    $count 1;
     while (
    $myrow mysql_fetch_array($result)) {
    // HTML OUTPUT ETC GOES HERE
    $count++;

    Now the tricky bit is to figure out that every time you get to a multiple of three, echo something extra (in our case, </tr><tr> to force a new row)

    PHP Code:
    $count 1;
     while (
    $myrow mysql_fetch_array($result)) {
    // HTML OUTPUT ETC GOES HERE
    if (!ereg("."$count 3)) {
    echo 
    "</tr><tr>";
    }

    $count++;

    Now, I have not tested the above code, I do not know if it works! It is just an example of the idea I had in my head. Its basically saying that if you divide $count by 3, and the result does not contain a decimal place, then echo out.

    Have a play, hope that helps.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread