PHP - If Else Display
I have written a bra calculator, when the user enters their measurements their bra size is displayed however as the code I have used to do this came from a help tutorial I do not understand how it was constructed as I am quite a newb.
The form works perfectly when returning data however if there is no size for a particular measurement it just displays nothing. I would like it to display N/A I have tried adding various if elses but without success. Any help is much appreciated Code: [Select] <FORM ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD=get> <input type="text" name="band" value="<?php echo $_GET['band']; ?>" /> <input type="text" name="bust" value="<?php echo $_GET['bust']; ?>" /> <INPUT TYPE=submit VALUE="Calculate"> </FORM> <?php $band = $_GET['band']; $bust = $_GET['bust']; $query = sprintf("SELECT size FROM bra_calculator WHERE band='%s' AND bust='%s'", mysql_real_escape_string($band), mysql_real_escape_string($bust)); $result = mysql_query($query); if (!$result) { echo "no"; } else { while ($row = mysql_fetch_assoc($result)) { echo $row['size']; } } mysql_free_result($result); ?> Similar TutorialsSo I have this script. I connected the database and verified a working connection to the base, password correct. As I save the script on my server it saved the changes and I view the file online. The resulting page is blank. Really need help completing this code as it's essential to my sites organization, have a look below and help me if possible.
<?php Hi everyone, im not sure if this topic belongs in CSS so please move if it is but... I have a style sheet with some boxes i want my SQL results to go into, i want to know how to echo the results into the boxes. heres the html: Code: [Select] <!DOCTYPE html> <head> <title>Compaines | Removalspace.com</title> <style type="text/css"> <!-- body { background-image: url(styles/downloaded%20styles/todo/todo/images/bg.png); } --> </style> <link href="styles/downloaded styles/todo/todo/css/style.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/style9.css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/demo.css" /> <link href='http://fonts.googleapis.com/css?family=Terminal+Dosis' rel='stylesheet' type='text/css' /> <style type="text/css"> <!-- .Stile1 {color: #333333} --> </style> </head> <body> <!--start container --> <div id="container"> <header> <nav> <div id="logo"><a href="#"><img src="images/removalspace1.png" alt="Logo here" width="463" height="135" /></a> </div> <div id="search-top"> <form method="post" action="search.php"> <input type="text" onFocus="if(this.value=='Search')this.value='';" onBlur="if(this.value=='')this.value='Search';" value="Search" id="search-field"/> <input type="submit" value="" id="search-btn"/> </form> </div> <div id="nav_social"><a href="http://www.facebook.com/pages/Removalspace/181434181939226"><img src="styles/downloaded styles/todo/todo/images/facebook_32.png" alt="Become a fan" width="32" height="32" /></a><a href="#"><img src="styles/downloaded styles/todo/todo/images/twitter_32.png" alt="Follows on Twitter" /></a><a href="#"><img src="styles/downloaded styles/todo/todo/images/linkedin_32.png" alt="Linked in" /></a><a href="contact.php"><img src="styles/downloaded styles/todo/todo/images/email_32.png" alt="Contact" width="32" height="32" /></a> </div> </nav> </header> <div class="content"> <ul class="ca-menu"> <li> <a href="removals.php"> <span class="ca-icon">A</span> <div class="ca-content"> <h2 class="ca-main">Bringing removals home</h2> <h3 class="ca-sub">All in one place</h3> </div> </a> </li> <li> <a href="storage.php"> <span class="ca-icon">I</span> <div class="ca-content"> <h2 class="ca-main">Find the storage space</h2> <h3 class="ca-sub">Near You</h3> </div> </a> </li> <li> <a href="advertise_page.php"> <span class="ca-icon">C</span> <div class="ca-content"> <h2 class="ca-main">Advertise</h2> <h3 class="ca-sub">Your Business</h3> </div> </a> </li> <li> <a href="contact.php"> <span class="ca-icon">S</span> <div class="ca-content"> <h2 class="ca-main">Sophisticated Team</h2> <h3 class="ca-sub">Professionals in action</h3> </div> </a> </li> </ul> <!--star main --> <main> <div class="abox"> <figure> <fcapion> <h1>Company... </h1> </fcaption><a href="index-delete.php"></a><a href="#"><img src="images/images-8.jpeg" alt="I love graphic" width="200" height="200" /></a></figure> </div> <div class="abox"> <figure> <fcapion> <h1>Address... </h1> </fcaption> <a href="#"><img src="images/storagespace.jpg" alt="I love graphic" width="200" height="200" /></a> </figure> </div> <div class="abox"> <figure> <fcapion> <h1>Phone...</h1> </fcaption><a href="#"></a><a href="#"><img src="images/transport.jpg" alt="I love graphic" width="200" height="200" /></a></figure> </div> </main> <!--end main --> <!--start middle --> <middle> <div class="enter"> <P >Sign up to removalspace.com to advertise your business, choose from easy payment packages or add a FREE listing. Click the link to get started<br></P> <div class="imgteaser"> <a href="login-or-register.php"><img src="images/free listing2.jpg" alt="Todo el Todo" width="413" height="220" /><span class="desc"> <strong>Sign Up For Free!</strong> Start by making a FREE listing today.</span></a></div> </div> <div class="section_slogan"><img src="styles/downloaded styles/todo/todo/images/quote-right.png" alt="images" /><span class="cursive"> Nobody likes moving but finding the right people is easy at least with Removalspace.com</span><img src="styles/downloaded styles/todo/todo/images/quote-left.png" alt="images" /></div> <div class="middle_box"><h1><img src="styles/downloaded styles/todo/todo/images/fav.png" width="16" height="16" /> <a href="#">Resources</a></h1> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Search thousands of removal companies </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Search for a storage facility near you </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Contact Us </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> About removalspace. </ol> </div> <div class="middle_box"><h1><img src="styles/downloaded styles/todo/todo/images/fav.png" width="16" height="16" /> <a href="#">Blogs</a></h1> <p><img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Recent Post</p> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Post your comments </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Read Reviews </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Recent removalspace things. </ol> </div> <div class="middle_box"> <h1><img src="styles/downloaded styles/todo/todo/images/fav.png" width="16" height="16" /> <a href="#">Other </a></h1> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Advertisment Page <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Affiliate Links </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Our Packages. </ol></div> </middle> </div> <!--end middle --> <!--start footer --> <footer> <div id="footer"> <div id="footerleft"> <h2>removalspace</h2> <ul> <li><a href="http://www.imediacreatives.it">Contact</a></li> <li><a href="styles/downloaded styles/todo/todo/...">About Us</a></li> <li><a href="styles/downloaded styles/todo/todo/...">Other</a></li> </ul> </div> <div id="footermiddle"> <h2>User Comments</h2> <ul> <li><a href="styles/downloaded styles/todo/todo/...">Read Reviews</a></li> <li><a href="http://www.imediacreatives.it">Leave A Comment</a></li> <li><a href="styles/downloaded styles/todo/todo/...">Read Blogs</a></li> </ul> </div> <div id="footerright"> <h2>our mission</h2> <ul> <li><a href="">Who Are We?</a></li> <li><a href="">What We Do</a></li> <li><a href="">Our Mission</a></li> </ul> </div> <details> <summary> <p> Copyright © removalspace.com -2012.</p></summary><p></p> </details> </div> </footer> <!--end footer --> </div> <!--end container --> <!-- Free template distributed by http://freehtml5templates.com --> </body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> </html> heres the php code: Code: [Select] <?PHP include ('db.php'); $query = "SELECT * FROM companies ORDER BY approved DESC, company_name ASC"; $result = mysql_query($query); ?> <table border="0" cellpadding="1" cellspacing="2" bordercolor="#0066FF" background="images/table-images/back.png"> <tr> <th background="images/table-images/pattern.png">Company Name</th> <th background="images/table-images/pattern-head.png">Contact Name:</th> <th background="images/table-images/pattern.png">Contact Number:</th> <th background="images/table-images/pattern-head.png">Contact Email:</th> <th background="images/table-images/pattern.png">Address 1:</th> <th background="images/table-images/pattern-head.png">Address 2:</th> <th background="images/table-images/pattern.png">Area:</th> <th background="images/table-images/pattern-head.png">Postcode:</th> <th> - </th> <th> - </th> <th> - </th> <tr> <?php while ( $row = mysql_fetch_array($result)) { $approved = $row['approved']; SWITCH ($approved) { case 0: break; case 1: ?> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td></td> <td></td> <td></td> </tr> <?PHP break; case 2: ?> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td><?PHP echo $row['basicpackage_description']; ?></td> <td>-</td> <td>-</td> </tr> <?PHP break; case 3: ?> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td><?PHP echo $row['basicpackage_description']; ?></td> <td><?PHP echo $row['premiumuser_description']; ?></td> <td><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></td> </tr> <?PHP break; } } echo "</table>"; ?> That is currently set to echo out a table but i only want "company" "address" "phone" to make things easier. Company name = box1 street1,street2, location, postcode = box2 (for address) phone = box3 I hope theres enough information for any help, thank you in advance! Hello. I am not entirely certain if this is even possible, but I don't see why it wouldn't. The document that I have is: Code: [Select] <?php include('../connection.php'); $query="SELECT * FROM projects"; $result=mysql_query($query); echo "<table border='1' cellpadding='10'>"; while($row = mysql_fetch_array( $result )) { echo "<tr>"; echo "<td>$row[id]</td>"; echo "<td>$row[name]</td>"; echo "<td>$row[text]</td>"; echo "<td><img src='../uploads/$row[image]'/></td>"; echo "<td><a href='editprojects.php?id=$row[id]'>Edit</a></td>"; echo "<td><a href='deleteprojects.php?id=$row[id]'>Delete</a></td>"; echo "</tr>"; } echo "</table>"; mysql_free_result($result); mysql_close($connection); ?> Basically, the only important line from that file is: Code: [Select] echo "<td><img src='../uploads/$row[image]'/></td>"; What I am doing is uploading images and other files to a PHP database. [image] = carries all the uploaded files. That single line shows every uploaded image in a row. But it doesn't show the SWF because obviously 'img src' isn't for swf's. Is it possible to add another code to THAT LINE to show the swf's? that single bit needs to be able to read images and swf's, Please help if you can. Back again!! I have been trying to think of a way to do this but its starting to make my brain itch a bit too much now!!! I have the code below to display my query. Basicly its to disply 3 images and when 'x=a multiple of 3' it ends the row and starts another. The only problem is, that the first result will not be displayed as x has to begin at 1. if x begins at 0, it will display the first result and begin a new line. Code: [Select] echo "<center><table border='0' cell padding='3'><tr>"; $x = 1; while ($x < $num) { $id=mysql_result($result,$x,"id"); $caption=mysql_result($result,$x,"cap"); $address=mysql_result($result,$x,"address"); $date=mysql_result($result,$x,"date"); $album=mysql_result($result,$x,"album"); $member=mysql_result($result,$x,"member"); echo "<td><center><img src='/images/uploads/main/thumb_".$address."'><br>$caption</center></td>"; echo ($x % 3 == 0)? "</tr><tr>" : ""; $x++; } echo "</tr></table>"; Can anyone point me in the right direction?? Thanks Eric I want to grab a list of all the school programs I have in a database (math english biology chemistry ect ect) and dispaly them in a order so that they go alphabetically downward for 12 rows and then go across so it would look like soo: Academic Advisory Class Schedules Academic Assistance Counselling Center Academic Calendars Course Descriptions and Catalogue Academics Office Department Directory Administration Departments & Programs Adult Learners Fellowships Alumnimni Chapters Finals Schedules Alumni Events Athletics Campus Life At a Glance Campus Recreation Campus Safety & Security I know to get he I am just unsure what to do in the while array to make it look how I want Code: [Select] <?php $sql = "SELECT name,id FROM table_name ORDER BY name ASC"; $res =mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($res)){ //now what??? } ?> heres my code: Code: [Select] <?php if ($pagi_count > 1) { echo '<ul class="pagination">'; echo '<li><a href="#">«</a></li>'; $pagi_start = 1; $pagi_end = $pagi_count; for ($p = $pagi_start; $p <= $pagi_end; $p++) { $link = "$url/page/".$get_letter; if ($p > 1) $link .= "/$p"; if ($p == $pagi_num) $class = ' class="current"'; else $class = ''; echo '<li'.$class.'><a href="'.$link.'">'.$p.'</a></li>'; } echo '<li><a href="#">»</a></li>'; echo '</ul>'; } ?> now this works fine, however i want it to only show 20 page numbers, and if there are more than 20 total pages, i want the current page to be in the middle of the list (unless of course the current page is 1 or 2 then it would be more to the left of the list........ example: with 13 total pages, on page 8: << 1 2 3 4 5 6 7 ( 9 10 11 12 13 >> with 55 total pages, on page 2: << 1 (2) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 >> with 65 total pages, on page 12: << 2 3 4 5 6 7 8 9 10 11 (12) 13 14 15 16 17 18 19 20 21 >> im really stumped on the math for this....any help would be much appreciated. Hi again! I'm trying to use this code that i found somewhere in the net to display all the dates between 2 dates. It is exactly what i need but.. I understand the code and its structure (i think) but it gives me an error (maximum execution time of blah blah) which i think is because it makes an infinite loop(not sure.. ) Code: [Select] function GetDays($sStartDate, $sEndDate) { $sStartDate = gmdate("Y-m-d", strtotime($sStartDate)); $sEndDate = gmdate("Y-m-d", strtotime($sEndDate)); $aDays[] = $sStartDate; $sCurrentDate = $sStartDate; while($sCurrentDate < $sEndDate){ $sCurrentDate = gmdate("Y-m-d", strtotime("+1 day", strtotime($sCurrentDate))); $aDays[] = $sCurrentDate; } return $aDays; } Appreciate the help and suggestions! Gonna browse the forums for answers for the meantime... hello . i have a comments box on my site that doing some strange things. if i type anything in and press enter it adds more characters. http://www.grosvenorassociates.com/contact.php for example if i type 1 2 3 4 5 6 and press submit, i get 1\r\n2\r\n3\r\n4\r\n5\r\n6 if i type a b c d e f i get a\r\nb\r\nc\r\nd\r\ne\r\nf this is the code im using: Code: [Select] <textarea name="comments" type="text" class="textarea" value="<?PHP echo $comments; ?>"/><?PHP echo nl2br($comments) ?></textarea> i ideas whats doing this and how to fix it ? thanks rick Hi all. The following is a function to get and display data. However, I've hit a wall in my progress. It's only printing out one field. I need to have it print out every retrieved field. Any help is appreciated. function get_data($table_name){ $result=mysql_query("SELECT * FROM $table_name"); $num=mysql_num_rows($result); $i=0; while($i < $num){ $fields=mysql_fetch_field($result,$i); $display_fields=mysql_result($result,$i,$fields->name); echo $display_fields; $i++; }; }; I realized that (I think) I need the $display_fields var to be concatenated with the $i variable so there's a unique var name for each field retrieved from the mysql_fetch_field line. Any ideas? I am looking to display image paths in a row separated by commas. There are 6 images that goes to each user and I would like only the 6 images at be in each " " Like this: "images/listings/listing_516013019A-only.jpg,images/listings/listing_848813453A-1.jpg,images/listings/listing_664613453A-2.jpg,images/listings/listing_520313453A-3.jpg,images/listings/listing_690513453A-4.jpg,images/listings/listing_125113453A-5.jpg,images/listings/listing_641013453A-6.jpg," "images/listings/listing_736913186A-1.jpg,images/listings/listing_822713186A-2.jpg,images/listings/listing_136513186A-3.jpg,images/listings/listing_700313186A-4.jpg,images/listings/listing_716013186A-5.jpg,images/listings/listing_213113186A-6.jpg," "images/listings/listing_292113254A..-1.jpg,images/listings/listing_854413254A..-2.jpg,images/listings/listing_446013254A..-3.jpg,images/listings/listing_676313254A..-4.jpg,images/listings/listing_563413254A..-5.jpg,images/listings/listing_341513254A..-6.jpg," Right now it is displaying them like this "images/listings/listing_516013019A-only.jpg," "images/listings/listing_848813453A-1.jpg," "images/listings/listing_664613453A-2.jpg," "images/listings/listing_520313453A-3.jpg," "images/listings/listing_690513453A-4.jpg," "images/listings/listing_125113453A-5.jpg," "images/listings/listing_641013453A-6.jpg," "images/listings/listing_736913186A-1.jpg," "images/listings/listing_822713186A-2.jpg," "images/listings/listing_136513186A-3.jpg," "images/listings/listing_700313186A-4.jpg," "images/listings/listing_716013186A-5.jpg," "images/listings/listing_213113186A-6.jpg," "images/listings/listing_292113254A..-1.jpg," "images/listings/listing_854413254A..-2.jpg," "images/listings/listing_446013254A..-3.jpg," "images/listings/listing_676313254A..-4.jpg," "images/listings/listing_563413254A..-5.jpg," "images/listings/listing_341513254A..-6.jpg," Here is the code I have: Code: [Select] <?php // Make a MySQL Connection mysql_connect("localhost", "xxxxxxxx", "xxxxxxxx") or die(mysql_error()); mysql_select_db("xxxxxxxx") or die(mysql_error()); $result = mysql_query("SELECT * FROM listimages ORDER BY listimages.listingid DESC ") or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "\""; echo "$row[imagepath],"; echo "\""; echo "<br>"; } ?> My tables for the images is "listimages" and the columns a id (which are the auto_increments) imagepath (which shows the path/image1.jpg) mainimage (which just shows 0 or 1 depending on the picture that is the default for that listing, 1 being default) listingid (shows numbers 1 2 3 etc corresponding to the Id in the listings table to show what images go with what listing) There are up to 6 images for each listing. Any idea how to fix this? Hello all, I am new to php and was wondering if i could get some guidance here. I am using phpAdmin 2.6.0 and running Mysql 4.1.21. here is my situation.... I have a script that allows us to upload a new product name, product code, category and a PDF file to the data base. There is also a folder on the server that has the PDF files in it. I think I deleted the code on the page (library.php) that displays the files for the client to download. My goal here is after I upload everything I want it to then be displayed on the page with a link to the PDF file. Here is the page that has the links on it. I hope that I explained this correctly. I am not a programmer but do have some idea and have been reading up on php to try and figure this out. I am looking to create the script that would display the links on the library.php page. Any help would be great. The other link is to the script that allows us to upload. www.pennstateind.com/library.php www.pennstateind.com/lib-admin.php Hi, Is it possible to display the whole array of voteID in this url? https://falling-skies-tv.loopiasecure.com/vote_result.php?voteID=292&comp=falling-skies-danmark Is there a script/website/code I can use? Thank you! hello i need help on displaying php code on my website so people can come and just copy it but it wont let me display it I'm trying to help someone out with their website (which is entirely in PHP) and I've come across a problem I can't seem to figure out. On the site is a php calendar that should display as so: However, sometimes for no apparent reason the calendar appears as so: I cannot seem to determine what is causing this to display incorrectly. It just started happening for no discernible reason. Anyone have any idea where I should start looking to find the issue? It is linked to a MySQL database that is somewhat wonky, could that be the issue? Thanks for any advice you guys can give me. hi friends. to fetch results from the database i made a function and how i call the function on a page like $results = GetResults($someID); when i print_r the $results i get all the results, but now im confused on how do i print the rows individually? say i got Title row how will i only get the Title row from the $results VAR? I have a fairly complicated Q&A Form with 10 Inputs. If there is a data entry error, then I re-load the Form display an error-message beneath the corresponding field. No problems there. Normally, if there was a more serious error (e.g. INSERT failed), then I would re-direct to a new page and display the error (or success) message there. No problem again. But here is where I am confused... Because my code iterates through each of the 10 Inputs on my Q&A Form, there could conceivably be an error on each loop. If I had two serious errors (e.g. INSERT error and UPDATE error), then how should I handle displaying the error?! For those types of errors, I would usually re-direct, however there would usually be only one error to display, e.g. Quote Your profile answers could not be added due to a System Error. Should I display every error that might occur for every one of the 10 Input fields, or does it make sense to just display one error, with the understanding that if one thing fails then everything does. Hope that makes sense?! Thanks, Debbie Hello mates, I'm newbie in PHP and I'm trying to make something here. I'm working on a script that allows me to write some comments (from admin panel) and display them on my index page. For now, the script is displaying me all comments that I'm writing, and I want to display just 5 let's say. Any solution for this? Code: [Select] <tbody> <?php $scom=mysql_query("select * from comments order by date desc"); $num=mysql_num_rows($scom); if($num!=0) { while($randc=mysql_fetch_array($scom)) { echo' <tr> <td width="50" align="center" valign="top" bgcolor="#B5D2DC"><img src="images/500999.png" width="30" height="30" /></td> <td class="textmic"> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#B5D2DC"> <tr> <td class="textc"><u>'.$randc["date"].'</u></td> </tr> <tr> <td align="justify">'; $newtext = wordwrap($randc["comment"], 20, "\n", true); echo $newtext.'</td> </tr> <tr> <td> <hr width="100%" noshade="noshade" size="8" color="#B5D2DC" /> </td> </tr> </table> </td> </tr> '; } } ?> </tbody> i have a stupid simple problem here, but ive never done this exactly this way before and im having a tough time working it out. was looking for any suggestions. my script is working fine: $table_name = "plan"; $sql = "SELECT id, plan_name FROM $table_name ORDER BY plan_name"; $query = mysql_query($sql); if(mysql_num_rows($query) > 0) { echo "<table>"; while($row = mysql_fetch_array($query)) { echo "<tr><td>" . $row['plan_name'] ."</tr></td>"; } echo "</table>"; ... but i have another table company that are related to plan_name i have the company_id field in my plan table for the relationship. and that id is related to the company id field of course. all i am trying to do is display the company_name next to $row['plan_name'], so i know which plans are related to which company. i think i need to create two seperate queries, but is there a way to include everyone in one query? is there a better way? here is my sql: plan table: `id` int(11) NOT NULL AUTO_INCREMENT, `company_id` int(11) NOT NULL, `plan_name` varchar(255) NOT NULL, ... company table `id` int(11) NOT NULL AUTO_INCREMENT, `plan_id` int(11) NOT NULL, `company_name` varchar(255) NOT NULL,... it also seemed to be overkill to have two while loops running.. i am just thinking out loud on the best approach to this. Hey everyone, I have a problem here.Now as u see my data is being displayed one after another in vertical manner.But what do i want to do is the entire table being displayed in same page continuously one after another in horizontal manner.how would i do that? (below a screen shot is given how my table looks like.) <code> <?php for($i=0;$i<=25;$i++) { if($i%5==0) { ?> <table> <tr> <th scope="row">U_Id :</th> <td><?php echo 'uid'; ?></td> </tr> <tr> <th scope="row">Name :</th> <td><?php echo "name"; ?></td> </tr> <tr> <th scope="row">Teamname :</th> <td><?php echo "teamname"; ?></td> </tr> <tr> <th scope="row">Coins :</th> <td><?php echo 'coins';?></td> </tr> <tr> <th scope="row">Cash:</th> <td><?php echo 'cash'; ?></td> </tr> </table> <br/> <?php //echo "$i<br/>"; } } ?> </code> Guys, i want to display ads after 4 items to be displayed. Iam fetching item using mysql database & iam showing 8 items per page. I used below code but its not working because i used the item id to specify the first number but the items is not listed as correct order Code: [Select] <?php // first number $first = $row['id']; // second number $second = 4; //checking if the first number is muliple of second. If true then display ads. If($first % $second == "0") { echo 'ads to display'; } It will work if i list items in correct order. Please let me know correct solution. Thanks in advance ! |