PHP - Big Picture, Whats The Best Way To Make A Database Driven Menu ?
Whats the best way to make a database driven menu ?
Right now I have a db that looks like id | boats | Inshore id | boats | Offshore id | boats | Bay Boats and so on I'm think of going to database 1 id-1 | boats database 2 id | 1 | inshore or would a multideminsional array work best. My goal is to have the short term format be Boats Inshore Offshore Bay Boats and in the long term a format whose style I can change later, I wanted to get ideas from people in the know and have done this before. Thanks in advance Similar TutorialsHello, I am making a small CMS and I having some trouble with making a dynamic menu. I am wondering for a few days how I should make this menu system. I have the follow MySQL table: Code: [Select] CREATE TABLE `pages` ( `id` int(4) unsigned NOT NULL AUTO_INCREMENT, `time` varchar(10) DEFAULT NULL, `lastby` varchar(2) DEFAULT NULL, `order_id` varchar(2) DEFAULT NULL, `text` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB; Now I would like to have a menu system as following that I make menu's in a menu table with a name and a menu ID and that I could place those pages as parent or as subparent. How could I manage to turn my theory into reality? How do I do I prevent a broken image icon if there is no image? Here is my code: Code: [Select] <?php if ($_POST){ $county = $_POST['county']; } $con = mysql_connect("localhost","",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("", $con); $imageLocation = $row['imageurl1']; $result = mysql_query("SELECT * FROM places WHERE `county` = '".mysql_real_escape_string($county)."' order by `date_created` DESC"); if ( mysql_num_rows($result) > 0 ) { echo "<strong>Click Headers to Sort</strong>"; echo "<table border='0' align='center' bgcolor='#999969' cellpadding='3' bordercolor='#000000' table class='sortable' table id='results'> <tr> <th> Title </th> <th> Borough </th> <th> Town </th> <th> Phone </th> <th> Rooms </th> <th> Bath </th> <th> Fees </th> <th> Rent </th> <th> Image </th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr> <td bgcolor='#FFFFFF' style='color: #000' align='center'> <a href='classified/places/index.php?id=".$row['id']."'>" . $row['title'] . "</a></td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['county'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['town'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['phone'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['rooms'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['bath'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['feeornofee'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['rent'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'><img src=user/". $row['imageurl1'] ." width='50'></td> </tr>"; } echo "</table>"; print_r($apts); } else { echo "<p> </p><p> </p> No Results <br /><p> </p><FORM><INPUT TYPE='button' VALUE='Go Back' onClick='history.go(-1);return true;'></FORM> and Refine Your Search <p> </p><p> </p>"; } ?> Thanks in advance Hi people. I'm very new to PHP and am building the www.airfieldcards.com website for pilots to use free of charge. I have made a subdomain "m" which I am going to use for the "mobile version" of the site. I have made the "information" showing card but need to make a menu as the first thing that the user sees when he logs onto the site via a mobile device (iPhone / android etc) It needs to take "username" from the database (this is the airfield name) Then list them in order (alphabetically) Then make a link out of the word to the ?"id" from the DB and display the relevant card. In other words. When the user visits http://m.airfieldcards.com the are greeted with the following Abbots Bromley Alderney Andrewsfield Here is the php that shows the actual "phone" version of the card. Code: [Select] <?php $host = 'localhost'; $usr = "username"; $password = 'thepassword'; $db_name = 'TheNameOfTheDB'; function cr($string){ $clean_string = str_replace("rn","<BR>",$string); return $clean_string; } if (!isset($id)) $id = $_GET['id']; mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $read_query = "select * from users where user_id = '$id'"; $results = mysql_query($read_query); $rs = mysql_fetch_array($results); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- body table { } body,td,th { font-size: x-large; } --> </style> <body> Airfield Name: <? echo $rs["username"]; ?> <table width="480" border="1" cellspacing="0" cellpadding="2"> <tr> <td bgcolor = #E6F8EB><span class="xx_large_font">Height Above</span></td> <td bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["height_above"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #dbeff8><span class="xx_large_font">Mb Difference</span></td> <td bgcolor = #dbeff8><div align="right"><span class="xx_large_font"><strong><? echo $rs["mb_diff"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #E6F8EB><span class="xx_large_font">Alternative</span></td> <td bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["alternative"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #dbeff8><span class="xx_large_font">General Location</span></td> <td bgcolor = #dbeff8><div align="right"><span class="xx_large_font"><strong><? echo $rs["general_location"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #E6F8EB><span class="xx_large_font">Grid Reference</span></td> <td bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["location_grid"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #dbeff8><span class="xx_large_font">Runway Num</span></td> <td bgcolor = #dbeff8><div align="right"><span class="xx_large_font"><strong><? echo $rs["runway_numbers"]; ?></strong></span></div></td> </tr> <tr> <td width="240" bgcolor = #E6F8EB><span class="xx_large_font">Circuit Dir</span></td> <td width="240" bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["circuit_direction"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #dbeff8><span class="xx_large_font">Cirtuit Height</span></td> <td bgcolor = #dbeff8><div align="right"><span class="xx_large_font"><strong><? echo $rs["circuit_height"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #E6F8EB><span class="xx_large_font">Runway m</span></td> <td bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["runway_length"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #dbeff8><span class="xx_large_font">OHJ Height</span></td> <td bgcolor = #dbeff8><div align="right"><span class="xx_large_font"><strong><? echo $rs["ohj_height"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #E6F8EB><span class="xx_large_font">Surface</span></td> <td bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["surface"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #dbeff8><span class="xx_large_font">Radio Freq</span></td> <td bgcolor = #dbeff8><div align="right"><span class="xx_large_font"><strong><? echo $rs["radio_frequency"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #E6F8EB><span class="xx_large_font">Callsign</span></td> <td bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["radio_callsign"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #dbeff8><span class="xx_large_font">Type</span></td> <td bgcolor = #dbeff8><div align="right"><span class="xx_large_font"><strong><? echo $rs["radio_type"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #E6F8EB><span class="xx_large_font">Other Radio</span></td> <td bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["other_radio"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #dbeff8><span class="xx_large_font">Fuel</span></td> <td bgcolor = #dbeff8><div align="right"><span class="xx_large_font"><strong><? echo $rs["fuel"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #E6F8EB><span class="xx_large_font">Landing Fee</span></td> <td bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["landing_fee"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #dbeff8><span class="xx_large_font">Opp Hrs</span></td> <td bgcolor = #dbeff8><div align="right"><span class="xx_large_font"><strong><? echo $rs["operating_hours"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #E6F8EB><span class="xx_large_font">Maintenance</span></td> <td bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["maintenance"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #dbeff8><span class="xx_large_font">Hangarage</span></td> <td bgcolor = #dbeff8><div align="right"><span class="xx_large_font"><strong><? echo $rs["hangarage"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #E6F8EB><span class="xx_large_font">Parking</span></td> <td bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["parking"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #dbeff8><span class="xx_large_font">Food</span></td> <td bgcolor = #dbeff8><div align="right"><span class="xx_large_font"><strong><? echo $rs["food"]; ?></strong></span></div></td> </tr> <tr> <td bgcolor = #E6F8EB><span class="xx_large_font">School</span></td> <td bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["school"]; ?></strong></span></div></td> </tr> <tr> <td colspan="2"><span class="xx_large_font">Remarks:<? echo $rs["remarks"]; ?></span></td> </tr> <tr> <td colspan="2"><span class="xx_large_font">Warnings:<? echo $rs["warnings"]; ?></span></td> </tr> <tr> <td bgcolor = #E6F8EB><span class="xx_large_font">Website</span></td> <td bgcolor = #E6F8EB><div align="right"><span class="xx_large_font"><strong><? echo $rs["weblinks"]; ?></strong></span></div></td> </tr> <tr> <td width="240" bgcolor = #dbeff8><span class="xx_large_font">Operator</span></td> <td width="240" bgcolor = #dbeff8><div align="right"><span class="xx_large_font"><strong><? echo $rs["operator"]; ?></strong></span></div></td> </tr> </table> <p class="xx_large_font"> </p> <p> </p> </body> </html> </html> Any help would be really appreciated. Thanks in advance. I am trying to write out a calendar style html table with data in each cell, and with a column on the left that shows the times. Basically it should look like this when written out to the webpage: Time Mon Tues Wed Thur Fri Sat 8:00 data data2 9:30 data3 data4 10:00 data5 data6 11:00 data7 data8 The times on the left will vary each month, and the 'data' (these are actually fitness classes held each month) will appear on various days of the week. There is no need to toggle from one month to the next and such, it's just a listing of the current month to display the classes held on which days and at which times. Very easy to do statically in html, but a bit more challenging dynamically. Using MySQL, the table that holds the data looks like this: Code: [Select] schedule_id class_time class_title day_order 1 08:00 data 1 2 08:00 data2 3 3 09:30 data3 2 4 09:30 data4 4 5 10:00 data5 3 6 10:00 data6 5 7 11:00 data7 1 8 11:00 data8 3 The day_order field corresponds to the weekday - Mon is 1, Tues is 2, etc. My query looks like this: Code: [Select] SELECT schedule_id, class_time, class_title, day_orderFROM `class_schedule` order by class_time, day_order Here is the html/ php code to write it out: Code: [Select] <table border="0" cellpadding="2" cellspacing="0" width="625"> <tr> <td class="calheader">Time</td> <td class="calheader">Mon</td> <td class="calheader">Tue</td> <td class="calheader">Wed</td> <td class="calheader">Thu</td> <td class="calheader">Fri</td> <td class="calheader">Sat</td> <td class="calheader">Sun</td> </tr> <? $i=0; $first_time = ""; while($i<$num_rows){ $sid = mysql_result($sql,$i,"schedule_id"); $ctime = mysql_result($sql,$i,"class_time"); $cdate = mysql_result($sql,$i,"CURDATE()"); $strtime = date("h:i:s",$cdate.$ctime); $ctitle = stripslashes(mysql_result($sql,$i,"class_title")); $order = mysql_result($sql,$i,"day_order"); if ($ctime != $first_time){ if (isset($first_time)){ echo ""; } if ($first_time == ""){ echo "<tr>\n"; echo "<td class=\"timecell\">". $ctime ."</td>\n"; } $first_time = mysql_result($sql,$i,"class_time"); } $j = 1; while ($j<8 && $first_time != ""){ if ($order == $j){ $thetitle = $ctitle; } else { $thetitle = " "; } echo "<td class=\"calcell\">". $thetitle ."</td>\n"; $j++; } unset($first_time); if (!isset($first_time)) { echo "</tr>\n"; } $i++; } unset($ctitle); unset($thetitle); unset($weekday); unset($sid); unset($clink); unset($order); mysql_close(); The above code sort of works, but the trouble I am having is that it is creating a new table row for each class, even if they occur at the same time slot. It should be putting them on the same row, to the right of the time slot across the days of the week. If anyone could assist, that would be wonderful - I am really stuck with this... Thanks Sorry for my bad english but i hope you would understand my query. How can i set 404 not found for database driven pages..? I am using header("HTTP/1.0 404 Not Found"); in my 404 error page and ErrorDocument 404 /404.html, whereas 404.html is my error page. i have an URL http://www.example.com/folder/my-test-for-url-95/ which is opening correctly because it has existence on database. but when i am opening http://www.example.com/folder/my-test-for-url-951/ which has existence on database is also opening without any information but i want here a 404 not found page. How can i do so. Thanks Hi all, I am wondering what the best way to do this is... Take GoDaddy for example, if your domain is about to expire you will get an automatic email. I am wanting to do something similar, If someone orders a Soap Dispenser, I want to send an email (if they accept to receiving emails on the order) each month asking/reminding them to top up on soap. I have been reading but cant find anything adequate, I have seen something about Cron Jobs, but never heard of this before, please could you point me in the right direction. Thanks in advance. Peter I'm trying to do sort of like a web comics site where you make your own comic, add your own characters, text bubbles, backgrounds, etc. Problem is I have no idea how I could output that. Can I somehow make "a print screen out of whatever the browser returns" ?. Can anyone help? Can some please help. I have a mysql database. In the table I have added a colum for pictures as VARCHAR and inserted the locations of the pictures. The pictures are in a seperate folder. I am trying to display the images in a php file but can't see where I am going wrong. images are uploaded to a directory and the sql database contains the filename. I added 'url' field and am trying to link the two I have used on of the posts to help me adapt some script however I'm not sure I have the syntax right. The image in DW live view looks ok and I get the link finger ok but when previewed in browser the image is not shown at all or any link. Any ideas <? echo !empty($row['pic']) ? "<a href=\"{$row['url']}\" <img src=\"js/images/{$row['pic']}\">" : ''; ?> it echos out to a table Mike I have a database table of plants, one of chemicals, one of products, one of illnesses. Each table is connected, for example lets say opium poppies. They contain the chemical morphine. Morphine is used in painkiller products. Its used to treat pain and other illnesses. On the opium poppy page, I want to list all the chemicals found in the poppy. All the products (i.e. opium, laudanum) made from the poppy. All the illnesses which are treated with the poppy. Users need to be able to edit this page, and enter chemicals, products or illnesses that are related to this plant. They also need to be able to edit the info on the page.
Making database relations is a pain in the ass with CakePHP. I don't want to waste any more time so I'm thinking maybe making it as a wordpress plugin is the way to go. How would you go about this? Is there an easier way than wordpress, like a better CMS, or framework? If I use wordpress, should I do all the DB interactions with AJAX to avoid having to interact with the DB through wordpress (this gave me massive trouble in the past since I had my data in an external db)?
hi i have daily data table it's contain ID, Date, and Rain i need to make a new table but tendays period ,,, any clues ,,, will be very greatfull thanks a lot ,,, I am new to PHP and currently trying to develop a website... i am stuck at one place. Lets say i'm a user(mrX) that has 4 types of car that are Ferrari, Lamborghini, Evo and BMW. So, i will register to the system about my details and all of my car info such as their cc, transmission, plat number, engine capacity. Then, i will log on into the system and after log on, there will be a drop down list. If i pick Ferrari for example, under the drop down list there will be all the information about the car. The same on the other car also. Hello folks I am new to php and I have been trying to put together a database that a user can search and choose from the results. I have managed to make this script by copying code from google searches and trial and error. The script so far has been tested and works. The hard part is the code for choosing from the results, I have tried some things but I have been far from the mark, the thing is I can't get my head around the problem, if the first field is a number which is unique to each row, how can I pick that up in a php argument. I have tried making the first field an href link to send that number to a different table which would collect the results of the users choices, but I'm just not sure what to put in the code. Could someone throw me a lifeline here I've searched for hours on google to find any code that looks like it would work with no luck. // Get the search variable from URL $var = @$_GET['a'] ; $trimmed1 = trim($var); //trim whitespace from the stored variable $var = @$_GET['b'] ; $trimmed2 = trim($var); $var = @$_GET['c'] ; $trimmed3 = trim($var); $var = @$_GET['d'] ; $trimmed4 = trim($var); $var = @$_GET['e'] ; $trimmed5 = trim($var); $var = @$_GET['f'] ; $trimmed6 = trim($var); //connect to your database mysql_connect("localhost","root",""); //(host, username, password) //specify database mysql_select_db("a2149809_MV") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "SELECT * FROM `table` WHERE `field1` LIKE \"%$trimmed1%\" AND `field2` LIKE \"%$trimmed2%\" AND `field3` LIKE \"%$trimmed3%\" AND `field4` LIKE \"%$trimmed4%\" AND `field5` LIKE \"%$trimmed5%\" AND `field6` LIKE \"%$trimmed6%\" order by `field1`"; $result=mysql_query($query); $num=mysql_num_rows($result); mysql_close(); <table width="100%" border=2 cellspacing=2 cellpadding=2> <tr><form name="form" action="" method="get"> <td colspan="6"><input type="submit" name="Submit" value="Search" /> </td> </tr> <tr> <td><input type="text" name="a" value="" size="4" /></td> <td><input type="text" name="b" value="" size="40" /></td> <td><input type="text" name="c" value="" size="3" /></td> <td><input type="text" name="d" value="" size="10" /></td> <td><input type="text" name="e" value="" size="10" /></td> <td><input type="text" name="f" value="" size="10" /></td> </form></tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"Field1"); $f2=mysql_result($result,$i,"Field2"); $f3=mysql_result($result,$i,"Field3"); $f4=mysql_result($result,$i,"Field4"); $f5=mysql_result($result,$i,"Field5"); $f6=mysql_result($result,$i,"Field6"); ?> <tr> <td><?php echo $f1; ?></td> <td><?php echo $f2; ?></td> <td><?php echo $f3; ?></td> <td><?php echo $f4; ?></td> <td><?php echo $f5; ?></td> <td><?php echo $f6; ?></td> </tr> <?php $i++; } ?> </table> What I want to do is what is in the shown in the table. I want to only get the Math subject and order the units from unit 1 (UI) to the last available unit in the database; after this, under each unit, to show the homework related to each unit. I have tried to save it into an array with mysql_fetch_array but it stores the row that involves one unit. I want all the units and only the units with their homework under them.
My database is attached to this post in a txt file.
hope someone can help.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin tÃtulo</title> </head> <body> <form action="" method="post" name="form1" id="form1"> <table width="200" border="1"> <tr> <td>Subject:</td> <td>Math</td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td>UI</td> <td>UI</td> <td>UII</td> <td>UIII</td> <td>UII</td> <td>...</td> </tr> <tr> <td>Home work</td> <td>Math work1</td> <td>Math work2</td> <td>Math work3</td> <td>Math work4</td> <td>Math work5</td> <td>...</td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=347193.0 I currently have an HTML form where the options for a certain drop-down menu are hard-coded. Instead, I want to use PHP to... 1. Look up the values in a column (cities) in a MySQL table (locations) 2. Make those values the only options in the dropdown menu. Any ideas how I would do this? This is what I have so far. <label for="city">What is your destination city?</label> <select class="form-control" id="city" name="city"> <?php //connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); //grab the city names from the MySQL table $query = "SELECT cities FROM locations"; $res = mysqli_query($dbc, $query); while ($data = mysqli_fetch_assoc($res)) { echo '<option value="'.$data['cities'].'">'.$data['cities'].'</option>'; } //close the db connection mysqli_close($dbc); ?> </select> Using unordered list, <ul> Reading from XML file, Taking menu name from database, Is there other system to make dropdown navigation menu? Which is the best way to make dropdown navigation menu? I also want to show the sitemap of navigation.How can it be done? How can I make a CSS3 menu like the menu placed in below website? Welcome :: Bardia Textile Co. I mean top menu that has fancy effect. please at least tell me the name of these kinds of menu in the way I could find some more examples. Hi im new to php and I need help making webpage that queries a mysql database based on a 3 check boxes and displays results on the same page or on another page. The table being queried has 4 columns, name, gps, wifi, bluetooth. So for example a row in the table would be like, samsung galaxy s2, yes, yes, yes. The idea is for it to be a website that will display phones according to their features. So the idea is depending on if the boxes were ticked the samsung galaxy would be displayed as a result. So i need some help understanding how to make this. Some1 gave me the code below in attempt to help me (im not sure it works or not) but im not sure how fully use it, ie what pages i need to make and how i create the connection to the mysql database, and how to use the query that they wrote to display the results thanks code: Code: [Select] <form action="?do=filter" method="post"> <table cellspacing="0" cellpadding="3" border="1"> <tr> <td>GPS<input type="checkbox" name="gps" value="checked"></td> <td>Wifi<input type="checkbox" name="wifi" value="checked"></td> <td>Bluetooth<input type="checkbox" name="bluetooth" value="checked"></td> </tr> <tr><td><input type='submit' name='filter' value='Filter'></td></tr> </table> </form> </html> <?php function filterMe($filter){ if(isset($_POST[$filter])){ return "Yes"; }else{ return "No"; } } if(isset($_POST['filter'])){ echo "Gps - " . filterMe('gps'); echo " Wifi - " . filterMe('wifi'); echo " Bluetooth - " . filterMe('bluetooth'); } ?> All you need to do is use a query something like SELECT name,gps,wifi,bluetooth FROM `product` WHERE `gps`='".filterMe('gps')."' AND `wifi`='".filterMe('wifi')."' AND `bluetooth`='".filterMe('bluetooth')."' i need to upload files to a different folder dependint on option in form, make thumbnails, and store title and src for image and thumb in database table dependant on category. i think i'm pretty close, but there's still something wrong. Here is my upload form : Code: [Select] <form enctype="multipart/form-data" action="upload.php" method="POST"> Photo: <input type="file" name="photo"><br> Category: <select name="cat"> <option value="weddings">Weddings</option> <option value="music">Music</option> <option value="portraits">Portraits</option></select> Title: <input type="text" name="title"><br> <input type="submit" value="Upload photo"> </form> form processed by upload.php : Code: [Select] <?php require "db.php"; //Get form info $name=$_POST['name']; $title=$_POST['title']; $category=$_POST['cat']; $pic=($_FILES['photo']['name']); //set target dir source file width height $target = $cat."/"; $src = $target . basename( $_FILES['photo']['name']); $destination = $cat."/thumbs"; $thumbsrc = $destination . basename( $_FILES['photo']['name']); $width = 200; $height = 200; header("content-type: image/jpeg"); $src_img = imagecreatefromjpeg("$src"); $srcsize = getimagesize("$dest"); $dst_img = imagecreatetruecolor($width, $height); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $width, $height, $srcsize[0], $srcsize[1]); imagejpeg($dst_img); //Unstert into db mysql_query("INSERT INTO `$category` VALUES ('$name', 'Stitle', '$src, $thumbsrc')") ; //move photo if(move_uploaded_file($_FILES['photo']['tmp_name'], $fulltarget)) { //Ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //not ok echo "Sorry, there was a problem uploading your file."; } ?> call a script from main page Code: [Select] <div class="gallery"> <?php include "weddings/get.php" ?> </div> <div class="gallery"> <?php include "music/get.php" ?> </div> get.php displays links Code: [Select] <?php include "db.php"; $cat = weddings; $q = "SELECT id, title, src, thumbsrc FROM $cat"; $result = $mysqli->query($q) or die(mysqli_error($mysqli)); if ($result) { echo "<ul id='photos'> \n"; while ($row = $result->fetch_object()) { $title = $row->title; $src = $row->src; $thsrc = $row->thumbsrc; $id = $row->id; echo "<a href='$src' class="lightbox" rel="$cat" title="$name - $title"><img src='$thsrc' id='$id' alt='$name' /></a>": } echo "</ul>"; } ?> I think i'm going along the right sort of path, but i'm not sure. |