Jump to content

Darkwoods

Members
  • Posts

    88
  • Joined

  • Last visited

Everything posted by Darkwoods

  1. Hey here is my code im trying to redirect the index.php to index.php?id=1 the way i have done it doesn't look really good is there a better way to do it please? im trying to redirect to id=1 because otherwise i wont be able to echo out anything... id 1 is default category so is there a way to tell it if $id is empty echo from id 1? <?php $id = $_GET['id']; if($id == ''){ echo "<meta http-equiv=Refresh content=0;url=index.php?id=1>"; } $result = mysql_query("SELECT * FROM pages WHERE id='$id' ",$connect); while($row = mysql_fetch_assoc($result)) { echo $row['anything1']; echo $row['anything2']; } ?>
  2. thanks it is working just as i wanted Karma
  3. oh thanks man i dont need to use the while if($id != '6') will do the whole job great maybe i should just use more my head to figure out PHP thanks anyway
  4. Hey thanks... here is the code im using.. the code you wrote makes alot of sense but how can imlpent it with the while when i already have ($row = mysql_fetch_array($result2)? <?php echo '</h1><img class="section_img" src="images/index_img.jpg" alt="Menu" />'; $result = mysql_query("SELECT * FROM cat_foodmenu ",$connect); while ($row = mysql_fetch_array($result)) { $id_c = $row['id']; $title = $row['title']; echo '<h1><a name="'. $title .'">'. $title .'</a></h1>'; echo ''; $result2 = mysql_query("SELECT * FROM food_menu WHERE cat_id='$id_c' ORDER BY id ASC",$connect); while ($row = mysql_fetch_array($result2)) { $id = $row['id']; $food_title = $row['title']; $price = $row['price']; $info = $row['info']; $cat = $row['cat_id']; echo '<div class="recipe"><span class="name_of_the_recipe">' .$food_title.'</span>'; if ($cat != 7){ echo '<div class="price">$' . $price .'</div>'; } else { echo '<div class="price2">$' . $price .' <font style="color:#333; font:Verdana; font-size:9px;">Per Person</font></div>'; } echo '<div class="recipe_bg"> </div><div class="clear_container"></div></div>'; echo '<p>(' . $info .')</p><br />'; } } ?>
  5. hey how do i stop echoing a specific id for example i dont want the id 6 to display with the others ids thanks
  6. ah thanks it worked just one question u cant seperate the values somethin like that $var == 'value1', 'value2', 'value3', etc in PHP? anyway thanks
  7. im trying to have different values but i don't know how to separate them, i tried with , . 'AND' but still not working with me i googeled it but could not find any examples thanks <?php if($var == 'value1' or 'value2' or 'value3') { echo 'Lets echo it!'; } ?>
  8. this did the trick for me thanks for your help premiso <?PHP if($wineinfo == NULL){ echo '<br />'; } elseif($wineinfo != NULL){ echo '<p>(' . $wineinfo .')</p><br />'; } ?>
  9. well the thing is im trying to avoid some html if it is null
  10. i tried this but still something is wrong it is not working <?PHP if($wineprice2 != NULL){ echo '<div class="price"> $' . $wineprice2 .'</div>'; } ?>
  11. im trying to echo data from mysql but i don't want to echo it if it is null/empty anyone have a good idea how to do it? something like this if $var != null echo '$var'; lol sorry i know im a tottaly noob thx
  12. Thank you guys, phpfreals.com helped me again today thanks for being so nice with helping people this code works perfect
  13. Hello im trying to disable some specific $id values from showing in the page lets say the values are number 2 and 5 that i want to disable and all the rest to show as normal... i want the data to be on the page when i have it only on the id number 2 or 5 $id = $_GET['id']; if($id == '2,5') { } how can i do that please? here is the code im using $result = mysql_query("SELECT * FROM cat_foodmenu ",$connect); while($row = mysql_fetch_array($result)) { $id = $row['id']; $title = $row['title']; echo '<h1>'. $title . '</h1>'; echo '</h1><img class="section_img" src="images/index_img.jpg" alt="Menu" />'; $result2 = mysql_query("SELECT * FROM food_menu WHERE cat_id='$id' ORDER BY id ASC",$connect); while ($row = mysql_fetch_array($result2)) { $id = $row['id']; $food_title = $row['title']; $price = $row['price']; $info = $row['info']; echo '<div class="recipe"><span class="name_of_the_recipe">' .$food_title .'</span>'; echo '<div class="price">$' . $price .'</div>'; echo '<div class="recipe_bg"> </div><div class="clear_container"></div></div>'; echo '<p>(' . $info .')</p><br />'; } }
  14. hhaha thanks man i have been stuck with this over 4 hours thankssssss alot karma
  15. Hi im trying to sort my categories but i can't figure out how to do it so please i need help what im basically trying to do is to display the gategories this way: Category name -title -title Category name -Title -title i came so far with the code you can see, but i cant make it loop it just show the first category and its contents but the other categories doesn't show up <?php $result = mysql_query("SELECT * FROM cat_foodmenu ",$connect); while($row = mysql_fetch_array($result)) { $id = $row['id']; $title = $row['title']; echo '<h1>'. $title . '</h1>'; $result = mysql_query("SELECT * FROM food_menu WHERE cat_id='$title' ORDER BY id ASC",$connect); while ($row = mysql_fetch_array($result)) { $id = $row['id']; $title = $row['title']; $price = $row['price']; $info = $row['info']; echo '<div class="recipe"><span class="name_of_the_recipe">' .$title .'</span>'; echo '<div class="price">$' . $price .'</div>'; echo '<div class="recipe_bg"> </div><div class="clear_container"></div></div>'; echo '<p>(' . $info .')</p><br />'; } } ?>
  16. i got flash file swf and it take the data like text and image from a xml file okay? so what im asking how do i get my data from the database in an XML file how do i echo the text and image from the database when using XML file thanks
  17. Hey i got a flash news rotator and it take the data from an xml file... so i have to connect to the database in the xml file and echo the data in the xml file let say i want to SELECT FROM 'news', 'id' 'title'; and echo the title in xml can that be done if yes please could anybody guide me thanks
  18. Hey im trying to do a direction page where it open differently link direction pages every time somebody enter it.. like this for example any good hint on how to do this? <?php header( 'Location: http://www.site1.com/new_page.html' ) ; header( 'Location: http://www.site2.com/new_page.html' ) ; header( 'Location: http://www.site3.com/new_page.html' ) ; ?>
  19. hello i have a multitiple dropdown box in the edit page and i would like to how the selected options in the edit page here is the code: echo '<input type=hidden name="type_specialitydoc" value="multiselect"> <select size = "15" id="value_specialitydoc" name="value_specialitydoc[]" multiple > '; $dbquery2 = mysql_query("SELECT * FROM specialty_categories"); while ($dbrow2 = mysql_fetch_array($dbquery2)) { $id1 = $dbrow2['id']; $catname = $dbrow2['catname']; /* echo '<option style="font-weight:bold; color:#CCCCCC" value="'. $id1 .'"disabled="disabled">-'. $catname . '</option>'; */ echo '<optgroup label="'. $catname . '">'; $dbquery = mysql_query("SELECT * FROM specialty where speccat = $id1 ORDER BY name;"); while ($dbrow = mysql_fetch_array($dbquery)) { $id = $dbrow['id']; $name = $dbrow['name']; echo ' <option value="' .$id .'"> ' . $name .'</option> '; } } echo '</SELECT>'; thats how my database looks like: Table1: Maintable Column: id, field1, field2, SPECIALTY <<< (the values of the id from table specialty .catvalue) Table2: Specialty Column: id, name, catvalue Table3: Specialty_categories Column: id, catname
  20. <?php $sql = "SELECT id, name FROM specialty ORDER BY name"; $res = mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); echo "<SELECT MULTIPLE SIZE=9 value='multiselect' name='category'>\n"; echo "<option value=''>- select category -</option>\n"; $prev = ''; while (list($id, $name) = mysql_fetch_row($res)) { $gp = strtoupper($name{0}); if ($prev != $gp) { if ($prev) echo "</optgroup>\n"; echo "<optgroup label='$gp'>\n"; $prev = $gp; } echo "<option value='$id'>$name</option>\n"; } echo "</optgroup>\n</SELECT>\n"; ?> i hope somebody can help me with this im trying to have the categories in the optgroup and displaying all the fields that are related to this category im using 2 tables -cat .id .name -items .id .idcat .itemname i want the dropdown to display like this Cat1 -itemname1 -itemname2 Cat2 -itemname1 -itemname2 please help me thank you
  21. i am making it complicated lool here what i want to change in the code i want to display the categories in the optgroup thats what i meant
  22. okey guys i found a good code but i still need help from you here is the code: $sql = "SELECT id, name FROM specialty ORDER BY name"; $res = mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); echo "<SELECT MULTIPLE SIZE=9 value='multiselect' name='category'>\n"; echo "<option value=''>- select category -</option>\n"; $prev = ''; while (list($id, $name) = mysql_fetch_row($res)) { $gp = strtoupper($name{0}); if ($prev != $gp) { if ($prev) echo "</optgroup>\n"; echo "<optgroup label='$gp'>\n"; $prev = $gp; } echo "<option value='$id'>$name</option>\n"; } echo "</optgroup>\n</SELECT>\n"; ?> now what i want to change in this code is to select from table specialty_categories in the database and display the specialty table data to the related categories specialty_categories i hope someone can help with this pleaseee
×
×
  • 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.