PHP - Display Latest Submition To An Sql Db
Right now I just cheated and sorted by descending then put like thirty <br />'s so you couldn't see old ones. How can I do this properly?
Similar Tutorialshey I am not usually in this php forum, I am usually around html/css but a task arose and I figure since this forum uses smf it would be a perfect place to ask. Not saying you are all smf experts though. My question is how do I display the latest posts for smf in a page thats not a forum page. Like On my index page I want to display the latest posts on the forum. Help anyone? I have a search page and everything works fine but I would like to add the latest 10 rows to the page so there is something to look at or click on before the user searches. The page is at: www.giantstridedives.com/locations. You can see that it's pretty boring. Hit submit and you'll see the entries so far (only 3 right now). I'd like to have the latest 10 display there by default but then when a user searches they are replaced by the search results. Make sense? Here's the code I'm using for the search: Code: [Select] <?php if (isset($_POST['submit'])) { require_once('dbconnection.php'); mysqli_select_db($conn, $dbname); $searchterm = $_POST['search']; $searchterm = strip_tags($searchterm); $searchterm = trim ($searchterm); $q ="SELECT * FROM locations WHERE loc_name LIKE '%" . $searchterm . "%' AND loc_approved != '0'"; $r = mysqli_query($conn, $q) or die(mysql_error($q)); $row = mysqli_fetch_assoc($r); $rowcount = mysqli_num_rows($r); } ?> <h1>Search for Scuba Dive Locations</h1> <form id="searchform" name="searchform" method="post" action="index.php"> <input type="text" name="search" id="search_bar" /> <input type="submit" name="submit" id="submit" value="Submit" /> </form> <span style="color: #333;">Search for the name of the location, ie: Devils Den or USS Oriskany.</span><br /> <?php if (isset($_POST['submit'])) { if ($rowcount == 0) { echo "Sorry, but we can not find an entry to match your query: <strong>$searchterm</strong>"; } else { //this tells the table below to display since $totalRows_Products_res is not 0 ?> <table style="font-size: 14px;" border="0" width="650"> <tr> <td colspan="6"><p>You searched for <strong><?php echo $searchterm; ?></strong>. Results are displayed below.</p></td> </tr> <tr> <td><strong>Location Name</strong></td> <td><strong>City</strong></td> <td><strong>State</strong></td> <td><strong>Depth (ft)</strong></td> <td><strong>Fees</strong></td> <td><strong>Gear Rentals</strong></td> <td><strong>Map</strong></td> </tr> <?php do { ?> <tr> <td><a href="loc_details.php?loc_id=<?php echo $row ['loc_id']; ?>"> <?php echo $row ['loc_name']; ?> </a></td> <td><?php echo $row ['loc_city']; ?></td> <td><?php echo $row ['loc_state']; ?></td> <td><?php echo $row ['loc_depth']; ?></td> <td>$<?php echo $row ['loc_fee']; ?></td> <td><?php if($row['loc_gear'] == 1) { echo 'Yes'; } else { echo 'No'; } ?></td> <td><a href="http://maps.google.com/maps?q=<?php echo $row ['loc_lat'];?>,<?php echo $row ['loc_lon'];?>" target="_blank">View Map</a></td> </tr> <?php } while ($row = mysqli_fetch_assoc($r)); ?> </table> <?php mysqli_free_result($r); } // this closes out results else } ?> I figure I can use the below query to get the results. Code: [Select] select * from table WHERE id > ((SELECT MAX(id) from table) - 10);I'm just not sure how I can display them by default and then have them be replaced by the search results. Anyone have any ideas for me? As always I appreciate the help as I continue to learn this beast. Hello everyone, I have a page with a short form with just a password field and a submit button. I also have php code setting variables depending on whether or not the password is correct. When the password is entered and the submit button is CLICKED, everything works as it should. However, when the password is entered and the ENTER button is pushed to submit the form, the form is reset and nothing else happens. Also, this only happens in I.E., it works fine with Firefox. I have plenty of other forms that I use in the same manner but they all work whether the submit button is clicked or the enter button is pushed to submit, regardless of what browser is used. The idea is to have this window close (it's opened as a pop-up) and the main window load the next page. Again, it works perfectly as long as the submit button is clicked but not if the enter button is pushed. Not sure if it has something to do with my php code or what. Any ideas on how to fix this? Here's my code: Code: [Select] <?php if (isset($_POST['submit'])) { $pword = md5($_POST['pword']); $q = mysql_query("SELECT * FROM `accounts` WHERE acct_number = '$acct' AND pword = '$pword'") or die (mysql_error()); $r = mysql_num_rows($q); // Checks to see if anything is in the db. if ($r == 1) { $student = "true"; } else { $student = "false"; } } else { $student = "unknown"; } ?> <!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=iso-8859-1" /> <title>Student Verification...</title> </head> <!-- <body> tag is in PHP --> <?php if ($student == "true") { echo "<body onunload=\"opener.location=('signup.php?acct1=$acct')\">"; } else { echo "<body>"; } if ($student == "true") { echo "<div align='center'>"; echo "<p><font size='+2'>Passcode Correct!</font></p>"; echo "</div>"; echo "<div align='justify'>"; echo "<p>You will now be directed to the signup page.</p>"; echo "</div>"; echo "<div align='center'>"; echo "<p>Thank you.</p>"; echo "<input type='button' value='Continue to Signup...' onClick='window.close()'>"; echo "</div>"; echo "<meta http-equiv=\"REFRESH\" content=\"20;url=close.php\">"; } elseif ($student == "unknown") { echo "<div align='center'>"; echo "<table width='325' height='175' border='0' cellspacing='0' cellpadding='0'>"; echo "<tr>"; echo "<td width='325' align='center' valign='middle'>"; echo "<p><font size='+1'><strong>Welcome!</strong></font></p>"; echo "<p>Please enter the school passcode.</p>"; echo "<form name='form' method='POST' action='schoolpw.php'>"; echo "<p><input type='password' name='pword' size='30' maxlength='20' /></p>"; echo "<input type='submit' name='submit' id='submit' value='Submit' /> "; echo "<input type='button' name='cancel' value='Cancel' onClick='window.close()' />"; echo "</form>"; echo "</p>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; } elseif ($student == "false") { echo "<div align='center'>"; echo "<table width='325' height='175' border='0' cellspacing='0' cellpadding='0'>"; echo "<tr>"; echo "<td width='325' align='center' valign='middle'>"; echo "<p><font size='+1'><strong>Welcome!</strong></font></p>"; echo "<p><font color='#FF0000'>Incorrect Passcode! Please try again.</font></p>"; echo "<form name='form' method='POST' action='schoolpw.php'>"; echo "<p><input type='password' name='pword' size='30' maxlength='20' /></p>"; echo "<input type='submit' name='submit' value='Submit' /> "; echo "<input type='button' name='cancel' value='Cancel' onClick='window.close()' />"; echo "</form>"; echo "</p>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; } ?> </body> </html> I am bit confused. Can we display the latest tweet in the webpage. Hi, I want to get a latest video from Youtube Playlist. I look it on Google API, and the other solutions, but I think dont undestand quit good what I need to do. For example a have a playlist: https://www.youtube.com/playlist?list=PLW8l7rX2YaXkaSI8GGbmqPjOEmfzd2hz3 And I want to see always only a latest uploaded video, so I need a link (embed - watch, or "youtu.be/xy"): https://www.youtube.com/watch?v=LyzziLETNUw&list=PLW8l7rX2YaXkaSI8GGbmqPjOEmfzd2hz3 Thanks in advanced, T Hi Guys, Sorry if this is the wrong forum but i wasnt sure the best one. i am trying to see how others control the version of apps they have written and updating. i want to set the version of my app e.g. 1.0 and then have a section where if i release 1.5 it will show up that a new version is available for upgrade. the only thing im not too sure about is when someone goes to upgrade if not all of the updated files are uploaded correctly i want it to say version missmatch. could someone give me examples of how i could achieve this? I'm in the process of creating a webage that shows latest scores and an updated league table for soccer/football matches like the bbc sports website does. I have the database set up with a form to update and display latest score all work well apart from if i update a score like the following teamA 1 teamB 0 it updates table to give teamA 3 points based on the current score however if teamA score again teamA 2 teamB 0 it updates table again but gives teamA another 3 points which is not correct so i need a way to stop it happening. thought about it for a while and only thing i can come up with is some maths to compare the values of score for each team and add/remove points as dependent on current score. Anyone got something similar to this I'm having trouble listing the most recent 10 content. How can I solve this problem. $sorgu = mysqli_query("select * from icerik order by id desc limit 0,10");
while($goster=mysqli_fetch_assoc($sorgu)) { } error code: Fatal error: Uncaught ArgumentCountError: mysqli_query() expects at least 2 arguments, 1 given in C:\xampp\htdocs\blog\orta.php:3 Stack trace: #0 C:\xampp\htdocs\blog\orta.php(3): mysqli_query('select * from i...') #1 C:\xampp\htdocs\blog\index.php(4): include('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\blog\orta.php on line 3 Hello all, My question is about a custom-coded latest-news plugin written by someone else. I don't know if it is generic, a copy of something else or what. It works good! but when I go to add a new news item to the list under Settings, it adds the item to the bottom of the list. The news is displayed on my homepage in short form and in full format on the primary news page. I need new items to be added to the TOP of the list instead or in reverse, so that in all the containers where it resides, the latest news item added is always at the top of the list. I know nothing about php but I am looking to learn. I plan on taking some basic classes on css and php to upgrade my archaic html skills, but I'm currently studying other subjects. Regardless, if this has a simple fix, I would be very interested in knowing what is needed and where/why. Here is the core of the php that I am finding in the plugin: There are three php files, This one says active, the other two say inactive so I get the impression they are not in use. Let me know if I should post their contents as well. Appreciate any help with this! My sincere thanks in advance. Labeled active: latest_news.php */ob_start();register_activation_hook(__file__, latest_news_install);function latest_news_install() { global $wpdb; $table_name = $wpdb->prefix . "latest_news"; if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { $sql = "CREATE TABLE IF NOT EXISTS " . $table_name . " ( `id` int(10) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `description` text NOT NULL, `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id) );"; mysql_query($sql) or die(mysql_error()); }}if( !function_exists('wp_latest_news_init') ) { function wp_latest_news_init() { add_shortcode( 'wp_latest_news', 'shortcode_latest_news'); }}if( !function_exists('shortcode_latest_news') ) { function shortcode_latest_news() { // extract(shortcode_atts(array('limit' => '5', ), $atts)); global $wpdb; $user_count = $wpdb->get_results("SELECT * FROM wp_latest_news ORDER BY date ASC LIMIT 4"); foreach ($user_count as $output) { $htmlOutput[] = "<li><b><a href='". get_permalink(287)."?news_id=".$output->id."'>" . $output->title . "</a></b></li>"; } //echo $htmlOutput; //echo "<pre>"; print_r($user_count); echo "</pre>"; foreach ($htmlOutput as $out) { echo $out; } return $htmlOutput; }}/* add_action('init', 'wp_latest_news_init' ) is used for call init function for create shortcode */add_action('init', 'wp_latest_news_init' );add_action('admin_menu', 'wp_latestnews_links' );function wp_latestnews_links() { add_submenu_page( 'options-general.php', __( 'Latest News ' ), __( 'Latest News ' ), 5 , 'latest_news_settings', 'latest_news_settings' );}// function latest_news_settings() {// global $wpdb;// if (isset($_POST["submit"])) {// $sql="INSERT INTO ".$wpdb->prefix . "latest_news(`title`,`description`) VALUES ('".$_POST['news_title']."','".$_POST['description']."') ";// //$sql=$wpdb->insert( $wpdb->latest_news, array( 'title' => $_POST['news_title'] ,'description' => $_POST['description'] ) );// mysql_query($sql) or die(mysql_error());// }// include 'Latest_news_setting.php';function latest_news_settings() { global $wpdb; $action = $_REQUEST["action"]; $id = $_REQUEST['id']; $sql = "SELECT * from ".$wpdb->prefix."latest_news "; $results = $wpdb->get_results($sql); //echo "<pre>";print_r($results); //$post_arr = query_posts(""); //echo "<pre>";print_r($post_arr);exit; switch ($action) { case 'add' : include('news_form.php'); break; case 'save' : if(isset($_POST['cancel'])) { include('latest_news_list.php'); } else if(isset($_POST['add'])) { $wpdb->query("insert into ".$wpdb->prefix."latest_news (`title`,`description`) VALUES ('".$_REQUEST['news_title']."','".$_REQUEST['description']."')"); //header("Location: http://localhost:81/Bravo/wp-admin/edit.php?page=slider_images"); header("location:?page=latest_news_settings"); } break; case 'edit' : $sql = "SELECT * from ".$wpdb->prefix."latest_news where id = '".$id."' "; $results_arr = $wpdb->get_results($sql); //echo "<pre>";print_r($results_arr); include('news_form.php'); break; case 'update' : if(isset($_POST['cancel'])) { include('news_form.php'); } else if(isset($_POST['edit'])) { //echo $id; $wpdb->query("update ".$wpdb->prefix."latest_news set title = '".$_REQUEST['news_title']."', description = '".$_REQUEST['description']."' where id='".$id."'"); header("location:?page=latest_news_settings"); } break; case 'delete' : $wpdb->query("delete from ".$wpdb->prefix."latest_news where id='".$id."'"); header("location:?page=latest_news_settings"); break; default: include('latest_news_list.php'); break; }}?>() Hello guys, I've been reading through various threads here about getting latest tweets with php but they're all basically methods I've seen before, and involve getting the tweets from the atom feed xml. I've been experimenting with various code snippets that do this on my site, and most of the time they work. But about one in every 10 times it doesn't, because for some reason the tweet doesn't appear in the atom feed. I guess this is a problem with Twitter, but I've google this, and to be honest there's only a few whispers from people that could be experiencing something like this problem, which makes me wonder whether I'm just unlucky or being stupid and overlooking something..? I don't see what though. Anyway I know there's methods where you can actually log into your twitter acount and post tweets, and all the rest of it, but the codes I've found are all extremely lengthy and arcane, and do far more than what I want them to. So what I'm wondering is- has anyone used this foolproof method of retrieving tweets, and if so I wonder is you could share your code with me, or point me in the right direction? All I want to do is get my latest tweet and display it on my site. Many Thanks I need to find the earliest and latest times, but there must be at least 3 to count it. $array[] = "09:00 - 15:00" $array[] = "09:00 - 15:00" $array[] = "09:00 - 15:00" $array[] = "09:00 - 17:00" $array[] = "09:00 - 15:30" $array[] = "07:30 - 15:00" $array[] = "07:00 - 12:00" So the above would return 09:00 - 15:00 I thin would need to ensure that a maximum 4 hours inbetween, so I then get something like 10:00 - 14:00 returned hello dear Linux-experts well at the moment i wonder how i can find out the latest schools at openstreetmap - note: i focus on a country - south america and he on Argentina: so here we go [date:"2014-09-18T00:00:00Z"];area[name="Argentina"][boundary=administrative]->.a;(node(area.a)[amenity=school];way(area.a)[amenity=school];);out center;js this doable with overpass-api.de or with overpass-turbo.eu love to hear from you Hi there, I have updated a webpage and it appears that some users are still seeing the older version of the page. Is there a way I can force the user's version of the page to display the latest content on the page? I have see I can add some meta tags which control the cache, but my site relies quite heavily on cookies, so I guess clearing the cache would reset/have an effect on the cookies? Does anyone have any ideas on how I can make users always see the latest content? Thanks! Hi friends i have latest rss news feed im my php site, i would like to share latest 5 rss feed so some of our partners can publish in thier site . How to do it ? now i use this code to show where the visitors came from to my site. <?php $referer=$_SERVER['HTTP_REFERER']; echo $referer; ?> now, i want to show the 5 latest vistors referer's site url on my site ? 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 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! 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); ?> 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??? } ?> |