View Single Post
Old 03-07-2007, 06:37 AM   #22 (permalink)
JMareel
Recruit
 
Join Date: Feb 2007
Posts: 20
JMareel is on a distinguished road
Angry

OK I am really feeling lost now and uneducated in web coding terms.

I have a couple of questions for you.

1) The .txt file that contains my SQL code that creates and fills up my database should be kept on the server. What is considered the server then? my web site file/folder structure? or the host company's computer I publish and host my web site on?

2) I have been working with trial and error on understanding your code on the example web site you made and on the recent code blocks you wrote. I am feeling really lost in where I need to put your snippets of code and what they do ! Where exactly does
Code:
 /* select what we have in the database, and build the form for submitting */
  $categories = @mysql_query("SELECT * FROM categories ORDER BY id", $DB_LINK);
  while($category = @mysql_fetch_array($categories)){
    $item_count = 1;
    $body .= "<td valign='bottom'><font size='+2'><b>".$category['name']."</b></font> <input type='checkbox' name
='allbox".$category['id']."' onclick=\"checkAll('".$category['id']."');\" /> Check All
      <table border='0' cellspacing='0' cellpadding='0' width='100%' style='border: 1px solid rgb(12, 13, 119);'>
       <tr>
       ";
    $items = @mysql_query("SELECT * FROM items WHERE category=\"".$category['id']."\" ORDER BY id", $DB_LINK);
    while($item = @mysql_fetch_array($items)){
      if(!(($item_count++) %2))
        $body .= "</tr><tr><td valign='top'>
        "; /* only two items valigned within a category */
      else
        $body .= "<td valign='top'>";
      $body .= "<input type='checkbox' value='".$item['id']."' name='checkbox[".$category['id']."][]'><b>".$ite
m['name']."</b><br />
        ".$item['description']."</td>
        ";
    }
I have tried putting this after the head and the body of the Order page (page with tables and checkboxes) seperately and it doesn't seem to produce the desired result. Parts of the code end up showing up on the page.

And where exactly does this go?
Code:
if(isset($_POST['checkbox'])){
/* we were called through the 'submit' button
 * so we build the page accordingly
 */
  $categories = @mysql_query("SELECT id FROM categories ORDER BY id", $DB_LINK);
  $checked = $_POST['checkbox'];
  while($category = @mysql_fetch_array($categories)){
     foreach($checked[$category['id']] as $check){
       $res = @mysql_query("SELECT * FROM items WHERE id='$check'", $DB_LINK);
        while($row = @mysql_fetch_array($res)){
            /* do whatever with what is fetched, name, description, price, etc. */
        }
     }
  }
} 
I am not going to pretend to know something I don't so I am going to just ask outright. Can you put it in simple terms as to where exactly the blocks of code need to go? If I understand where to put them, then maybe I can understand how they are talking with each other and exchanging information. I apologize for maybe sounding so ignorant but this is truely baffling me.

The easiest thing so far that I have taught myself is how to write the code to create the database, insert data, and query data depending on my needs. This PHP and java, although not Chinese, is a little more difficult and added to the fact that the code needs to be inputted into a certain place in the source of the page. I hope I can pay you back one way or the other when I get my website published finally! One last question... would you rather continue this via email or keep it to this thread?

Much Appreciated,
-JM
JMareel is offline   Reply With Quote