Jump to content

Psycho

Moderators
  • Posts

    12,157
  • Joined

  • Last visited

  • Days Won

    129

Everything posted by Psycho

  1. I *think* $_POST['imagename'] is supposed to be an array of values? Also, the correct format for an INSERT query with multiple records is like this: INSERT INTO tableName (field1, field2) VALUES ('value1a', 'value1b'), ('value2a', 'value2b'), ('value3a', 'value3b') Plus you were not encasing the imageame value in single quotes in the query. I think what you want to do is something like this: $values = array(); foreach ($_POST['imagename'] as $imagename) { $values[] = "('6666', '{$imagename}')"; } $sql = "INSERT INTO image_list (ProductID, imagename) VALUES " . implode(', ', $values); mysql_query( $sql, $international);
  2. As Sasa just stated, I gave you the logic to do exactly what you want. Just modify the code I provided to generate a table. Personally I feel I provided a much more logical, better constructed page, but you decide to flip back to your method. Makes no sense to me why you would grab the first record and then do a do/while loop. Also, since you are only using three fields, change the query to only get those three. Without table: <?php require_once('Connections/hairstation.php'); mysql_select_db($database_hairstation, $hairstation); $query = "SELECT c.category, p.product, p.price FROM products p JOIN categories c ON p.categoryID = c.categoryID ORDER BY c.category, p.product"; $results = mysql_query($query, $hairstation) or die(mysql_error()); $currentCategory = ''; $outputHTML = ''; while($product = mysql_fetch_assoc($results)) { if($currentCategory!=$product['category']) { $currentCategory = $product['category']; $outputHTML .= "{$currentCategory}<br />\n"; } $outputHTML .= "{$product['product']} - {$product['price']}<br />\n"; } mysql_free_result($prices); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <?php echo $outputHTML; ?> </body> </html> Or with table <?php require_once('Connections/hairstation.php'); mysql_select_db($database_hairstation, $hairstation); $query = "SELECT c.category, p.product, p.price, p.id FROM products p JOIN categories c ON p.categoryID = c.categoryID ORDER BY c.category, p.product"; $results = mysql_query($query, $hairstation) or die(mysql_error()); $currentCategory = ''; $outputHTML = "<table width=\"500\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n"; while($product = mysql_fetch_assoc($results)) { if($currentCategory!=$product['catName']) { $currentCategory = $product['category']; $outputHTML .= " <tr><th colspan=\"4\">{$currentCategory}</th></tr>\n"; } $outputHTML .= "{$product['product']} - {$product['price']}<br />\n"; $outputHTML .= " <tr>\n"; $outputHTML .= " <td>{$product['product']}</td>\n"; $outputHTML .= " <td>{$product['price']}</td>\n"; $outputHTML .= " <td><a href=\"editProduct?id={$product['id']}\">Edit</a></td>\n"; $outputHTML .= " <td><a href=\"deleteProduct?id={$product['id']}\">Delete</a></td>\n"; $outputHTML .= " </tr>\n"; } $outputHTML .= "<table>\n"; mysql_free_result($prices); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <?php echo $outputHTML; ?> </body> </html>
  3. <?php require_once('Connections/hairstation.php'); mysql_select_db($database_hairstation, $hairstation); $query = "SELECT * FROM products p JOIN categories c ON p.categoryID = c.categoryID ORDER BY c.catName, p.prodName"; $results = mysql_query($query, $hairstation) or die(mysql_error()); $currentCategory = ''; $outputHTML = ''; while($product = mysql_fetch_assoc($results)) { if($currentCategory!=$product['catName']) { $currentCategory = $product['catName']; $outputHTML .= "<b>{$currentCategory}</b><br />\n"; } $outputHTML .= "{$product['prodName']}<br />\n"; } mysql_free_result($prices); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <?php echo $outputHTML; ?> </body> </html>
  4. Huh? You have statuses of 0, 1, 2, but then you state values for 0, 2, & 3??? In any event, you need to create another status to indicate that an image is in the process of being screened. So, when you pull the next image for a screener, you also set it's status so another screener will not get the same image. However, you would also need to account for those instances where a screener does not complete the screening process - otherwise the image would be stuck in limbo. Either a scheduled or manual event to reset all images in the being screened status to the not screened status. You could use statuses such as this: 0: In queue, Not screened 1: In the process of being screened 2: Rejected 3: Accepted But, I would use two different fields: Screened: 0/1 (0 - in queue, 1 being/has been screened) Accepted: 0/1 (0 - rejected, 1 accepted). You could then find images that got stuck in the screening process where Sreened = 1, but the accepted value is null.
  5. Yes, I DID see that. I was responding to your statements "I just noticed you can attach files ... I just noticed now that you can include files." Funny how you just noticed that today when I mentioned it yesterday. I already copied the code from your post yesterday. I just haven't had the time to sift through it.
  6. I think I may have misrread that. I thought there was some need for PHP processing (e.g. see if days were available). Yes, if you only need to calculate the days, then you would only need to use JavaScript.
  7. Well, that inner switch statement doesn't look right. Specifically the switch "value" $id = $_GET['id']; switch ($_GET['page'] = 'roster' && $_GET['id']) { case $id: echo ("Display info specific to ID"); break; default; echo ("Display main team page"); } The switch value is "($_GET['page'] = 'roster' && $_GET['id'])". So, whatever the result is of that will be compared against the switch cases. I'm not even sure what that "value" would return. You have an assignment and then and AND statement of another value $_GET['id']. The first part will return true and the second part will return the value of $_GET['id']. So, I think the result is just the value of $_GET['id']. Since, your first case value is $id (which you previously set to $_GET['id']), that will always be the result. You need to rethink your logic. Not really sure what you are trying to do there. I thin an IF/ELSE might be a better option.
  8. Form values can only be accessed by the PHP processor when the values are submitted. For example, by clicking a submit button and submitting the form - which would refresh the page. To submit the values without refreshing the page you will need to use AJAX. In this case use JavaScript to submit the values and receive the results. There are plenty of AJAX tutorials to get you started.
  9. Hmm, I don't have much experience with creating PDFs via PHP, but I have a TON of experience in creating dynamic PDFs via a web interface. This was a web-based application for the customers of a national printing company. However, we utilized the web forms along with PostScript code (the native language for PDF creation). We then ran the PostScript code through a Distiller to create the PDFs. I'm not certain, but I can probably guess why you are encountering some of the problems. 1. Fonts: In printing Fonts is one of the biggest headaches. If the font is not embedded into the PDF then the device rendering the PDF will replace the font with something else. So, if you create the PDF with a font available on your computer it will display fine on your computer but display differently on a computer without that font. There are some complexities around printing. I *think* that true type fonts can be sent from the printing computer to the printer, but that for non true-type fonts, the printer will need to have the font installed. 2. Page size: The horizontal size is most likely correct because a #10 envelope is pretty much the same with as an 8-1/2 x 11 page. I'm not sure why you are having problems with the vertical distance. When you open the PDF in Acrobat have you checked the dimensions in the properties and are they correct? If so, then the problem is probably a PC to Printer issue and not the PDF itself. Have you tried printing an envelope from Word to see if it prints correctly?
  10. There is obviously something wrong in your code. Attach the files you are using and we can take a look at the full code.
  11. You are using it wrong. Check the manual: http://php.net/manual/en/domnode.removechild.php It should be: $parentObject->removeChild($childObject);
  12. No, it is not a web server problem. The problem has to be that you are doing something outside of the code you posted previously. As I stated, I took the three blocks of code you posted in the initial message and ran it successfully. The only thing I had to do was set a value for $num to specify which question/answers I wanted displayed. To be honest, the code you are using is pretty crappy which has made me reluctant to try and fix your problem. However, the only thing I can think of which would cause your problem would be if you run this line with one value for $num shuffle_assoc($answers[$num]); And then run this with a different value for $num foreach ($answers[$num] as $answer) { $answer2 = str_replace($pattern,$replace,$answer); echo "<li><input type=\"radio\" id=\"$answer2\" value=\"$answer2\" name=\"answers\" />\n"; echo "<label for=\"$answer2\">$answer</label></li>\n"; } Since you never showed how you are setting $num, I can't really do more than guess.
  13. $title = preg_replace('/ /', '+', $row['title']); echo "<a href=\"http://www.mysite.com/search.php?query={$title}&search=1\">{$row['url']}</a>"; echo "<br>{$title} <br>{$row['description']} <br><br>";
  14. Which is exactly the same logic I provided except mine was in a function that is more flexible. Oh well.
  15. The error is pretty self explanatory. The PHP.ini file has localhost configured as the mail server and there isn't one. You need to have a mail server available in order to send email.
  16. You were almost there. You will need to run a foreach() on the array and check each value independantly. I'd use stristr for a case insensitive search function searchArray($search, $array) { foreach($array as $key => $value) { if (stristr($value, $search)) { return $key; } } return false; } $searchValue = 'arau.org'; $position = searchArray($searchValue, $arrayVar); if($position===false) { echo "{$searchValue} was not found."; } else { echo "{$searchValue} was found at position {$position}."; }
  17. Is the 2nd code block you posted in your first post the content for the "password-forgot.php" page or is it a separate file that is included? If so, it could be a problem in how you are including it. Try create a simple "Hello world" script in that directory and test it. Hello <?php echo "World!"; ?> What does that produce?
  18. You aren't going to have any PHP errors for that page because the PHP code isn't being processed!
  19. Using IN is like a multiple WHERE clauses. Example: SELECT * FROM users WHERE favoriteColor IN ('blue', 'green', 'red') That is logically the same as SELECT * FROM users WHERE favoriteColor == 'blue' OR favoriteColor == 'green' OR favoriteColor == 'red' In addition to using a comma separated list of values for the IN values you can also do a query. So, I used a query to get all the city values for the selected managers. The result is a query that grabs all the people records where their city is in the list of cities for the selected manager. The second query uses a simple JOIN. If you don't know how to use JOINs you need to learn. Without using JOINs you will be increasing your coding work and - most likely - the system overhead.
  20. I hope you realize that that page isn't blank!!! Check the source code for the page returned and you will see the PHP code. There is a serious problem here. Either the PHP is not getting processed or you are outputting the PHP.
  21. $output = "<a href=\"http://www.mysite.com/search.php?query={$row['title']}&search=1\">{$row['url']}</a>"; $output .= "<br>{$row['title']} <br>{$row['description']} <br><br>"; $output = preg_replace(' ', '+', $output); echo $output;
  22. SELECT * FROM people WHERE city = IN ( SELECT city FROM cities WHERE manager = 'joe' ) OR SELECT people.* FROM people JOIN city ON people.city = city.city WHERE cities.manager = 'joe'
  23. No, that is not the problem. The 0 is to set the index of the first question value to 0 (which is unnecessary). The questions and answers are indirectly "associated" via the parent array IDs. Which is one reason that is a poor implementation. The code he posted works as long as you set $num to the value of one of the available indexes. It is also a poor implementation because the code is using a custom function to randomize the answers instead of just using shuffle. The custom function is maintaining the index association, but it is not even used in the output so it is unnecessay overhead.
  24. I just copies all of the code you just posted and set $num to one of the values in the arrays and it works fine for me. Every time I refresh the page the answers are in a different order. Although that is a pretty poor implementation, IMHO.
×
×
  • 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.