PHP - Displaying Multiple Times
Hi guys, i got the following code i wrote which displays a small pop up on screen if the user has mail, and display a little icon. The problem is it displays a new icon for each new mail message. How can i make it so it only display 1 icon no matter how many unread mail the user has. Or even better if not too complicated display a number next too the image?
Code: [Select] <? require'xxxxxxxxxxxxxxxxx.php'; mysql_select_db("membership") or die( "Unable to select database"); $sql=("SELECT * FROM user_alerts WHERE user_id = '".($_SESSION['user_id'])."'") or die (mysql_error()); if ($query=@mysql_query($sql)) { if (mysql_num_rows($query) > 0) { while ($req=mysql_fetch_array($query)) { if ($req['messageRead'] == 'NO') { ?> <div> <img src="xxxxxxxxxxxxxx.png" width="32" height="32" alt="unread mail" /> <a href="http://www.xxxxxxxxxxxx/account=account">You have Mail!</a> <div id="boxes"> <div style="top: 199.5px; left: 551.5px; display: none;" id="dialog" class="window"> <h2>You have new mail!</h2> <br /> <p>Visit your account page to read it.</p> <br> <a href="#" class="close">Close Window</a> </div> <!-- Mask to cover the whole screen --> <div style="width: 1478px; height: 602px; display: none; opacity: 0.8;" id="mask"></div> </div> </div> <? } } } } You can ignore most of the div stuff but that's pretty much it. It should check my database for any entries with the users session id in the column called 'user_id'. and only show the image if it then finds an entry with 'NO' in the 'messageRead' column. It currently shows the images for each entry it finds. Thanks for any help Similar TutorialsFirst, Happy X-Mas to all! I want to do a form for entering dog-show results. On first site of form the user is able to enter how many dogs for each class (there are youth and open class for example) he want to insert. So on second site there will be formfields for every dog in every class, created with php. User should be able to take dogname from jquery autocomplete - this works for multiple fields. But i need the according id to the dogname - and actual only one id is given - the first one is changing by choosing from autocomplete in next fields... Data came from a json array like 0: {dogidindatabase: "9892", value: "Excalibur Khali des Gardiens de la Cour ",…} dogidindatabase: "9892" label: "<img src='../main/img/female.png' height='20'>Excalibur Khali des Gardiens de la Cour " value: "Excalibur Khali des Gardiens de la Cour " 1: {dogidindatabase: "15942", value: "Excalibur from Bandit's World Kalli",…} dogidindatabase: "15942" label: "<img src='../main/img/male.png' height='20'>Excalibur from Bandit's World Kalli" value: "Excalibur from Bandit's World Kalli"all i need is inside ... the script in form is <script type='text/javascript'> //<![CDATA[ $(function() { $(".dog").autocomplete({ source: "xxx.php", minLength: 3, select: function(event, ui) { $('#dogidindatabase').val(ui.item.dogidindatabase); } }); $["ui"]["autocomplete"].prototype["_renderItem"] = function( ul, item) { return $( "<li></li>" ) .data( "item.autocomplete", item ) .append( $( "<a></a>" ).html( item.label ) ) .appendTo( ul ); }; }); //]]> </script>and the form looked like <input type='text' name='dog' class='dog' value='".strip_tags(${'dogname' .($countbabymale+1)})."' size='35' data-required='true' /><br> <input class='readonly' readonly='readonly' type='text' id='dogidindatabase' name='dogidindatabase' size='5' />I changed in script and form id='dogidindatabase' to class, but it doesn´t work. Testsite is under http://www.wolfdog-d...how.php?lang=de (only german at first) - Insert a number (higher than 1) under baby 3-6 (first box, the others are not working for testing); submit to get to page 2; you see all post-variables (for testing). Try to insert a dogname in first input-field (choose "exc") and insert first one - the id is under dogname. In second dogname inputfield you can choose second dog - the id for the first one changes to id of seond one .... How can i get both for every dog? Greetings.. I have an ajax application i'm creating, that allows uploading images 1 at a time. That part works, and it works well. What I need to know now, is how would I go about converting the existing code I have, to change the sizing of it twice as well as renaming the images to something more website friendly. here is the code that i currently have, im sure this is easy but as i can't find any workable code on the google, i am lost as to how to modify it. so any help is appreciated. Code: [Select] <script language="JavaScript" type="text/javascript"> if(!/(\.bmp|\.gif|\.jpg|\.jpeg)$/i.test(window.parent.document.form1.filefieldname.value)) { window.parent.document.form1.filefieldname.value = ""; } else { <?php function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object); } } reset($objects); rmdir($dir); } } $folder = isset($_POST['folder']) ? $_POST['folder'] : ''; if($folder == '') { $rand = rand(5, 1000000); $folder = 'temp'.$rand; ?> window.parent.document.form1.folder.value = "<?php echo $folder; ?>"; <?php } if(!is_dir("../uploads/".$folder)) { mkdir('../uploads/'.$folder); } else { $rand = rand(5, 100000); $folder = $folder.''.$rand; mkdir('../uploads/'.$folder); } $image_name = $_FILES["filefieldname"]["name"]; $newname = "../uploads/".$folder."/".$image_name; move_uploaded_file($_FILES["filefieldname"]["tmp_name"], $newname); ?> var parDoc = window.parent.document; var A = window.parent.document.form1.upload_cnt.value; A = Number(A); B = 1; var cnt = A + B; if(cnt == '8') { window.parent.document.form1.filefieldname.disabled=true; } parDoc.getElementById('upload_cnt').value = cnt; parDoc.getElementById('files_list').innerHTML += '<br><a href="../uploads/<?php echo $folder.'/'.$_FILES['filefieldname']['name'] ?>"><?php echo $_FILES['filefieldname']['name'] ?></a>'; window.parent.document.form1.filefieldname.value=""; } </script> Okay I'm a newbie at PHP but was trying to write a counter for my website to count the amount of times a specific button is clicked. My desired outcome is as follows: If the form submit button "like" or "dislike" is clicked, get user's ip and check to see if it already exists in the database. If it exists, don't increment the count (of either button), otherwise log the ip and increment the count (of whichever button is clicked) by 1. Currently I've got the increment working (testing only the like button at the moment) and I've got the ip being stored into the database, but cannot get the comparison to work. Each time the button is clicked it adds the ip address into the database instead of disallowing it. Note: there are two different tables--one storing the ip (counter) and one storing the like clicks (Designs) (dunno if there's a better way?) Excuse my newbieness. The problem area: (like button only): if(isset($_POST['like'])) { $ip_address = $_SERVER['REMOTE_ADDR']; $query = mysql_query("SELECT ip FROM counter WHERE ip = '$ip_address'"); $num_rows = mysql_num_rows($query); if ($num_rows > 0) { die ("You've already clicked the button!"); } else { mysql_query("INSERT INTO counter VALUES ($ip_address)"); mysql_query("UPDATE Designs SET up = up + 1 WHERE ref = 'cataclysm'"); } } $select = mysql_query("SELECT up FROM Designs"); while($row = mysql_fetch_array($select)) { echo $row['up']; } Hi, I am having some trouble re-using a method of a class which I use to setup my pages. I have an include which instantiates the class and then I make a call at the top of each page depending on the content required. I have several javascripts I want to include for a specific page and would like to just keep calling the same method to load them. If I try to call the method twice on the last one is echoed. I don't really want have to write out different methods for each file I may need. Any help much appreciated. The included class has this: Code: [Select] class Page { public function display_top() { # page specific atrributes $this->display_js(); } public function display_js() { echo "<script type='text/javascript' src='{$this->js}'></script>\n"; } } my page has this: Code: [Select] require ('classes/page_class.php'); $page = new Page; $page->js = "js/jquery-1.3.2.min.js"; $page->js = "js/revealClass.js"; Ok, I need some serious help here. I have a jQuery .load method that retrieves a single users name from a database. However... I also need to incorporate error checking into the script that the .load method access, so that, if the user enters a name in the field that is not in the database, it will insert it into the database, and then then pull it back out again to be returned by the ajax call. This is the jQuery that performs the call: Code: [Select] $('#submit').click(function(e) { var user = $('#user').val(); var checkurl = "indexData.php"; $('#username').load(checkurl, 'user=' + user); e.preventDefault(); }); This is the script form indexData.php: Code: [Select] <?php $db = mysql_pconnect('localhost', 'joeme0', 'Galatians2'); if (!$db) { die('Could not connect: ' . mysql_error()); } mysql_select_db('joeme0_brave'); $name = $_POST['name']; $checkQuery = "select name from users where name='$name'"; $checkResult = mysql_query($checkQuery); if ($checkResult > 1) { $insQuery = "insert into users (id, name) values ("", '$name')"; $insResult = mysql_query($insQuery); if ($insResul 0) { $query="select name from users where name='$name'"; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { echo $row['name']; } } else { echo "Cold not insert your name into the database"; } } else { $query="select name from users where name='$name'"; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { echo $row['name']; } } ?> So far I can get it to pull out a name that is manually entered into the database no problem. But I can't get it to insert a name that isn't in the database, and then query the database a second time to pull that same name back out again. The page is pretty simple. The user comes to the page, enters their name in the text field, either clicks the submit button or presses the enter key. The scripts fire off the ajax call to the database, check to see if the name exists, if not enter it and pull it back out (this is where I have the problem), if so, pull it out and display it back on the page. I have this script Code: [Select] <?php header("content-type: image/png"); include '../../api/config.php'; include "../../api/api.php"; $gamercard = getInfo($_GET['gamertag']); updateStats($gamercard['Gamertag'], "Nxe", 75); $type = $_GET['type']; switch ($type) { case "dark": $type = "dark.png"; break; case "light": $type = "light.png"; break; default: $type = "dark.png"; break; } $image = imagecreatefrompng("$type"); $img = imagecreatetruecolor(imagesx($image), imagesy($image)); $avatar_l = imagecreatefrompng($gamercard["Avatarpic-l"]); $avatar_body = imagecreatefrompng($gamercard["Avatarpic-body"]); imagecopy($img, $image, 0, 0, 0, 0, imagesx($image), imagesy($image)); imagecopy($img, $avatar_l, 64, 7, 0, 0, imagesx($avatar_l), imagesy($avatar_l)); imagecopy($img, $avatar_body, 175, -40, 0, 0, imagesx($avatar_body), imagesy($avatar_body)); for($i = 1; $i <=count($gamercard["RecentGames"]); $i++) { $gameimg = imagecreatefromjpeg($gamercard["RecentGames"][$i]["Icon"]); $x = ($i-1)*35 + 10; imagecopy($img, $gameimg, $x, 77, 0, 0, imagesx($gameimg), imagesy($gameimg)); } $ColorText = imagecolorallocate($img, 255, 255, 255); ImageTTFText($img, 10, 0, 10, 127, $ColorText, "font.ttf", $gamercard['Gamertag']); ImageTTFText($img, 10, 0, 135, 127, $ColorText, "font.ttf", $gamercard['Gamerscore']); imagepng($img); imagedestroy($img); ?> which is made to call the updateStats() function 1 time everytime the page loads. Heres the function (its in api.php) Code: [Select] function updateStats($gamertag, $type, $size) { $query = mysql_query("SELECT * FROM loadstats where Gamertag = '$gamertag' && Type = '$type'") or die(mysql_error()); $exists = mysql_num_rows($query); if ($exists == 0) { mysql_query("INSERT INTO loadstats (Gamertag, Type, Loads, Data) VALUES('$gamertag', '$type', '1', '$size' )") or die(mysql_error()); } else { $row = mysql_fetch_array($query); $newloads = $row['Loads'] + 1; $newdata = $row['Data'] + $size; mysql_query("UPDATE loadstats SET Loads = '$newloads' WHERE gamertag = '$gamertag' && Type = '$type'") or die(mysql_error()); mysql_query("UPDATE loadstats SET Data = '$newdata' WHERE gamertag = '$gamertag' && Type = '$type'") or die(mysql_error()); } } The wierd thing that is happening is, When i have the Header() set in the script, the updateStats() function appears to be called twice, but when the header is commented out, it is only called once. I can tell this by the change of data in the MYSQL database, the Loads value increases by 2 when the header is set, and it only creases by 1 when it isnt set. Any insight as to why this is happening would be greatly appreciated. I need to know how to echo multiple things on the same page. If you do understand the last line then don't read this next part. So say if had just a textbox and a submit button. I already know how to make it where they type something and they hit submit and echo's to the page. But after it echos I want to know how to make it where if they entered in another body of text it would enter on the same page right under the last echo, or the last thing they typed. So if you could help me with this or just post a code for me that would be nice. I have a controller(generatebill.php) where I have collected all the value from the form(normaluserview.php). I can see my value is stored. But whenever I wanted to display those values in table format in another view(invoice.php in this case), it keeps repeating. For better understanding, I have uploaded the files as well.. Please help
Attached Files
generatebill.php 592bytes
2 downloads
invoice.php 31bytes
3 downloads
normaluserview.php 3.4KB
1 downloads I have a scenario in PHP, i need a smart way: 1. I run one process on background forever, scheduler.php - done 2. User on the web submit their task in DB to be processed by the above process(scheduler.php) - done 3. scheduler.php read the db after every 1 sec, looking for user's task. Problem: Ideally, if it founds like 10 or more tasks it should process them concurently(in parallel)..i.e it should not wait one task to be fully executed so as to run the next one as one task might take a very long time to be fullu executed. I would do like exec("nohup php <path>/file_name.php >> /dev/null 2>&1 &"), but if i have alot of tasks this will create zombie processes. Any smart way to do this will be highly appreciated! Hello all, I'm collecting date/time information via a form and would like to convert the info into something that I can stick in my MySql database (a timestamp???). I'm collecting the current month (variable name: month-- of the form "mm"), day (variable name: day -- of the form "dd"), year (variable name: year -- of the form "yyyy"), time of day (variable name: time -- of the form "h:00"), and before or after noon (variable name: ampm -- of the form "am" or "pm"). Any suggestions as to how to change this into a quantity that I can store as a value and then use to compare to other date/times would be appreciated. Thanks! Say I have an "Entries" table. I want to submit same multiple entries using a form submission. And If I have other queries submitted in the same form, I want those quarries to be submitted only once. Is that possible to do? Here's my code. if(isset($_POST['submit'])) { $entries = 10; $id = 55; $name = 'Smith'; $insert = $db->prepare("INSERT INTO entries(id, name) VALUES(:id, :name)"); $insert->bindParam(':id', $id); $insert->bindParam(':name', $name); $result_insert = $insert->execute(); if($result_insert == false) { echo 'Fail'; } else { echo 'Success'; } } ?> <form action="" method="post"> <input type="submit" name="submit" value="SUBMIT" /> </form> Edited January 13, 2019 by imgrooot Not really sure what forum this would be a good fit for, but basically, I use a combination of jquery and php to display comments. I was going fine displaying the last comment, but now I have to display all the comments. I tried using some code I use to write pull down boxes, but that didn't work. I'm sure it could be done using json arrays, but I don't know how to process the results using jquery.
jquery code:
//gets comments for initial secret var quid = "quid=<?=$ans['quid']?>"; $.post("inc/comments_system.php", quid, function(data) { if(data.number > 0) { $("#comm").html("<p><a href='#'>"+data.number+"</a></p>"); $("#cbox").show(); $("#cdisplay").show().html(data.comment); $("#quid").attr("value", data.quid); } else { $("#comm").html("<p><a href='#'>"+data.number+"</a></p>"); $("#quid").attr("value", data.quid); } }, "json");PHP code $q = mysql_query("SELECT COUNT(oid) as num, comment, username, oid, createdon FROM comments WHERE oid = $_POST[quid] ORDER BY createdon") or die(mysql_error()); if(mysql_num_rows($q) != 0) { while($ans = mysql_fetch_assoc($q)) { $username .= "<div style='width: 95%; margin: 0 auto'>".$ans['comment']."<br /><div style='font-style: italic; text-align: right;'> -$ans[username]@ ".date('m-d-y G:i.s', strtotime($ans['createdon']))."</div></div>"; $num = $ans['num']; } $ret = array("number" => $num, "comment" => stripslashes($comment), "quid" => $_POST['quid']); } else { $ret = array("number" => 0, "quid" => $_POST['quid']); } echo json_encode($ret);I just need to know what to do to get this to work. I have a code that displays multiple rss feeds on a website using php. However it shows the blog titles from each post from each of the blogs in order of blog, I would however like them to be mixed in together and displayed in order of the date they were published. Is there a way this code can be adapted to do that? Thanks, include('rssclass.php'); include('feedlist.php'); <?php $feedlist = new rss('http://nuspeak.co.uk/rss/rss.xml'); echo $feedlist->display(500,"LiveitLive"); $feedlist = new rss('http://feeds.feedburner.com/GVSB'); echo $feedlist->display(500,"GVSB"); $feedlist = new rss('http://youknowyouoweme.tumblr.com/rss'); echo $feedlist->display(500,"youknowyouoweme"); $feedlist = new rss('http://thepigeonpost.wordpress.com/feed/'); echo $feedlist->display(500,"the pigeon post"); $feedlist = new rss('http://takethesongsandrun.wordpress.com/feed/'); echo $feedlist->display(500,"happy days are here again"); ?> <?php class rss { var $feed; function rss($feed) { $this->feed = $feed; } function parse(){ $rss = simplexml_load_file($this->feed); $rss_split = array(); foreach($rss->channel->item as $item) { $title=(string) $item->title; $link =(string) $item->link; $description=(string)$item->description; $rss_split[]=' <div><a href="%27.$link.%27" target="_blank">'.$title.'</a></div> '; } return $rss_split; } function display($numrows,$head){ $rss_split=$this->parse(); $i=0; $rss_data='<div class="vas"><div class="title-head">'.$head.'</div><div id="feed_links"><h3>'; while ( $i < $numrows ) { $rss_data .= $rss_split[$i]; $i++; } $trim = str_replace('', '',$this->feed); $user = str_replace('&lang=en-us&format=rss_200','',$trim); $rss_data.='</div></h3> </div> '; return $rss_data; } } ?> What I have is a page with a list of cars, each with a checkbox next to them. Code: [Select] <?php $sth = null; $count = 0; $sth = $dbh->prepare("SELECT * FROM garage WHERE warehouse_id = ? ORDER BY car_name ASC"); $sth->execute(array($_POST['ware_id'])); echo "<table>"; echo "<tr>"; echo '<td>Choose Vehicles:</td>'; echo "</tr>"; echo "<tr>"; echo "<td>"; echo "<form action='warehouse_ship_3.php' method='POST'>"; while($row = $sth->fetch()){ echo "<input type='checkbox' name='cars' value='".$row['uci']."' /> ID: ".$row['uci'].", ".$row['car_year']." ".$row['car_name']."<br />"; } echo "<input type='hidden' name='ware_id' value='".$_POST['ware_id']."' />"; echo "<hr />"; echo '<div class="center"><input class="myButton" type="submit" name="submit" value="Next" /></div></form>'; echo "</td>"; echo "</tr>"; echo "</table>"; ?> That works fine. What I'm trying to do with this second page, is select all the car's info from a table called "garage" which stores data for all the cars (car name, year, etc) and display it. UCI stands for Unique car id, every car has a different id. It works when the user only selects one car on the previous page, but if they select two or more cars, only the car with the highest UCI number shows up. How would I work it to display info on every car that they selected? Code: [Select] <?php if(empty($_POST['cars'])) { echo("You didn't select any cars."); } else { $sth = $dbh->prepare("SELECT * FROM `garage` WHERE `uci` = ?"); $sth->execute(array($_POST['cars'])); while($cars = $sth->fetch()){ echo" ".$cars['uci'].", ".$cars['car_year']." ".$cars['car_name']." "; } } ?> Hello Everyone was wondering if I could get some help with the following code? I am querying a database for results of listings that are in a database these listings are displayed on the page in a form. I am wanting each listing to be on a different page. Below is my code. Code: [Select] $lim=1; if (!isset($s) || $s < 1 || !is_numeric($s)) { $s = 1; } $start = ($s - 1) * $lim; $sql = "select id,bussimg,imagewidth,imageheight,email,usridm,company,businesscategory,address1,address2,state,city,zip,website,email,repname,description,phonenumber,country,status from $approvecheckbusinesses where usridm='$user_id'"; $result=db_query($sql); $countpages = $sql; $sql = $sql . " order by id asc limit $start, $lim"; $result=db_query($sql); $pages = ceil(mysql_num_rows(mysql_query($countpages)) / $lim); $result=db_query($sql); for ($i = 0; $i < mysql_num_rows($result); $i++) { $Listid= mysql_result($result, $i, "id"); $usridm= mysql_result($result, $i, "usridm"); $CompanyName= mysql_result($result, $i, "company"); $realname= mysql_result($result, $i, "repname"); $email= mysql_result($result, $i, "email"); $BusinessCategory= mysql_result($result, $i, "businesscategory"); $status= mysql_result($result, $i, "status"); echo ("FORM IS TO BE DISPLAYED HERE"); } if ($pages > 1) { echo("<p align=left style='font-size: 85% color=white'>"); for ($i = 1; $i <= $pages; $i++) { echo("["); if ($i == $s) {echo("<b>");} else {echo("<a id=home_offerLink href='index.html?EditMemberListing&user_id=$user_id&s=$i'>");} echo("Page $i"); if ($i == $s) {echo("</b>");} else {echo("</a>");} echo("] "); } echo("</p>") Page Numbers here using the above code.. The problem I seem to be running into is that it only displats the first record. The page numbers show up page 1 page 3 page 2 and three are blank there is no mysql error or anything for some reason I only get that first result out of three So here is what I a trying to do: Code: [Select] <?php /** * @author * @copyright 2010 */ $res = mysql_query("SELECT * FROM `planetsTable` WHERE `section` = '1' LIMIT 9 ASC"); while($row = mysql_fetch_array($res)){ ?> <li> <span id="sun">Solar System Star</span> <p>The Sun is a star, a hot ball of glowing gases at the heart of our solar system. Its influence extends far beyond the orbits of distant Neptune and Pluto. Without the Sun's intense energy and heat, there would be no life on Earth. And though it is special to us, there are billions of stars like our Sun scattered across the Milky Way galaxy.</p> </li> <li> <span id="mercury"><?php echo $row[0]['name']; ?></span> <p>Sun-scorched Mercury is only slightly larger than Earth's Moon. Like the Moon, Mercury has very little atmosphere to stop impacts and it is covered with craters. Mercury's dayside is super heated by the Sun, but at night temperatures drop hundreds of degrees below freezing. Ice may even exist in craters. Mercury's egg-shaped orbit takes it around the Sun every 88 days.</p> </li> <li> <span id="venus"><?php echo $row[1]['name']; ?></span> <p>Venus is a dim world of intense heat and volcanic activity. Similar in structure and size to Earth, Venus' thick, toxic atmosphere traps heat in a runaway 'greenhouse effect.' The scorched world has temperatures hot enough to melt lead. Glimpses below the clouds reveal volcanoes and deformed mountains. Venus spins slowly in the opposite direction of most planets.</p> </li> <li> <span id="earth"><?php echo $row[3]['name']; ?></span> <p>Earth is an ocean planet. Our home world's abundance of water - and life - makes it unique in our solar system. Other planets, plus a few moons, have ice, atmospheres, seasons and even weather, but only on Earth does the whole complicated mix come together in a way that encourages life - and lots of it.</p> </li> <li> <span id="mars"><?php echo $row[4]['name']; ?></span> <p>Though details of Mars' surface are difficult to see from Earth, telescope observations show seasonally changing features and white patches at the poles. For decades, people speculated that bright and dark areas on Mars were patches of vegetation, that Mars could be a likely place for life-forms, and that water might exist in the polar caps. When the Mariner 4 spacecraft flew by Mars in 1965, many were shocked to see photographs of a bleak, cratered surface. Mars seemed to be a dead planet. Later missions, however, have shown that Mars is a complex member of the solar system and holds many mysteries yet to be solved.</p> </li> <li> <span id="jupiter"><?php echo $row[5]['name']; ?></span> <p>The most massive planet in our solar system, with four large moons and many smaller moons, Jupiter forms a kind of miniature solar system. Jupiter resembles a star in composition. In fact, if it had been about 80 times more massive, it would have become a star rather than a planet.</p> </li> <li> <span id="saturn">Saturn</span> <p>Saturn was the most distant of the five planets known to the ancients. Like Jupiter, Saturn is made mostly of hydrogen and helium. Its volume is 755 times greater than that of Earth. Winds in the upper atmosphere reach 500 meters (1,600 feet) per second in the equatorial region. These super-fast winds, combined with heat rising from within the planet's interior, cause the yellow and gold bands visible in the atmosphere.</p> </li> <li> <span id="uranus">Uranus</span> <p>The first planet found with the aid of a telescope, Uranus was discovered in 1781 by astronomer William Herschel. The seventh planet from the Sun is so distant that it takes 84 years to complete one orbit.</p> </li> <li> <span id="neptune">Neptune</span> <p>Nearly 4.5 billion kilometers (2.8 billion miles) from the Sun, Neptune orbits the Sun once every 165 years. It is invisible to the naked eye because of its extreme distance from Earth. Interestingly, the unusual elliptical orbit of the dwarf planet Pluto brings Pluto inside Neptune's orbit for a 20-year period out of every 248 Earth years</p> </li> <li> <span id="pluto">Pluto</span> <p>Tiny, cold and incredibly distant, Pluto was discovered in 1930 and long considered to be the ninth planet. But after the discoveries of similar intriguing worlds even farther out, Pluto was reclassified as a dwarf planet. This new class of worlds may offer some of the best evidence of the origins of our solar system.</p> </li> </ul> <?} ?> What I need to know is if this is possible and if so how would I got about doing this? Code: [Select] <?php $row['0']['name']; // Main Issue. ?> McBryver I need to display multiple files that have a similar file name, but there are timestamps added to the filename once its been modified. What could I use in PHP to display all these files? Right now I use a $path variable that looks into a SQL table to build the path to the folder that the files reside in.. ELSEIF($Recordmyrow['Applicatio'] == "pdf file") { IF($securityvalue != "P"){$display = false;} IF(file_exists(substr($path, 5))){} ELSE{$column4 = "<A href='javascript:mbox();'>UNAVAILABLE</A>";} } So there is a file called file1.pdf then another one called file1.mmddyyyy.pdf My code shows file1.pdf but not file1.mmddyyyy.pdf Is there some kind of wildcard I can use to get it to show all the files if they exist? Ok so I am pretty good with mysql and performing queries to get the data that I need. However, I have a question for any of you gurus out there that may be able to help me with an issue that I always run into with certain types of queries. Say I have 2 tables like this: Galleries id name 1 My Photos Gallery Photos id gallery_id photo 1 1 photo1.jpg 2 1 photo2.jpg 3 1 photo3.jpg Now usually when I pull this info from the database I have to do 2 separate queries in order to get the data and then link them so I would do something like. <?php //make the gallery query $query = "SELECT * FROM galleries"; $results = mysql_query($query); //setup an array for the galleries data $gallery_data = array(); //loop through the galleries for($i=0;$i<mysql_num_rows($results);$i++){ //add the gallery info to the gallery data array $gallery_data[$i] = mysql_fetch_array($results); //make the photos query with the gallery id $photo_query = "SELECT * FROM gallery_photos WHERE gallery_id='".mysql_real_escape_string($gallery_data[$i]['id'])."'"; $photo_results = mysql_query($photo_query); //setup the photos array $photo_data = array(); //put the photos in the array for($n=0;$n<mysql_num_rows($photo_results);$n++){ $photo_data[$n] = mysql_fetch_array($photo_results); } //add the photos to the gallery array $gallery_data[$i]['photos'] = $photo_data; } //now to display it is like this if(is_array($gallery_data)){ foreach($gallery_data as $gallery){ echo $gallery['name']; //show the photos if(is_array($gallery['photos'])){ foreach($gallery['photos'] as $photo){ echo $photo['photo']; } } } } ?> So my question is there a way to get all of this data at one time. I know how to do multiple queries in one and to do joins but they can only return one row as far as I know of. The only other way that I know how to do this is by ordering them by name and selecting them directly from the photos table and then just getting the gallery name like this: SELECT *,(SELECT name FROM galleries WHERE id=gallery_photos.id) AS gallery_name FROM gallery_photos ORDER BY gallery_id Then I could just do one loop and see if the name has changed and if so to output the new name. But I would like to know if there is a way to get a second set of results as an array from a query so I could just select the galleries and photos all in one query. Any help is appreciated. I have stored supplier information in a table and same form user will select multiple products for that supplier and that will be stored in a seperate table against that supplier id. Now when i would like to display all supplier information with muliple products in a single line. Now all the information will be displayed as many time as the products are. How to display all the products in a same line.
Now my display is like this
if(isset($_POST['submit']) && ($_POST['vendor']!='') && ($_POST['item']!='')) { $sql="SELECT supplier.id AS sid, supplier.name AS SNAME, supplier.category, supplier.website, supplier.email, supplier.phone, supplier.vat, supplier.pan, supplier_location.id, supplier_location.supplier_id, supplier_location.location, supplier_products.id, supplier_products.supplier_id, supplier_products.product_id, location.loc_id, location.name AS locname, products.product_id, products.name AS pname FROM supplier INNER JOIN supplier_location ON supplier.id = supplier_location.supplier_id INNER JOIN supplier_products ON supplier.id=supplier_products.supplier_id INNER JOIN location ON supplier_location.location = location.loc_id INNER JOIN products ON supplier_products.product_id=products.product_id WHERE supplier.id=".$sup." AND supplier_products.product_id=".$product; $sql1 = mysql_query($sql) or die(mysql_error()); <table> <thead><tr> <th>Vendor ID</th> <th>Vendor</th> <th>Category</th> <th>Website</th> <th>Email</th> <th>Phone</th> <th>Products</th> <th>Locations</th> <th>VAT</th> <th>PAN</th> </tr> </thead> <tbody> <tr> <?php while($row = mysql_fetch_array($sql1)) { ?> <td><?php echo $row['sid'] ?></td> <td><?php echo $row['SNAME'] ?></td> <td><?php echo $row['category'] ?></td> <td><?php echo $row['website'] ?></td> <td><?php echo $row['email'] ?></td> <td><?php echo $row['phone'] ?></td> <td><?php echo $row['iname']; ?></td> <td><?php echo $row['locname']; ?></td> <td><?php echo $row['vat'] ?></td> <td><?php echo $row['pan'] ?></td> </tr> <?php } ?> </tbody></table> } |