Jump to content

Addos

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Addos's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. "Place in code tags please. " Ok gald that's done so now how about some real help! \o/
  2. Hi, I’m trying to update in insert into the ‘menu’ column of my database with the word ‘single’ if the checkbox is ticked and in the Form below but unfortunately it’s not updating it for me and is setting all the values in the ‘menu’ column on the database to 0. I have a few multiple checkboxes in this form and I just wanted to be able to update the database as per what the user ticks however as I’ve seen over a few searches on the net that the checkbox is like a button and doesn’t hold a value unless it’s ticked so it’s throwing all sorts of errors such as undefined index to name but a few. I’m quite new to all this and just can’t seem to figure out how to get around this. I have been at this since December and just can’t get my head around what’s missing. What I should point out is that if I change type="checkbox" to type="text" the from works a treat however I need to use checkboxes as letting the user input the word ‘single into the form is obviously a very risky method. Can anyone help me to figure out what I’m missing? Thanks very much for($i=0; $i < $totalRows_GetMenuUpdate; $i++) { if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { if($_POST["menu_bf"][$i] == ""){ $_POST["menu_bf"][$i] = 0;} $updateSQL = sprintf("UPDATE tbl_prdt SET menu='%s' WHERE cate_ID='%s'", $_POST['menu_bf'][$i], $_POST['id_bf'][$i]); mysql_select_db($database_, $); $Result1 = mysql_query($updateSQL, $) or die(mysql_error());} ?> <form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td><strong> title:</strong></td> <td><strong> Tick</strong></td> </tr> <?php do { ?> <tr valign="baseline"> <td><?php echo $row_GetMenuUpdate['category_Name']; ?></td> <td> <!-- if I use this to physically add the details it works so I know that the database query is working<input name="menu_bf[]" type="text" value="<?php //echo $row_GetMenuUpdate['menu']; ?>" size="3">--> <input type="checkbox" name="menu_bf[]" value="<?php echo $row_GetMenuUpdate['menu']; ?>" <?php if($row_GetMenuUpdate['menu'] == 'single'){ echo "checked=\"checked\"" .'/>'.'</td>'.'</tr>'; ?> <?PHP } else { echo '/>'.'</td>'.'</tr>'; } // End ?> </td> </tr> <input type="hidden" name="id_bf[]" value="<?php echo $row_GetMenuUpdate['category_ID']; ?>"> <?php } while ($row_GetMenuUpdate = mysql_fetch_assoc($GetMenuUpdate)); ?> <tr valign="baseline"> <td><input type="submit" value="Update record"></td> <td> </td> </tr> </table> <input type="hidden" name="MM_update" value="form1"> </form>
  3. I have been so close so many times to getting this to work but I keep getting the same problem. I wonder if you or anybody can take a look at my latest attempt and help me out. When I run the code below I end up with some extras </li></ul>. This is only when the secondary category ‘($xProduct['product_Name'] $xProduct['product_ID'])’ has no dynamic value but it goes on to produce a menu flyout anyway. So I need to not return the extra </li></ul> when the secondary category is null. Here is a working example of the exact problem my revised code produces. http://www.doggiematters.ie/so_close.php If you mouse over ‘Birthdays’ you’ll see the blank flyout appearing. This is the HTML output. As I say I have a few versions of this problem and just can’t seem to see how to strip these unwanted tags when not needed. Again thanks a mil B Code I’m using at the moment: <ul id="p7PMnav"> <?php $output = ''; mysql_select_db($database_doggies, $doggies); $xHeadings = mysql_query("SELECT * FROM tbl_prdtcategories WHERE category_archive = 0 "); while($xHeading = mysql_fetch_assoc($xHeadings)) { $output .= "<li>\n".'<a href="results.php?category=' . $xHeading['category_ID'] . '">' . $xHeading['category_Name'] .'</a>'."<ul>\n"; $xProducts = mysql_query("SELECT * FROM tbl_prdtcategories, tbl_products,tbl_prdtcat_rel WHERE product_ID = prdt_cat_rel_Product_ID AND product_Archive = 0 AND product_OnWeb = 1 AND category_ID = prdt_cat_rel_Cat_ID AND category_Name = '$xHeading[category_Name]' ORDER BY product_Name"); while($xProduct = mysql_fetch_assoc($xProducts)) { $output .= "<li>\n".'<a href="details.php?prodId=' . $xProduct['product_ID'] . '">' . $xProduct['product_Name'] .'</a>' ."</li>\n"; } $output .= "</ul></li>\n" ; } print $output; ?> </ul> This is what I need to return. <ul id="p7PMnav"> <li><a href="#" class="p7PMtrg">Petwear</a> <ul> <li><a href="obedience.php">Bonnie Blue Coat</a></li> <li><a href="law.php">Designer Chinese Jacket</a></li> </ul> </li> <li><a href="suppliers.php">Birthdays</a></li> </ul> This is what I'm getting <ul id="p7PMnav"> <li><a href="results.php?category=12">Petwear</a> <ul> <li><a href="details.php?prodId=40">Bonnie Blue Coat</a></li> <li><a href="details.php?prodId=31">Designer Chinese Jacket</a></li> </ul> </li> <li><a href="results.php?category=15">Birthdays</a><ul> </ul> </li> </ul> This is where things are going wrong in that this is what I want at this point of the script <li><a href="suppliers.php">Birthdays</a></li> </ul> but this is what I'm getting ie the <ul></ul></li></ul> should simply be </li></ul> <li><a href="results.php?category=15">Birthdays</a><ul> </ul> </li> </ul>
  4. Thanks for this. I've been at this all day and just can't see how to apply it to the PHP code I have as there are 2 loops in my code and my brain is overloaded. I can't see how to work with only one loop as there are many to many relationships in my database......
  5. Hello, I’m going crazy trying to figure out how do apply <ul> <li> tags to the PHP code down below. I need to be able to produce the following at the browser. <ul> <li><a href="#" class="p7PMtrg">Training & Education</a> <ul> <li><a href="#">Obedience Classes</a></li> <li><a href="#">The Law and your dog</a></li> </ul> </li> <li><a href="#">Pet Shop Supplies</a></li> </ul> The PHP code runs perfectly but I just need to apply the tags to it and can’t figure out how to do this. I know the logic is: If there is only one heading echo <li> … </li> else if there is one heading and a subcategory echo <ul> <li>…</li> <li>…</li> </ul> </li> But as I say I can’t figure out the logic of the code. Can anyone help? Thanks B <ul> <?php $output = ''; mysql_select_db($database_*****, $*****); $xHeadings = mysql_query("SELECT * FROM tbl_prdtcategories WHERE category_archive = 0 "); while($xHeading = mysql_fetch_assoc($xHeadings)) { $output = '<li>'.'<a href="results.php?category=' . $xHeading['category_ID'] . '">' . $xHeading['category_Name'] .'</a>' .'</li>'; $xProducts = mysql_query("SELECT * FROM tbl_prdtcategories, tbl_products,tbl_prdtcat_rel WHERE product_ID = prdt_cat_rel_Product_ID AND product_Archive = 0 AND product_OnWeb = 1 AND category_ID = prdt_cat_rel_Cat_ID AND category_Name = '$xHeading[category_Name]' ORDER BY product_Name"); while($xProduct = mysql_fetch_assoc($xProducts)) { $output .= '<ul>'.'<a href="details.php?prodId=' . $xProduct['product_ID'] . '">' . $xProduct['product_Name'] .'</a>' .'</ul>'; } print $output; } ?> </ul>
×
×
  • 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.