Jump to content

Kaizen Maven

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Kaizen Maven's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I wanted to use the id number from some data that I have in a database to print out the link, name of the link, and a description in a unordered list. I also want to be able to put it in alphabetical order. Here is the code we currently have... THIS STARTS AT THE TOP OF THE PAGE, BEFORE THE DOCTYPE... //bibliography //scribner writers series $sql1 = mysql_query('SELECT * FROM research_databases WHERE id = 254'); $sql11 = mysql_query('SELECT * FROM research_databases WHERE id = 253'); //biography $sql2 = mysql_query('SELECT DISTINCT r.id, r.db_name, r.db_url, r.comments FROM research_databases r INNER JOIN lnk_subjects_databases l ON r.id = l.database_id WHERE l.subject_id = 49 ORDER BY db_name ASC'); //demographics/statistics $sql3 = mysql_query('SELECT DISTINCT r.id, r.db_name, r.db_url, r.comments FROM research_databases r INNER JOIN lnk_subjects_databases l ON r.id = l.database_id WHERE l.subject_id = 56 ORDER BY db_name ASC'); //dictionaries/encyclopedias/thesauri $sql4 = mysql_query('SELECT DISTINCT r.id, r.db_name, r.db_url, r.comments FROM research_databases r INNER JOIN lnk_subjects_databases l ON r.id = l.database_id WHERE l.subject_id = 57 ORDER BY db_name ASC'); //history/political science $sql5 = mysql_query('SELECT DISTINCT r.id, r.db_name, r.db_url, r.comments FROM research_databases r INNER JOIN lnk_subjects_databases l ON r.id = l.database_id WHERE l.subject_id = 25 OR l.subject_id = 34 ORDER BY db_name ASC'); //access science $sql6 = mysql_query('SELECT * FROM research_databases WHERE id = 180'); //engineering information village $sql7 = mysql_query('SELECT * FROM research_databases WHERE id = 181'); //health & wellness $sql8 = mysql_query('SELECT * FROM research_databases WHERE id = 182'); //accunet photo archive $sql10 = mysql_query('SELECT * FROM research_databases WHERE id = 156'); //database $sql12 = mysql_query('SELECT * FROM research_databases WHERE id = 414'); ....AND THIS IS THE WHILE LOOPS THAT CURRENTLY PRINTS OUT WHAT WE HAVE... <?php if (mysql_num_rows($sql4)>0) { echo "<ul>"; while ($row6 = mysql_fetch_array($sql6)) { echo "<li><a href=\"{$row6['db_url']}\">{$row6['db_name']}</a><br>"; if (strlen($row6['comments']) > 0) { echo "{$row6['comments']}"; } } while ($row4 = mysql_fetch_array($sql4)) { echo "<li><a href=\"{$row4['db_url']}\">{$row4['db_name']}</a><br>"; if (strlen($row4['comments']) > 0) { echo "{$row4['comments']}"; } } ?> My problem is that I would like to add other links to the list (but put them in alphabetical order), but I'm not seeing how to do that with the while loop. So I thought it would be easier just to call all the id with a SELECT statement and then use ORDER BY db_name ASC. I just can't get the syntax right.
  2. I found this php script lastRSS. That will spit out your RSS feed headers as an ul list. I just can't make it work. The instructions are to place the snippet of code on your page. Here is what I have: <h1>News Test</h1> <?php // include lastRSS library include 'lastRSS.php'; // create lastRSS object $rss = new lastRSS; // setup transparent cache $rss->cache_dir = './cache'; $rss->cache_time = 3600; // one hour // load some RSS file if ($rs = $rss->get('http://tulanelib.blogspot.com/feeds/posts/default')) { // here we can work with RSS fields } else { die ('Error: RSS file not found...'); } ?> , then the author gives you the file lastRSS.php to upload to the same directory. (Which I have done). But nothing prints out. See example here.
  3. Thank you, I'm guessing SERVER_NAME would be a better option, as it could be used for both servers.
  4. Hi, we have a main server that holds our actual website and then a test server that we can test different things on. The domain for the real server and the test server are different. So I thought about using <?php $_SERVER['REQUEST_URI']?> for to replace all the full paths. For example, instead of having: <a href="http://www.mydomain.com/article/item1.php/">Item 1</a> . I could just put <a href="<?php $_SERVER['REQUEST_URI']?>/article/item1.php/">Item 1</a> . Which would bring back the same thing. Would this be wise? Is there anything I need to know before I do this? Thanks
  5. Side Note: I just made all the "_id" for each table a primary key, so that I can move on with the tutorial. Hopefully that will work, but I'll come back if I have any questions.
  6. Ok, so basically PRIMARY KEY & KEY are the same thing, and I can set them both in the PHPmyAdmin I just tried to make the movie_id, movie_type, and movie_year the primary key and my PHPAdmin said
  7. Ok, so I just said the hell with it and I'll do i from PHPMyAdmin. Now I'm familiar with setting up tables and inputting the fields with their settings. But the book says to type this: $movie = "CREATE TABLE movie ( movie_id int(11) NOT NULL auto_increment, movie_name varchar(255) NOT NULL, movie_type tinyint(2) NOT NULL default 0, movie_year int(4) NOT NULL default 0, movie_leadactor int(11) NOT NULL default 0, movie_director int(11) NOT NULL default 0, PRIMARY KEY (movie_id), KEY movie_type (movie_type,movie_year) ) TYPE=MyISAM AUTO_INCREMENT=4"; I know how to convert the movie_id, name, type, leadactor, and director into fields. But what about the PRIMARY KEY & KEY. In PHPMyAdmin what do I make the KEY? I see icons for Primary (with Key), also for Index, Unquie, and Fulltext. But do I make the movie_id field and the movie_type and year the primary key? Or just one?
  8. Yes I am using cPanel with my hosting. So should I just create the tables, etc with my PHPAdmin???
  9. I have just read this post: http://www.phpfreaks.com/forums/index.php/topic,95378.0.html, but this seems to apply for someone that has PHP installed on their computer or local machine. I am using a hosting server and my hosting company has PHP 5.0.4 installed. I am trying to work on creating tables for a database using the book "Beginning PHP, Apache, MySQL Web Development", and for some reason I can not seem to connect to the MySQL DB. Here is my code: <?php //Connect to MySQL DB. $connect = mysql_connect("localhost","php","mypasshere") or die ("Hey loser, this dog anit gonna hurt. You might want to check your server connection."); //Create the main database mysql_create_db("php") or die(mysql_error()); //Make sure our recently created database is the active one mysql_select_db("php"); //Create the "movie" table $movie = "CREATE TABLE movie ( movie_id int(11) NOT NULL auto_increment, movie_name varchar(255) NOT NULL, movie_type tinyint(2) NOT NULL default 0, movie_year int(4) NOT NULL default 0, movie_leadactor int(11) NOT NULL default 0, movie_director int(11) NOT NULL default 0, PRIMARY KEY (movie_id), KEY movie_type (movie_type,movie_year) ) TYPE=MyISAM AUTO_INCREMENT=4"; $results = mysql_query($movie) or die (mysql_error()); //Create "movietype" table $movietype = "CREATE TABLE movietype ( movietype_id int(11) NOT NULL auto_increment, movietype_label varchar(100) NOT NULL, PRIMARY KEY (movietype_id) ) TYPE=MyISAM AUTO_INCREMENT=9"; $results = mysql_query($movietype) or die(mysql_error()); //Create "people" table $people = "CREATE TABLE people ( people_id int(11) NOT NULL auto_increment, people_fullname varchar(255) NOT NULL, people_isactor tinyint(1) NOT NULL default 0, people_isdirector tinyint(1) NOT NULL default 0, PRIMARY KEY (people_id) ) TYPE=MyISAM AUTO_INCREMENT=7"; $results = mysql_query($people) or die (mysql_error()); echo "Movie Database Successfully Created!"; ?> I do have PHPMyAdmin, and I know I could do it through there, but I am trying to follow the book. I created the db php (cbxwebde_php) through my cPanel, and then created the username php (cbxwebde_php), then my password. Should I have done this first? I am getting this message: Thanks for any help.
  10. Yes...another person wrote this php code a while back, and I'm somewhat of a n00b myself, so you'll have to forgive me. I see that this snippet of code <?php } while ($row1 = mysql_fetch_array($sql1)) { if ($row1['dept_head'] == "Y") { $strong = "<strong>"; $endstrong = "</strong>"; } else { $strong = ""; $endstrong = ""; } if ($a % 2 == 0) { $class = 0; } else { $class = 1; } if ($order2 == "dept_head") { echo "<tr><td class=\"alt" . $class . "\">{$row1['dept']}</td>" . "<td class=\"alt" . $class . "\">" . $strong . "{$row1['firstName']} {$row1['lastName']}". $endstrong . "</td>" . "<td class=\"alt" . $class . "\"><a href=\"mailto:{$row1['email']}\">{$row1['email']}</a></td>" . "<td class=\"alt" . $class . "\">{$row1['title']}</td>" . "<td class=\"alt" . $class . "\">(504){$row1['phone']}</td></tr>"; $a++; } if ($order2 != "dept_head") { echo "<tr><td class=\"alt" . $class . "\">" . $strong . "{$row1['firstName']} {$row1['lastName']}". $endstrong . "</td>" . "<td class=\"alt" . $class . "\"><a href=\"mailto:{$row1['email']}\">{$row1['email']}</a></td>" . "<td class=\"alt" . $class . "\">(504){$row1['phone']}</td>". "<td class=\"alt" . $class . "\">{$row1['dept']}</td>" . "<td class=\"alt" . $class . "\">{$row1['title']}</td></tr>"; $a++; } } ?> is doing most of the work. But is there any reason why the information would just stop coming from the mySQL DB?
  11. @GhettoT, Yes more or less: Here is the actual code itself <?php include('../includes_global/db_connect.php'); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta name="keywords" content="Tulane, Tulane University, Howard-Tilton, Memorial, Library, New Orleans, special collections, rare books, jazz archive, manuscripts, latin american library, latin, american, music and media, maxwell music library, music library"> <meta name="description" content="Welcome to the web site for the main library at Tulane University (New Orleans, LA USA), Howard-Tilton Memorial Library."> <meta http-equiv="Content-Language" content="EN-US"> <meta name="Abstract" content="Welcome to the web site for the main library at Tulane University (New Orleans, LA USA), Howard-Tilton Memorial Library."> <meta name="Robots" content="index,follow"> <meta name="author" content="Christopher Boudy"> <title>Howard Tilton Memorial Library at Tulane University (Library Staff: Staff Directory)</title> <link rel="stylesheet" type="text/css" href="../css/layouts/staff_layout.css"> <link rel="stylesheet" type="text/css" href="../css/main.css"> <link rel="stylesheet" type="text/css" href="../css/menus/staff_side_menu.css"> <link rel="stylesheet" type="text/css" href="../css/nav_menu.css"> <!--[if IE]> <link rel="stylesheet" type="text/css" href="../css/ie_nav_menu.css"> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="../css/ie7_nav_menu.css"> <![endif]--> <link rel="alternate stylesheet" type="text/css" href="../css/medium.css" title="A"> <link rel="alternate stylesheet" type="text/css" href="../css/large.css" title="A+"> <script src="../js/styleswitcher.js" type="text/javascript"></script> <link rel="shortcut icon" href="../images/favicon.ico"> </head> <body> <!-- Jump Links --> <?php include('../includes_global/jumplinks.php'); ?> <!-- Off Campus Login --> <?php include('../includes_global/off_campus_link.php'); ?> <!-- Text Resize --> <?php include('../includes_global/textresize.php'); ?> <div id="container"> <div id="header"> <!-- Top Navigational Menu --> <?php include('../includes_global/nav_menu.php'); ?> </div> <div id="left"> <!-- Side Navigational Menu --> <?php include('../includes_local/staff_side_nav.php'); ?> <div class="sidelinks"> <a href="http://dreamland.tcs.tulane.edu/~testlib/staff/staff_directory.php?order1=lastName&ascdesc1=asc" title="View By Last Name"> <img src="../images/lname.gif" alt="View By Last Name" width="30" height="30" class="left"> View By Last Name</a> <br> <br> <a href="http://dreamland.tcs.tulane.edu/~testlib/staff/staff_directory.php?order1=firstName&ascdesc1=asc" title="View By First Name"> <img src="../images/fname.gif" alt="View By First Name" width="30" height="30" class="left"> View By First Name</a> <br> <br> <a href="http://dreamland.tcs.tulane.edu/~testlib/staff/staff_directory.php?order1=dept&order2=dept_head&ascdesc1=asc&ascdesc2=desc" title="View By Department"> <img src="../images/dept.gif" alt="View By Department" width="50" height="30" class="left"> View By Dept</a> <br> <br> <a href="dept_info.php"> <img src="../images/phone2.gif" alt="View By Department" width="50" height="40" class="left"> View By Phone</a> </div> </div> <div id="right"> </div> <div id="content"> <h1>Staff Directory</h1> <strong>Note</strong>: A name in <strong>bold</strong> indicates a department head or main contact. <br> <?php $order1 = $_GET['order1']; $order2 = $_GET['order2']; $ascdesc1 = $_GET['ascdesc1']; $ascdesc2 = $_GET['ascdesc2']; if (strlen($order1) < 1) { $order1 = "lastName"; } if (strlen($order2) < 1) { $order2 = ""; } if (strlen($ascdesc2) < 1) { $ascdesc2 = ""; $joiner = ""; } else { $joiner = ", "; } $sql1 = mysql_query('SELECT * FROM lnk_depts_staff l, library_staff s, library_depts d WHERE l.staff_id = s.id AND l.dept_id = d.id ORDER BY ' . $order1 . ' ' . $ascdesc1 . $joiner . $order2 . ' ' . $ascdesc2); ?> <table> <?php if ($order2 == "dept_head") { ?> <tr> <td class="table_title">Department</td> <td class="table_title">Name</td> <td class="table_title">Title</td> <td class="table_title">Email</td> <td class="table_title">Phone Number</td> </tr> <?php } else { ?> <tr> <td class="table_title">Name</td> <td class="table_title">Email</td> <td class="table_title">Phone Number</td> <td class="table_title">Department</td> <td class="table_title">Title</td> </tr> <?php } while ($row1 = mysql_fetch_array($sql1)) { if ($row1['dept_head'] == "Y") { $strong = "<strong>"; $endstrong = "</strong>"; } else { $strong = ""; $endstrong = ""; } if ($a % 2 == 0) { $class = 0; } else { $class = 1; } if ($order2 == "dept_head") { echo "<tr><td class=\"alt" . $class . "\">{$row1['dept']}</td>" . "<td class=\"alt" . $class . "\">" . $strong . "{$row1['firstName']} {$row1['lastName']}". $endstrong . "</td>" . "<td class=\"alt" . $class . "\"><a href=\"mailto:{$row1['email']}\">{$row1['email']}</a></td>" . "<td class=\"alt" . $class . "\">{$row1['title']}</td>" . "<td class=\"alt" . $class . "\">(504){$row1['phone']}</td></tr>"; $a++; } if ($order2 != "dept_head") { echo "<tr><td class=\"alt" . $class . "\">" . $strong . "{$row1['firstName']} {$row1['lastName']}". $endstrong . "</td>" . "<td class=\"alt" . $class . "\"><a href=\"mailto:{$row1['email']}\">{$row1['email']}</a></td>" . "<td class=\"alt" . $class . "\">(504){$row1['phone']}</td>". "<td class=\"alt" . $class . "\">{$row1['dept']}</td>" . "<td class=\"alt" . $class . "\">{$row1['title']}</td></tr>"; $a++; } } ?> </table> </div> <div id="footer"> <!-- Footer --> <?php include('../includes_global/footer.php'); ?> </div> </div> </body> </html> I just can't figure out what it stopped spitting out the info??? Would it have anything to do with the space in mySQL for this table: Space usage : Type Usage Data 7,864 Bytes Index 3,072 Bytes Overhead 1,068 Bytes Effective 9,868 Bytes Total 10,936 Bytes My overhead was red, and I didn't know what this meant.
  12. Hi, We have a staff directory at work that pulls: first name, last name, phone number, etc from a mySQL DB and displays them in a table. We also have a backend section where you can input the information. For some reason, I want to input a new employee in the backend and it didn't show up on the frontend of our site. Nothing was touched, it just seemed to stop working. If need be I can post the code.... Thank you for any help on this:
  13. Hi everyone, I've been trying to find a good php forum to be involved in and this one seems like a good place to call php home. Anyway, I'm looking for a PHP script that I can use for my clients. I want them to have the ability to login in, update their contact info, see blueprints that we have come up with, pay their bill, send me updates, etc. I am actually going to add some PHP functionally later, but I'm just looking for something that is very customizable. I saw a couple of things on HotScripts, but none of them were up to date. All I really need for it to do is to be able to log them, have a forgot password or username thing, and update the contact info. I'll add the rest of the stuff later. Any suggestions would be great!
×
×
  • 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.