Jump to content

Gazan

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Everything posted by Gazan

  1. I know of that, and not to sound rude, but i asked for an example so i could understand how to output it with php..
  2. Alright, here goes. I have a table that consists of numbers (123, 918, 328, 190) etc.. What i want to do is to get the average number from the database, and output them by php. How do i do that? if you could, please provide me with an example. I'd be very greatfull if you would
  3. Hmm, get what you mean, but could you provide me with an example? with, artists for example.. I'd be very thankfull if you would
  4. My question is very simple, however i cant seem to figure it out.. How do i explode a string and store each exploded word into an array? So the array will hold a key value for each word in the string. Thanks in advantage
  5. Yeah, i see that now.. I'd love to but, somehow i don't have access to do so.. :s
  6. Yeah, thats what i'd like. Like, the links in the menu will be as i've typed with www.url.com/index.php?show=example. But when i go onto the page (www.url.com/index.php) it shall show some content as default, and then when you click some of the menu links, it will go to one of the switch options with the matching value. EDIT: I get the following error "no index defined" with the script..
  7. Hey experts, i'm having this issue with switch.. It's just that, i use it to show different pages. Etc. www.url.com?show=gallerypage, www.url.com?show=contactpage. I want to show some content by default, if none of the above options are chosen. My code are as follow: $page = $_GET['page']; switch ($page) { case 'contactpage': echo "This is the contact page."; break; case 'gallerypage': echo "This is the gallery page': break; default: echo "This is the frontpage."; break; } with this i want to make it like, if there has not been chosen a $page then it shows the default "This is the frontpage." But how do i make it work like that?
  8. Hello experts. How do i get all files (.php) from a specefied folder, and store them into an array?
  9. Yeah i get that.. But how would you insert it into php? would you store it into a function to display in every page?
  10. Lately i've been wondering how do you insert a html header into a site? Like, would you store the html code for the header into a function and then call it on your php page? Another question, when you do html div's? do you store them into arrays and display them via variables? Some thing i'm very curious about.. If my question is not understandable, please reply so.. Thanks in advance
  11. Dreamweaver is a good help for highlighting your code, that's it really.. (Even though i use it mysql). As mentioned, you need to learn the language before you can speak it. Go read tutorials, it will take a while to get into it, but once you're in it, you can create almost whatever you'd like to.
  12. What would be a better way of doing it then? Anyhow, thanks alot.
  13. Hey all. I'm stuck doing a mysql search function for my project.. What i have now, only returns results that matches 1 keyword in my form. What i want to, is to search for multiple keywords. I've been googling around, reading some tutorials, but i don't get the concept of explode() and storing the keywords into and array, and then do a query where you search for keywords that matches that array.. I need some explanation on how to do this. Current code: if(isset($_POST['keyword'])) { $keyword = $_POST['keyword']; if(empty($keyword)) { echo "You need to type a keyword to search for."; } else { $keyword = mysql_real_escape_string($keyword); $sql = "SELECT * FROM nyheder WHERE news_subject OR news_content LIKE '%".$keyword."%' ORDER BY news_date AND news_time"; $result_search_news = mysql_query($sql); $count_search_news = mysql_num_rows($result_search_news); if($count_search_news==0) { echo "You search for "<b>".$keyword."</b>" gave no results."; } else { echo "Your search for "<b>".$keyword."</b>" gave ".$count_search_news." results:"; echo "<br /><br />"; while($news_search = mysql_fetch_array($result_search_news)) { echo $news_search['news_subject']; echo "<br />"; } } } }
  14. Gazan

    PHP Help!

    Now tizag has been mentioned a few times, i'd like to mention www.w3schools.com. That's i've learned to script javascript, php, css and so on. You learn the basics from there, then you need to go further with your fantasy to combine your coding into.. Yeah, whatever you want to make!
  15. <?php //Your form goes here.. if(isset($_POST['preview'])) { echo "Here is a preview"; //Output the variables they filled in.. echo $title; echo $weblog_entry; } ?> Replace the variables with whatever variables you're using. It's not as hard as it seems. You just take the variables they've filled in, and then output them on the same page IF they've pressed "preview". EDIT: what maq said.
  16. Hmm. All your examples just keeps giving me the same error.. EDIT: Thanks everyone! got it to work. Especially thanks Mikedean, second try on your example did it! And yeah, - i'll put the connection inside the query class. - Thanks for the tip
  17. Nope.. Still not working. The code you posted just returns the same error, just line 19 instead of 20. EDIT: I know, this was just made pretty quickly, and im new to OOP. I tried this out instead, but didn't work either. <?php class query { function sql_connect() { mysql_connect("localhost", "root", ""); mysql_select_db("underskrift"); } function sql_query($sql) { $this->sql_connect(); mysql_query($sql) or die(mysql_error()); } function sql_row($result) { mysql_fetch_array($result); } } $query = new query; $sql = 'SELECT * FROM underskrifter'; $result = $query->sql_query($sql); while($row = $query->sql_row($result)) { echo $row['underskrift_navn']; } ?>
  18. Hey there. I can't make my script work.. I'm using the db class for connecting, and the query class for doing the sql queries. but when i output the code below, it returns: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\test.php on line 20 However, if i do the sql queries without using classes it works perfect, of course. Heres my source (Notice: It has nothing to do with the missing password in the connect, 'cause i don't use pass for my offline server..): <?php class db { function db_connect() { mysql_connect("localhost", "root"); mysql_select_db("underskrift"); } } class query { function sql_query($sql) { global $db; $db->db_connect(); mysql_query($sql) or die(mysql_error()); } function sql_row($result) { mysql_fetch_array($result); } } $db = new db; $query = new query; $sql = 'SELECT * FROM underskrifter'; $result = $query->sql_query($sql); while($row = $query->sql_row($result)) { echo $row['underskrift_navn']; } ?>
  19. Hey there. I've got a problem with the login system im creating. I'm really new to classes and objects, so i suppose it's there the problem exists.. Anyway, my problem is; when i hit login in the login form, it won't log me in before i hit it the 2nd time. So i have to hit login twice before it logs me in, and that happens everytime.. Heres the code for index.php (login page) and classes.php (self describe..) Classes.php: <?php class User { function display_userpanel() { print "Welcome to the user panel.<br /> <a href='logout.php'>Log ud</a>"; } function display_loginform() { require_once("loginform.html"); } function process_login() { if(isset($_POST['brugernavn'])) { mysql_connect("localhost", "root"); mysql_select_db("underskrift"); $query = mysql_query("SELECT * FROM admin WHERE admin_brugernavn ='".$_POST['brugernavn']."' AND admin_password = '".$_POST['password']."' LIMIT 1"); $result = mysql_num_rows($query); if($result==1) { $_SESSION['in_user_id'] = true; } } } function process_logout() { session_start(); session_destroy(); header('location: index.php'); } function logged_in() { if(isset($_SESSION['in_user_id'])) { return true; } else { return FALSE; } } } $User = new User; ?> And the login page (Index.php): <?php require "classes.php"; session_start(); if($User->logged_in()) { $User->display_userpanel(); } elseif($User->process_login()) { } else { $User->display_loginform(); } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.