1. Список говнокодов пользователя denis90

    Всего: 22

  2. PHP / Говнокод #7627

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $result = $db->query("SELECT w.wine_name as wine_name,(SELECT wine_type FROM wine_type WHERE wine_id_type = w.wine_type) as wine_type,
    	                             (SELECT variety FROM grape_variety WHERE variety_id = (SELECT variety_id FROM wine_variety WHERE wine_id = w.wine_id)) AS wine_variety,
    								 w.year as wine_year, (SELECT winery_name FROM winery WHERE winery_id = w.winery_id) as winery,
    								 (SELECT region_name FROM region WHERE region_id = (SELECT region_id FROM winery WHERE winery_id = w.winery_id)) as winery_region,
    								 (SELECT cost FROM inventory WHERE wine_id = w.wine_id) as wine_cost,
    								 (SELECT on_hand FROM inventory WHERE wine_id = w.wine_id) as wine_quantity
    	                      FROM wine w
    						  WHERE w.wine_id = '$id'");

    достаём данные из базы для страницы редактирования ...

    denis90, 23 Августа 2011

    Комментарии (10)
  3. PHP / Говнокод #7617

    +156

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    <?php
    	include_once "database.php";
    	
    	$db = NewPDO();
    	$search = $db->prepare("SELECT w.wine_name as wine_name, w.year as wine_year, gv.variety as wine_variety, wn.winery_name as winery_name,r.region_name as region_name
    							FROM wine w
    							JOIN wine_variety wv ON w.wine_id = wv.wine_id
    							JOIN grape_variety gv ON wv.variety_id = gv.variety_id
    							JOIN winery wn ON w.winery_id = wn.winery_id JOIN region r ON wn.region_id = r.region_id
    							WHERE w.wine_name LIKE :in_wine_name AND wn.winery_name LIKE :in_winery_name AND r.region_name LIKE :in_region_name
    							ORDER BY w.wine_name ASC , w.year ASC , gv.variety ASC");
    	$wine_name = '%'.htmlspecialchars($_GET["wine"]).'%';
    	$winery_name = '%'.htmlspecialchars($_GET["winery"]).'%';
    	$region = '%'.htmlspecialchars($_GET["region"]).'%';
    	
    	$search->bindValue(':in_wine_name',$wine_name,PDO::PARAM_STR);
    	$search->bindValue(':in_winery_name',$winery_name,PDO::PARAM_STR);
    	$search->bindValue(':in_region_name',$region,PDO::PARAM_STR);
    	
    	$search->execute();
    	echo "<table>";
    	if ($search->columnCount() > 0)
    	{
    		echo "<tr align=\"center\">
    				<th>
    					Wine
    				</th>
    				<th>
    					Year
    				</th>
    				<th>
    					Variety
    				</th>
    				<th>
    					Winery
    				</th>
    				<th>
    					Region
    				</th>
    			  </tr>";
    		while($row = $search->fetch())
    		{
    			echo "<tr align=\"left\">
    					<td width=\"80\">
    						".$row["wine_name"]."
    					</td>
    					<td width=\"50\">
    						".$row["wine_year"]."
    					</td>
    					<td width=\"90\">
    						".$row["wine_variety"]."
    					</td>
    					<td width=\"230\">
    						".$row["winery_name"]."
    					</td>
    					<td>
    						".$row["region_name"]."
    					</td>
    				  </tr>";
    		}
    		echo "<tr>
    			  	<td colspan=\"5\">
    					".$search->rowCount()." records found matching your criteria.
    				</td>
    		      </tr>";
    	}
    	else
    	{
    		echo "<tr><td>No records match your search criteria</td></tr>";
    	}
    	echo "</table>";
    ?>

    Вот такой вот полнотекстовый поиск с выводом результата

    denis90, 23 Августа 2011

    Комментарии (16)