PHP - Make A Pic From A Directory Clickable To A Url From My Database
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 Similar TutorialsThis one im took from php Code: [Select] print "<form action='registration.php' method='post'onsubmit='return msg();'>"; print "Your message:<br>"; print "<textarea name='message' cols='40' rows='2'></textarea><br>"; print "<a onClick=\"addSmiley(':)')\"><img src='smile.gif'></a> "; print "<a onClick=\"addSmiley(':(')\"><img src='blush.gif'></a> "; print "<a onClick=\"addSmiley(';)')\"><img src='images/wink.gif'></a> "; print "<input type='submit' name='submit' value='Set Name'></form>"; print "<script language=\"Java Script\" type=\"text/javascript\">\n"; print "function addSmiley(a)\n"; print "{\n"; print "document.form.message.value += a;"; print "document.form.message.focus();\n"; print "}\n"; print "</script>\n"; print "<br><br>"; and i converted it to html Code: [Select] <html> <form action='registration.php' method='post'> Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <a onClick=\"addSmiley(':)')\"><img src='smile.gif'></a> <a onClick=\"addSmiley(':(')\"><img src='blush.gif'></a> <a onClick=\"addSmiley(';)')\"><img src='images/wink.gif'></a> <input type='submit' name='submit' value='Set Name'></form> <script type="text/javascript">+"\n" function addSmiley(a)+"\n" { "\n" document.form.message.value + = a document.form.message.focus()+"\n" } "\n" </script> "\n" <br> <br> </html> but that html problem is im cannot integrate the javascript im means canot click the smiley button la may i know what is wrong I'm trying to make my text and images into clickable links. The images and text are in a database so its getting really tricky for me since I'm new to PHP. I've tried many different ways without success. Here is a snippet of the code I'm working with. As you can see, I'm also working with an image re-sizer. I would really like to make those images and text clickable links(i.e. Title). Any help is appreciated! if ($res) { while ($newArray = mysqli_fetch_array($res, MYSQLI_ASSOC)) { $detail = $newArray['id']; $photo = $newArray['photo']; $id = $newArray['title']; $price = $newArray['price']; list($width) = getimagesize($photo); // set the maximum width of the image here $maxWidth = 100; if ($width > $maxWidth) echo "<p><img alt=\"Image\" width=\"$maxWidth\" src=\"$photo\" />"; echo "Title:".$id." Price:".$price."<br/"; Hi, I have a blog page I am working on and I am trying to make some enhancements that I need some help with. In MySQL I have a table with id, title and post. In my page display I want to enable the user to click on the title and display a post on it's own so the URL would look like www.mysite.com/blog/?id=1 or something like that. Here is the PHP function to display the post from MySQL. all on one page. function GetBlogPosts($inId=null, $inTagId =null) { if (!empty($inId)) { $query = mysql_query("SELECT * FROM blog_posts WHERE id = " . $inId . " ORDER BY id DESC LIMIT 2"); } else if (!empty($inTagId)) { $query = mysql_query("SELECT blog_posts.* FROM blog_post_tags LEFT JOIN (blog_posts) ON (blog_post_tags.postID = blog_posts.id) WHERE blog_post_tags.tagID =" . $tagID . " ORDER BY blog_posts.id DESC"); } else { $query = mysql_query("SELECT * FROM blog_posts ORDER BY id DESC"); } $postArray = array(); while ($row = mysql_fetch_assoc($query)) { $myPost = new BlogPost($row["id"], $row['title'], $row['post'], $row['postfull'], $row["author_id"], $row['date_posted']); array_push($postArray, $myPost); } return $postArray; } I want to display 3 clickable images in a single row which repeats as long as there is data in the database, so far it is displaying a single clickable image from the database. below is all the code.. <table width="362" border="0"> <?php $sql=mysql_query("select * from `publication` GROUP BY `catsue`") or die(mysql_error()); $num=mysql_num_rows($sql); while($rowfor=mysql_fetch_array($sql)) { $cat=$rowfor['catsue']; $pic=mysql_query("select * from `category` where `catsue`='$cat'") or die(mysql_error()); $picP=mysql_fetch_array($pic); $base=basename($picP['title']); ?> <tr> <td width="352" height="88"><table width="408" border="0"> <tr> <td width="113" rowspan="5"><a href="archive_detail.php?id=<?php echo $rowfor['id'];?>&category=<?php echo $rowfor['catsue'];?>"><img src="ad/pic/<?php echo $base;?>" width="100" height="100" border="0"/></a></td> <td width="94">Title</td> <td width="179" height="1"><?php echo $rowfor['catsue'];?> </td> </tr> <tr> <td> </td> <td width="179" height="3"> </td> </tr> <tr> <td> </td> <td width="179" height="8"> </td> </tr> <tr> <td> </td> <td width="179" height="17"> </td> </tr> <tr> <td> </td> <td width="179" height="36"> </td> </tr> </table></td> </tr> <?php }?> </table> Hi All I am trying to set up a system that where a user sets up an account the system automatically sets up a new directory and inserts template files into it. I understand mkdir is something to do with it. Does anyone know how to go about this please? thanks Hi guys, I've got a snippet of code that's supposed to make a new directory with the user's unique ID (member_id) in the database. I have the code here but I get a myriad of errors including the infamous "at line 1 error, and the directory does not create. Please help me!! //Create Directory $queryString2 = $_SERVER['QUERY_STRING']; $query2 = "SELECT member_id FROM members WHERE $queryString2 = $row[activation]"; $result2 = mysql_query($query2) or die(mysql_error()); mkdir("/home/gafferzo/www/members/clubs/" . mysql_result($result2,0), 0777); I have been looking around and have not been able to find any useful information on this. I am trying to transfer files from a folder in the directory to a table in a database. Eventually they will be images but for right now I am just trying to get text files to transfer. Any help/code/ideas would be a lot of help. This is going to be triggered a button on a page by the way. Hello All, I have a contact directory database. It has all the employees of my company (name, phone, email, department, building, etc). Say on one page I have the Marketing Department, and I want to say: "The Marketing Department Director is ________" How would I assign that value from the database? Do I want to put in a unique "keyword" field in the database, but then how would I store all the values automatically on the page? I see pages where I would want to list the Marketing Director, and his secretary, then another page with the Sales Director, and his secretary, etc.... all with being able to change the values in the database, and it changing across all the pages instantly. Do I need to say on every page "select * from database where keyword = marketingdirector" and then store that result as a variable? It seems unpractical to repeat that a few times for each different person I want to list. Is there a better way to do this then I'm thinking? Thanks all!
I have a form on which the filepond plugin send the file manually
Look here if(empty($_POST['image'])) { echo 'add file!'; } $myimage = $_POST['image']; $myimage = str_replace('data:image/png;base64,', '', $myimage); $myimage = str_replace(' ', '+', $myimage); $decode = base64_decode($myimage); $myfile = $_SERVER['DOCUMENT_ROOT'].'/mages/' . uniqid() . '.png'; //now put the file file_put_contents($myfile, $decode);
Hi, I've read a lot of places that it's not recommended to store binary files in my db. So instead I'm supposed to upload the image to a directory, and store the link to that directory in database. First, how would I make a form that uploads the picture to the directory (And what kinda directories are we talking?). Secondly, how would I retrieve that link? And I guess I should rename the picture.. I'd appreciate any help, or a good tutorial (Haven't found any myself). Hi guys, I've been working on a script for a while now, and I'm sure it doesn't look great and all, and it's probably really messed up.. But right now I've finally got it working! There's only 1 thing I'd really like to add.. Searching through & listing of remote directories! The directories I'm trying to list have directory listings enabled, and I think it *should* be possible. I just have no clue how. Here's my current code in a beautiful mix of HTML and PHP: <? $border_size = "0"; function returner($what) { $what=explode("/",$what); $tps=count($what); $what=$what[$tps-1]; return $what; } $page_url= ""; $home_url=returner(__FILE__); if(isset($_GET['q'])) { $qtext=$_GET['q']; } else { $qtext=""; } function getdirsize($directory, $format=FALSE) { $size = 0; if(substr($directory,-1) == '/') { $directory = substr($directory,0,-1); } if(!file_exists($directory) || !is_dir($directory) || !is_readable($directory)) { return -1; } if($handle = opendir($directory)) { while(($file = readdir($handle)) !== false) { $path = $directory.'/'.$file; if($file != '.' && $file != '..') { if(is_file($path)) { $size += filesize($path); } elseif(is_dir($path)) { $handlesize = getdirsize($path); if($handlesize >= 0) { $size += $handlesize; } else { return -1; } } } } closedir($handle); } if($format == TRUE) { if($size / 1048576 > 1) { return round($size / 1048576, 1).' MB'; } elseif($size / 1024 > 1) { return round($size / 1024, 1).' KB'; } else { return round($size, 1).' bytes'; } } else { return $size; } } if(isset($_GET['type'])){ $type=$_GET['type']; } else { $type="new"; } $textures=0; $models=0; $avatars=0; $seqs=0; $sounds=0; foreach (glob("textures/*.jpg") as $texture){ $textures++; } foreach (glob("models/*.zip") as $model){ $models++; } foreach (glob("avatars/*.zip") as $avatar){ $avatars++; } foreach (glob("seqs/*.zip") as $seq){ $seqs++; } foreach (glob("sounds/*.zip") as $sound){ $sounds++; } ?> <!DOCTYPE html> <html> <head> <title>ObjectPath Search</title> <style type="text/css"> #wrapper { width: 850px; margin: 30px auto 30px auto; padding: 10px; } body { color:#C6C6C6; background:#1E1E1E; /* margin:0; padding:0; */ overflow-x:hidden; } #tabs { font: 85% "Trebuchet MS", sans-serif; } .left { float: left; } .right { float: right; } a:link, a:visited, a:active { color: #3DB015; text-decoration: none; } a:hover { color: #00E0FF; } h2 { color: #3DB015; padding-bottom: 0.2em; font-size: 110%; } ul#icon {margin: 0; padding: 0;} ul#icon li {margin: 1px; position: relative; padding: 1px 0; cursor: pointer; float: left; list-style: none;} ul#icon span.ui-icon {float: left; margin: 0 1px;} </style> <link type="text/css" href="http://objects.jk-hosting.com/search/css/black-tie/jquery-ui-1.8.2.custom.css" rel="stylesheet" /> <script type="text/javascript" src="http://objects.jk-hosting.com/search/js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="http://objects.jk-hosting.com/search/js/jquery-ui-1.8.2.custom.min.js"></script> <script type="text/javascript"> function formHandler(form){ var URL = document.form.site.options[document.form.site.selectedIndex].value; window.location.href = URL; }; $(function(){ // Tabs $('#tabs').tabs(); }); </script> </head> <body> <div id="wrapper"> <div id="tabs"> <!-- Tabs start --> <ul> <li><a href="#tab-search">Search</a></li> <li><a href="#tab-list">List Objects</a></li> <li><a href="#tab-info">OP info</a></li> </ul> <div id="tab-search"><!-- Searchtab start --> Please enter a string to search for, and choose a folder to search in. <br /><br /> <form name="Search"> <input type='hidden' value='search' name='type'> <input value='<? print $qtext; ?>' type='text' name='q'> <select name='map'> <option selected='selected' value='models'>Models</option> <option value='avatars'>Avatars</option> <option value='textures'>Textures</option> <option value='seqs'>Seqs</option> <option value='sounds'>Sounds</option></select> <input type='submit' value='Search'> </form> </div> <!-- Searchtab end --> <div id="tab-list"><!-- Listtab start --> Please pick a folder to browse. <br /><br /> <form name="form"> <select name="site" onChange="javascript:formHandler()"> <option value="#">Look in folder...</option> <option value="<? print $page_url; ?>?type=list&map=models">Models</option> <option value="<? print $page_url; ?>?type=list&map=avatars">Avatars</option> <option value="<? print $page_url; ?>?type=list&map=textures">Textures</option> <option value="<? print $page_url; ?>?type=list&map=seqs">Seqs</option> <option value="<? print $page_url; ?>?type=list&map=sounds">Sounds</option> </select> </form> </div> <!-- Listtab end --> <div id="tab-info"><!-- Info tab start --> The OP currently contains: <br /><br /> <table> <tr><td><b><? echo $models; ?></b></td> <td>Models</td></tr> <tr><td><b><? echo $avatars; ?></b></td> <td>Avatars</td></tr> <tr><td><b><? echo $textures; ?></b></td> <td>Textures</td></tr> <tr><td><b><? echo $seqs; ?></b></td> <td>Seqs</td></tr> <tr><td><b><? echo $sounds; ?></b></td> <td>Sounds</td></tr> </table> </div> <!-- Info tab end --> </div> <!-- Tabs end --> </div> <!-- Start PHP generated content --> <? if($type=="search" || $type=="list") { $M=$_GET['map']; if($type=="search") { $Q=$_GET['q']; $empty="Nothing found with <b>\"" . $Q . "\"</b> in it's name.<br />\nPlease make a more general search query, or try a different folder.\n\n"; } else { $Q=""; $empty='This folder is empty'; } if($M=="textures") { $ext="jpg"; } else { $ext="zip"; } $i=0; print "<hr>\n"; $endfile=array(); $endsize=array(); $endsize2=array(); foreach (glob($M."/*".$Q."*.".$ext) as $filename) { $filename = explode(".", $filename); $filename=$filename[0]; $filename = explode("/", $filename); $filename=$filename[1]; $i++; $endfile[$i]=$filename; if($ext=="jpg") { $endfile[$i]="<a name='".$endfile[$i]."' href='".$pageurl."?type=view&name=".$endfile[$i]."&folder=".$M."&from=".$type."&addon=".$Q."'>".$endfile[$i]."</a>"; } $endsize[$i]=$size; $endsize2[$i]=$size2; } if($i != 1) { print "<b>".$i."</b> items were found.\n<hr>\n"; } else { print "<b>".$i."</b> item was found.\n<hr>\n"; } echo("<table width='100%' border='" . $border_size . "' cellspacing='0' cellpadding='0' >\n"); if($i!=0) { for ($t = 1; $t < $i; $t++) { $thumbfile = $M."/".$endfile[$t].'.jpg'; if(file_exists($thumbfile)) { $thumbnail = "<a name='".$endfile[$t]."' href='".$page_url."?type=view&name=".$endfile[$t]."&folder=".$M."&from=".$type."&addon=".$Q."'><ul id='icon'><li class='ui-state-default ui-corner-all' title='".$endfile[$t]."'><span class='ui-icon ui-icon-image'></span></li></ul></a>"; } else { $thumbnail = ""; } if($t=="1") { echo("<tr><td width='10%'>Number</td><td width='3%'><ul id='icon'><li class='ui-state-default ui-corner-all' title='".$endfile[$t]."'><span class='ui-icon ui-icon-image'></span></li></ul></td><td width='60%'>Name</td></tr>\n"); } echo("<tr><td>" . $t . "</td><td>".$thumbnail."</td><td>" . $endfile[$t] . "</td></tr>\n"); flush(); } $thumbfile = $M."/".$endfile[$t].'.jpg'; if(file_exists($thumbfile)) { $thumbnail = "<a name='".$endfile[$t]."' href='".$page_url."?type=view&name=".$endfile[$t]."&folder=".$M."&from=".$type."&addon=".$Q."'><ul id='icon'><li class='ui-state-default ui-corner-all' title='".$endfile[$t]."'><span class='ui-icon ui-icon-image'></span></li></ul></a>"; } else { $thumbnail = ""; } echo("<tr><td>" . $t . "</td><td>".$thumbnail."</td><td>" . $endfile[$t] . "</td></tr>\n"); } print "</table>\n"; if($i=="0") { print $empty; } } elseif($type=="view") { $filename=$_GET['name']; $folder=$_GET['folder']; if($_GET['from']=="list"){ $addon="?type=list&map=".$folder."#".$filename; } if($_GET['from']=="search"){ $addon="?type=search&q=".$filename."&map=".$folder."#".$filename; } print"<center><a href='".$home_url."'>Home</a></center>"; print "<hr>\n<center><img src='".$folder."/".$filename.".jpg'></img></center>\n<hr>\n<br />\n<a href='".$page_url."".$addon."'>Previous Page</a>\n"; } $htmlshow=""; if($_GET['type']=="returnOPfile") { if(isset($_GET['split'])) { $splitter=$_GET['split']; } else { $splitter=" | "; } if(isset($_GET['html'])) { $htmlshow="<br />"; } foreach (glob("textures/*.jpg") as $texture){ if(isset($_GET['size'])) { $size=$splitter.filesize($texture); } $texture = explode("/", $texture); $texture=$texture[1]; print "textures".$splitter.$texture.$size."\n".$htmlshow; } foreach (glob("models/*.zip") as $model){ if(isset($_GET['size'])) { $size=$splitter.filesize($model); } $model = explode("/", $model); $model=$model[1]; print "models".$splitter.$model.$size."\n".$htmlshow; } foreach (glob("avatars/*.zip") as $avatar){ if(isset($_GET['size'])) { $size=$splitter.filesize($avatar); } $avatar = explode("/", $avatar); $avatar=$avatar[1]; print "avatars".$splitter.$avatar.$size."\n".$htmlshow; } foreach (glob("seqs/*.zip") as $seq){ if(isset($_GET['size'])) { $size=$splitter.filesize($seq); } $seq = explode("/", $seq); $seq=$seq[1]; print "seqs".$splitter.$seq.$size."\n".$htmlshow; } foreach (glob("sounds/*.zip") as $sound){ if(isset($_GET['size'])) { $size=$splitter.filesize($sound); } $sound = explode("/", $sound); $sound=$sound[1]; print "sounds".$splitter.$sound.$size."\n".$htmlshow; } } ?> <!-- End PHP generated content --> </body> </html> So right now my question to you PHP freaks is, can you please help me edit my script so I can search through a remote directory? *This* is one of the directories I wish to be able to search through & list.. Thanks in advance. Edit; It might help if you know what the site currently looks like. *Click* 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 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 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 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. |