Jump to content

tristanlee85

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tristanlee85's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm trying to add some modifications to my phpBB site by getting information from a database on one of my other sites. It's pulling information correctly, but I'm having trouble adding more information to a variable. I actually so confused myself that it's going to be hard for me to explain this in propper terms. Here is the code I have so far: [code=php:0]$query1="SELECT * FROM xcart_products WHERE add_date < '$today_date' && add_date > '$minus_five_days'"; $result1=mysql_query($query1); $numrows1=mysql_numrows($result1); //echo $numrows1; if ($numrows1 < 2) { $latest_prod = "Latest product: "; } else { $latest_prod = "Latest products: "; } $count = 0; while ($count < $numrows1) { $product=mysql_result($result1,$count,"product"); //echo $product." - "; $product_id=mysql_result($result1,$count,"productid"); //The above variables will be included in: <a href="http://store.plastikracing.net/product.php? productid={PRODUCT_ID}" target="_blank">{PRODUCT}  <img src="http://store.plastikracing.net/product_images/t_{PRODUCT_ID}.jpg" width="50" height="38"></a><br> $count++; } [/code] Bascially, in that loop, there is a chance that "numrows1" is going to be greater than 1. Here is what I want to do. Let's say there is 1 row in the database that matches the criteria. The information pulled from that row will be inserted into a variable like so: [code=php:0]$display_product = "<a href='http://store.plastikracing.net/product.php?productid=".$product_id." target='_blank'>".$product."<img src='http://store.plastikracing.net/product_images/t_".$product_id.".jpg' width='50' height='38'></a><br>";[/code] Now, let's assume there are 2 products that match the criteria. I would like the 2nd product to be added to the end of the $display_product like so: [code=php:0]$display_product = "<a href='http://store.plastikracing.net/product.php?productid=".$product_id[0]." target='_blank'>".$product[0]."<img src='http://store.plastikracing.net/product_images/t_".$product_id[0].".jpg' width='50' height='38'></a><br><a href='http://store.plastikracing.net/product.php?productid=".$product_id[1]." target='_blank'>".$product[1]."<img src='http://store.plastikracing.net/product_images/t_".$product_id[1].".jpg' width='50' height='38'></a><br>";[/code] Does anyone have any suggestions? I was looking at using implode(), but I'm no too familiar with arrays.
  2. Oh wow. Perfect! Thanks for the help. I was trying to use if() statements and everything else. Thank you so much. Sometimes the simpliest things get you.
  3. To start, I'm going to post the code of my issue. [code]//Used for the employee menu and evaluations left to be completed $employee_list="SELECT * FROM employees"; $total_employees=mysql_query($employee_list); $employees_left=mysql_numrows($total_employees); $eval_remaining=($employees_left - $eval_complete); //Evaluates a variable for 'state' == 1 $state = mysql_query('SELECT state FROM employees'); $state_menu=mysql_result($state,"state"); if ($employees_left==0) {     echo "<option>--No employees in database--</option>"; } else { $count=0; while ($count < $employees_left && $state_menu == '1') { $name_menu=mysql_result($total_employees,$count,"name"); echo "<option>$name_menu</option>"; $count++; } }[/code] Basically, my main focus is on this: [code=php:0]while ($count < $employees_left && $state_menu == '1')[/code] What I'm wanting it to do is only run through the while() loop while $count < $employees_left and as long as the $state of the employee is "1". For example, I have the following in my table: [code]Name    | State ------------------ Tristan |   1 Ben     |   0 Aaron   |   1[/code] In this case, I would only want it to echo out [code]<option>Tristan</option>[/code] and [code]<option>Aaron</option>[/code] and not echo out [code]<option>Ben</option>[/code] since Ben's state is "0". I'm sure you guys can think of something to make this simple and make it work. I've been up too long. Thanks in advance.
×
×
  • 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.