Jump to content

bakhtn

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bakhtn's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. where do you suggest i post this then?
  2. I have got a new job as a Web Developer / Software Developer, I am finding it ok, but Im sure i can program better, any advice?? my manager is ok, but keeps on telling me I have to change this that the other. I wish she would be pleased with my work.
  3. I needed to have the sql statements with in the loop, I needed one row for each row of data , its a relational database. and the while loop does close in the actual script, Ive found a way round it, but why does this code produce a duplicate data in the file, and not when outputted to the browser. I just want to know why.
  4. //if any items in order table then display all items in order table $order_sql = "select * from orders"; $order_result = $handle -> query( $order_sql ); if($order_result->num_rows) { echo '<table bgcolor=#FFFF66 ><td>'; while ($order = $order_result -> fetch_assoc()) { $category_sql = "select category from category where category_id = {$order['category_id']}"; $category_result = $handle -> query( $category_sql ); $category_name = $category_result -> fetch_row(); $menu_sql = "select item_name from menu where item_id = {$order['item_id']}"; $menu_result = $handle -> query( $menu_sql ); $menu_name = $menu_result -> fetch_row(); echo $category_name[0] . ': ' . $menu_name[0] . ' ' . $order['size'] . ' ' . $order['type'] . ' ' . $order['amount'] . '<br />'; //insert data into order.txt file for print $file_insert = $category_name[0] . ": " . $menu_name[0] . " " . $order['size'] . " " . $order['type'] . " " . $order['amount'] . "\r\n"; @ $fp = fopen( 'order.txt', 'ab' ); if($fp) { fwrite( $fp, $file_insert, strlen( $file_insert ) ); } else { echo 'could not insert data into order.txt file for print, CLICK ON NEW ORDER'; } fclose($fp); }
  5. do you think i could have done it withou all those loops, any suggestions will be appreciated,
  6. solved it, databse had a duplicate name burger, although had a unique primary key, should not have cuased problems, i dont know why though, please can you explain to me why this happened.
  7. while ( $categories = $category_result -> fetch_assoc() ) { $menu_sql = "select * from menu where category_id = {$categories['category_id']}"; $menu_result = $handle -> query( $menu_sql ); $category2 = strtoupper($categories['category']); echo '<h3 id="' . $category2 . '">' . $category2 . '</h3>'; while ($menu = $menu_result -> fetch_assoc()) { echo $menu['item_name'] . ' '; $size_sql = "select distinct size from size where category_id = {$categories['category_id']} order by size desc"; $size_result = $handle -> query( $size_sql ); while ($size = $size_result -> fetch_row()) { echo $size[0] . ' '; } //get base type from base_type table for the pizza category $type_sql = "select type from base_type where category_id = {$categories['category_id']}"; $type_result = $handle -> query( $type_sql ); while ($type = $type_result -> fetch_row()) { echo $type[0] . ' '; } //get price for each item from menu if it is not null $price_sql = "select price from menu where item_name = '{$menu['item_name']}'"; $price_result = $handle -> query( $price_sql ); while ($price = $price_result -> fetch_row()) { echo $price[0] . ' '; if( is_null( $price[0] ) ) { //get price from size table if price is null in menu table; //$categories = $category_result -> data_seek(0); $size = "double"; $category_id = $categories['category_id']; $item_id = $menu['item_id']; $type = 'deep'; echo $menu['item_id']; $price_size_sql = "select price from size where size = '$size' and category_id = $category_id and item_id = $item_id"; $price_size_result = $handle -> query( $price_size_sql ); while ($price_size = $price_size_result -> fetch_assoc()) { echo " {$price_size['price']} "; } } } echo '<br />'; } echo '<br />'; } I get duplicate vakues for $category_id = $categories['category_id']; $item_id = $menu['item_id']; dont know whats wrong it works for pizzas but not burgers, please help me.
  8. theres an error in your SQL statement, run the sql seperately on the mysql monitor, and fix the error , that should sort it out.
×
×
  • 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.