another newbie ? if someone could please help

Discussion in 'PHP' started by SnoozZz, Feb 16, 2009.

  1. #1
    <?php
    $result = mysql_db_query($db, "SELECT * FROM gg_cart where billingemail = '".$_SESSION['aff_valid_account']."'");
    while ($record = mysql_fetch_array($result))
    
    //i did below to see my result, how do I use above to make below work if there are multiple results?
    $myresult = "$record[billingitem]";
    print "$myresult";
      {
    $result = mysql_db_query($db, "SELECT name, description, cat, now FROM gg_products where id = '$myresult'");
    while ($qry = mysql_fetch_array($result)) 
    {
    echo "<font face=arial><TABLE width=800 border=1 cellspacing=0 cellpadding=3>";
        echo "<tr><th>Item Name</th><th>Item Description</th>";
        echo "<th>Platform</th><th>price</th><th>Action</th></tr>";
          print "<tr>";
          print "<td><font size=2>";
          print "$qry[name]";
          print "</td>";
          print "<td><font size=2>";
          print "$qry[description]";
          print "</td>";
          print "<td><font size=2>";
          print "$qry[cat]";
          print "</td>";
    	  print "<TD><font size=2>";
          print "$qry[now]";
          print "</td>";
    	  print "<TD><font size=2>";
          print "delete";
          print "</td>";
          print "</tr>";
        }
        print "</TABLE>";
    
    }
    
    ?>
    PHP:
    please, any help
     
    SnoozZz, Feb 16, 2009 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    whats the problem?
     
    bartolay13, Feb 16, 2009 IP
  3. SnoozZz

    SnoozZz Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry, thought you would notice the line explaining the problem.

    I need to get the billing items from one table for a user, and then display the product details with data from another table.

    belo only gives me one result, where there should me more

    $result = mysql_db_query($db, "SELECT * FROM gg_cart where billingemail = '".$_SESSION['aff_valid_account']."'");
    while ($record = mysql_fetch_array($result))
    $q= $record[billingitem];
    print "$q";
      {
    $result = mysql_db_query($db, "SELECT * FROM gg_products where id = '$q'");
    while ($qry = mysql_fetch_array($result)) 
    {
    PHP:
     
    SnoozZz, Feb 16, 2009 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    try to put single qoute on the line
    $q= $record[billingitem];

    this must be
    $q= $record['billingitem'];
     
    bartolay13, Feb 16, 2009 IP
  5. SnoozZz

    SnoozZz Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    no matter what I do, I still only get one result. there should be more...
     
    SnoozZz, Feb 16, 2009 IP
  6. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #6
    You need to place your second while loop into the first one .. It will go through all items from order and at the same time will fetch this item info from products table !
     
    ActiveFrost, Feb 16, 2009 IP
  7. SnoozZz

    SnoozZz Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanx, but I think I'm just too much of noob.
    <?php
    $result = mysql_db_query($db, "SELECT * FROM gg_cart where billingemail = '".$_SESSION['aff_valid_account']."'");
    while ($record = mysql_fetch_array($result))
    $q= $record[billingitem];
    {
    	$result = mysql_db_query($db, "SELECT * FROM gg_products where id = '$q'");
    	while ($qry = mysql_fetch_array($result)) 
    		{
    			echo "<font face=arial><table width=800 border=1 cellspacing=0 cellpadding=3>";
        		echo "<tr><th>Item Name</th><th>Item Description</th>";
        		echo "<th>Platform</th><th>Price</th><th>Action</th></tr>";
          		print "<tr>";
          		print "<td><font size=2>";
          		print "$qry[name]";
          		print "</td>";
          		print "<td><font size=2>";
          		print "$qry[description]";
          		print "</td>";
          		print "<td><font size=2>";
          		print "$qry[cat]";
          		print "</td>";
    	  	print "<td><font size=2>";
    	  	print $cur;
          		print "$qry[now]";
          		print "</td>";
    	  	print "<td><font size=2>";
    	 	?>
    	 	<a href="?q=deletecart?id=<?php echo $q ; ?>">Delete</a>
    		<?php
          		print "</td>";
          		print "</tr>";
        		print "<tr><td>";
    		print "</table>";
    		print "</br>";
    		}
    }
    ?>
    
    PHP:
     
    SnoozZz, Feb 16, 2009 IP
  8. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #8
    $q before while loop starts .. needs to be inside it as your using fetch function. - this could be a reason why you've only 1 value ;)

    <?php
    $result = mysql_db_query($db, "SELECT * FROM gg_cart where billingemail = '".$_SESSION['aff_valid_account']."'");
    while ($record = mysql_fetch_array($result))
    {
        $q= $record[billingitem];
        $result = mysql_db_query($db, "SELECT * FROM gg_products where id = '$q'");
        while ($qry = mysql_fetch_array($result))
            {
                echo "<font face=arial><table width=800 border=1 cellspacing=0 cellpadding=3>";
                echo "<tr><th>Item Name</th><th>Item Description</th>";
                echo "<th>Platform</th><th>Price</th><th>Action</th></tr>";
              print "<tr>";
              print "<td><font size=2>";
              print "$qry[name]";
              print "</td>";
              print "<td><font size=2>";
              print "$qry[description]";
              print "</td>";
              print "<td><font size=2>";
              print "$qry[cat]";
              print "</td>";
            print "<td><font size=2>";
            print $cur;
              print "$qry[now]";
              print "</td>";
            print "<td><font size=2>";
            ?>
            <a href="?q=deletecart?id=<?php echo $q ; ?>">Delete</a>
            <?php
              print "</td>";
              print "</tr>";
                print "<tr><td>";
            print "</table>";
            print "</br>";
            }
    }
    ?>
    PHP:
    Another thing .. echo main table elements before all while loops, so it will not create a new table, but only new rows ;)
     
    ActiveFrost, Feb 16, 2009 IP
  9. SnoozZz

    SnoozZz Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    thanks, but no luck, i'm stumped
     
    SnoozZz, Feb 16, 2009 IP
  10. SnoozZz

    SnoozZz Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I'm still not getting it right, I'm trying to build a shopping cart around my existing site here Everything is basically done, if I can just get this to work.

    any help anyone???:rolleyes:
     
    SnoozZz, Feb 16, 2009 IP