Jump to content

simcoweb

Members
  • Posts

    1,104
  • Joined

  • Last visited

Everything posted by simcoweb

  1. Ok, thanks for adding some clarification to that :) I'm setting up the query to create the multiple tables to handle the members, specialties, categories, and member_catid as you've laid out. The part of the project i'm working on right now is the right syntax to get the current data that I have and display it inside the HTML that I have laid out on that example page [url=http://www.plateauprofessionals.com/display.php]http://www.plateauprofessionals.com/display.php[/url] Right now i'm using a while statement as so: [code]mysql_connect($dbhost, $dbuser, $dbpass) or die('No database here, boss'); mysql_select_db($dbname) or die('That database can not be found, boss.'); $sql=("SELECT * FROM members"); $result = mysql_query($sql) or die('Can not find that database today'); while ($row = mysql_fetch_array($result)) { echo <<<HTML[/code] But no results show in the output. I'm using variables throughout the HTML like so: <tr> <td style='border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top: 1px dotted #666633; border-bottom-width: 1px; padding: 4px' width='46%' bgcolor='#E3E1E1'><font class='bodytext'> <i>• $title</i></td> </tr> The HTML outputs fine with no errors. Just no data populates the HTML. I've concluded that using the 'while' loop is probably not the right way to go and i'm thinking a 'foreach' function instead. Once again, the goal is to have the HTML repeat for each profile pulled from the database. So, in a simple logical code example (most likely NOT proper syntax): [code]foreach ($row = mysql_fetch_array($result)) { echo <<<HTML // all the HTML here } [/code] All the examples i've viewed in tutorials show simple table useage for the results and using the .$row['name'] syntax like this: [code]echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>Age</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['name']; echo "</td><td>"; echo $row['age']; echo "</td></tr>"; } echo "</table>";[/code] I'm using one universal 'echo' statement instead of doing it for separate lines. Once again, looking for a little guidance in this :)
  2. Also, I think it's important to understand how the database will interact with the visitors. Basically like this: * visitor comes to site, views home page, is presented with the 4 main categories. * visitor clicks on a category and is taken to a page that displays a 'summary' of each profile in that category (up to 'x' then pagination takes over) * summary will contain a thumbnail, name, company name and title with a link to their full profile * full profile will contain pic, name, title, company, location, email, url to their site, details of their services and list of specialties A search function will be in place for them to search by keyword as well.
  3. Hmmm, ok... so what I could do is possibly create a series of checkboxes as a method of them selecting both the category they belong in AND the specialties they offer. Then those would be written to the database accordingly and make the connection between them. Or a similar way of selecting the specialties other than checkboxes. That could be a LOT of checkboxes. Also, if you could, please.. as i'm learning studiously as I go along... explain just a bit of this code you posted. The 'm.id' for example. I'm not family with that syntax and any explanations you can offer are greatly appreciated as to how you utilize this code. Thanks! [code]SELECT m.id FROM member m INNER JOIN speciality s ON m.memberid = s.memberid WHERE s.speciality IN ('Divorce', 'Family Law', 'Matrimonial') ORDER BY s.speciality[/code]
  4. Thanks for those great examples :) Now, as far as the 'specialties', instead of a textarea then what would you recommend? Perhaps a series of text boxes labeled like 'specialty1', 'specialty2', etc. ? I'm not 100% clear on your example for separating those to be more searchable.
  5. Corbin, thanks for that explanation. After reading Barand's post I just think i'm using the wrong method. Basically the data presenation flow should go like this: * visitor comes to the home page and is presented with 4 category choices (let's say A, B, C and D for fun) * visitor clicks on D * I need all profiles associated with D to show up (actually it will be a brief mini-listing) * when link in mini-listing is clicked on it will take the visitor to the member's full profile I'm not sure if I should be using a 'while' or a 'foreach' function. Barand, in your outline then i'd create these additional tables as well as set up an auto-incremental field for the id's.. correct? Now, in the profile form I need to, in some cases, pass the data into more than one table. Not sure how to handle that part. Also, quick note, in the 'Specialties' field I was going to make that just a text field (text area). I'm assuming it would still be workable the way you have it structured.
  6. First, thanks for your responses :) Second, can you elaborate on that a bit, please? I'm not sure how you mean that would apply to printing that data into the various locations i've laid out in the HTML. Thanks!
  7. Cool. Ok, i've worked up a test script in order to test the display of the user's profiles. The problem is it displays the HTML just fine but no data inserted. You can view this at www.plateauprofessionals.com/display.php [code]<?php // test to display addbiz results include 'config.php'; mysql_connect($dbhost, $dbuser, $dbpass) or die('No database here, boss'); mysql_select_db($dbname) or die('That database can not be found, boss.'); $sql=("SELECT * FROM members"); $result = mysql_query($sql) or die('Can not find that database today'); while ($row = mysql_fetch_array($result)) { echo <<<HTML <div align='center'> <table border='0' cellpadding='0' style='border-collapse: collapse' width='530'> <tr><td colspan='2'> <img border='0' src='http://www.plateauprofessionals.com/images/top.gif' width='530' height='35'></td> </tr><tr> <td height='15' colspan='2'> <h2>$name</h2></td> </tr> <tr> <td style='padding-left: 10px; padding-right: 10px; padding-top:5px; padding-bottom:5px' width='229' valign='top'>$image</td> <td style='padding-left: 10px; padding-right: 10px' width='261'> <div align='center'> <table border='0' cellpadding='0' style='border-collapse: collapse' width='100%'> <tr> <td style='border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top: 1px dotted #666633; border-bottom-width: 1px; padding: 4px' width='46%' bgcolor='#E3E1E1'><font class='bodytext'> <i>• $title</i></td> </tr><tr> <td style='border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px dotted #666633; padding: 4px' width='46%' bgcolor='#EFEDED'> <font class='bodytext'>• $phone</td></tr> <tr> <td style='border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px dotted #666633; padding: 4px' width='46%' bgcolor='#E3E1E1'> <font class='bodytext'>• $email</td> </tr><tr> <td style='border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px dotted #666633; padding: 4px' width='46%' bgcolor='#EFEDED'> <font class='bodytext'>• $url</td> </tr> <tr> <td style='border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px dotted #666633; padding: 4px' width='46%' bgcolor='#E3E1E1'> • <font class='bodytext'><a href='contact.php'>Click here to contact $name</a> </td> </tr> </table> </div> &nbsp;</td> </tr> <tr> <td style='padding: 4px' colspan='2'> <font class='bodytext'>About My Services</td> </tr> <tr><td style='padding: 4px' colspan='2'> <font class='bodytext'>My Specialties</td> </tr> <tr> <td style='padding-left: 0px; padding-right: 0px; padding-top: 4px; padding-bottom: 4px' background='images/bottom.gif' height='37' colspan='2'> <p align='center' class='bodytext'>You can use our <a style='color: #0000FF' href='search.php'>key word search</a> option also.</td> </tr> </table> </div> HTML; } ?> [/code]
  8. It's about 25-40 people max. It's quite possible they could have the same first name but not the same last name/combo. The 'name' field is the main id field, though. Is there a better way to handle this?
  9. Ok, here's the first request for some help :) I'm creating a 'template' and within that template is the code to summon the display of a person's profile. I've created the HTML for the template which consists of a table nested in another table whereas the various fields of the database will be displayed. In the template is the mysql query as well. There's several fields involved in each profile: name title company phone email details specialties image (their photo) Now, when I summon all these, this is what I have so far but don't know if this will work: [code]//need to open database and run query for this person mysql_connect($dbhost, $dbuser, $dbpass) or die('Database has gone bye bye'); mysql_select_db($dbname) or die('Where oh where is that database'); $sql="SELECT * FROM members WHERE name == '$name'"; $results = mysql_query($sql); $num = mysql_num_rows($results);[/code] What I need is for each field to be pulled from the database and then displayed in this HTML that I have set in an echo statement: [code]<div align="center">                   <table border="0" cellpadding="0" style="border-collapse: collapse" width="530">                     <tr>                       <td colspan="2">                       <img border="0" src="images/top.gif" width="530" height="35"></td>                     </tr>                     <tr>                       <td height="15" colspan="2">                       <h2>$name                       </h2>                       </td>                     </tr>                     <tr>                       <td style="padding-left: 10px; padding-right: 10px; padding-top:5px; padding-bottom:5px" width="229" valign="top">$image</td>                       <td style="padding-left: 10px; padding-right: 10px" width="261">                       <div align="center">                         <table border="0" cellpadding="0" style="border-collapse: collapse" width="100%">                           <tr>                             <td style="border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top: 1px dotted #666633; border-bottom-width: 1px; padding: 4px" width="46%" bgcolor="#E3E1E1"><font class="bodytext"><i>                             • $title                             </i></td>                           </tr>                           <tr>                             <td style="border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px dotted #666633; padding: 4px" width="46%" bgcolor="#EFEDED"><font class="bodytext">                             • $phone                             </td>                           </tr>                           <tr>                             <td style="border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px dotted #666633; padding: 4px" width="46%" bgcolor="#E3E1E1"><font class="bodytext">                             • $email                             </td>                           </tr>                           <tr>                             <td style="border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px dotted #666633; padding: 4px" width="46%" bgcolor="#EFEDED"><font class="bodytext">                             • $url                             </td>                           </tr>                           <tr>                             <td style="border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px dotted #666633; padding: 4px" width="46%" bgcolor="#E3E1E1">                             • <font class="bodytext"><a href="contact.php">Click here to contact me</a>                             </td>                           </tr>                         </table>                       </div>                       &nbsp;</td>                     </tr>                     <tr>                       <td style="padding: 4px" colspan="2"><font class="bodytext">                       About My Services</td>                     </tr>                     <tr>                       <td style="padding: 4px" colspan="2"><font class="bodytext">                       My Specialties</td>                     </tr>                     <tr>                       <td style="padding-left: 0px; padding-right: 0px; padding-top: 4px; padding-bottom: 4px" background="images/bottom.gif" height="37" colspan="2">                       <p align="center" class="bodytext">You can use our                       <a style="color: #0000FF" href="search.php">key                       word search</a> option also.</td>                     </tr>                   </table>                 </div>[/code] I'm not 100% the right syntax to make the query pull all fields and then display them in their respective locations in the HTML. Any guidance would be great :)
  10. Ok, I see that and it is a 'string' being passed. Perhaps if he changed this code a bit to: [code]<?php session_start(); if(empty($_SESSION['username']) or empty($_SESSION['id']) or empty($_SESSION['password'])) {//if there is nothing in the session echo 'you are not logged in'; exit;//quit the page so they cant view anything else }else{ echo 'You Are Now Logged In '; echo $username; echo '.'; include ('dbinfo.inc.php'); $sql_1=mysql_query("SELECT * FROM user_buildings WHERE username == '$username' AND password == '$password'"); $result_1=($sql_1); $num_1=mysql_num_rows($result_1); $row_1=mysql_fetch_array($result_1); echo '<br><a href="buildings/mining_depot.php"><img src="images/buildings/mining_depot.png" alt="Mining Depot"></a>'; echo '<br>Level '; echo $row_1['mining_depot']; } ?>[/code] so the 'mysql_query' is set in that string. Just trying to help :)
  11. Your query line needs brackets. Like this: [code]$sql_1=("SELECT * FROM user_buildings WHERE username == '$username' AND password == '$password'");[/code] Otherwise it thinks it's a string. It's not recognizing it as a valid query.
  12. First, thanks to all those who offer help in these forums. You rock. I'm hell bent to learn PHP, bought a book 'Learn PHP in 24 Hours (Sam's)' ... have owned it for 24 months. I've learned more in the past 40 days hanging around here and, through the help of the forum people, online tutorials, etc. and was able to write my first fully functional (and kinda cool may I add) script that featured an admin login, IP tracking, IP banning, page redirection, database connection, data retrieval and display, ability to convert data to CSV format, create a Zip file and download it. Plus a few extras. SO! It IS possible to learn this although it is a challenge! What i've learned is the BEST way to learn is to actually code. SO... i'm starting a new project for a client and wanted to start this thread in order to have a running dialogue for help instead of posting a couple of dozen threads. Hope this is ok. Here's the project outline to start this out. The first step is some guidance on the right way to start and the components. Opinions welcome :) Summary: I have a group of professionals ( doctors, lawyers, indian chiefs ) that have a networking group to promote each other's services. I need to create a system that includes: * category listings of services ( ex: medical, legal, real estate, etc. ) * profiles of each member which includes:   * name, title, business name, email (clickable), url to their personal site (clickable), summary of their business, list of their specialties, photo of the person The category view will be like a link directory just showing the titles of the categories, when clicked on it takes them to a listing view of the contents of that category. These will be a short summary with a thumbnail. The summary will show their name, company name, and specialties then a link to View Full Profile An admin area will need to contain ability to add/edit/delete profiles as well as categories. Beyond that there's not a whole lot the admin has to provide. Therefore it's pretty straight forward. I plan to use a common template for the profiles (just done in HTML and summoned by something like view-profile.php). I've already experiemented with this using another thread for help. I created a simple model of the profile adding as a guide/experience. I need to expand on it to include these additional info items, however, which I can do now that I know how to create the form and parse the data into the database. So, first questions are: 1. Is there a simple way to create the template system or should I just use an HTML template and wrap it in a PHP file to parse it? 2. I am not clear on how to code repititive results into an HTML environment. In other words, what's the best way to display multiple profiles/results in a repetitive display using tables? ( ie: the summary page under the category clicked). 3. This will also need to be paginated so the page doesn't grow a mile long. I'm working through the pagination tutorial (fine work might I add) but just wondered if there's an easier way to integrate it into this project while coding all the other functions. That's it for now. Looking for a bit of guidance on the best way to approach this. I'll be posting code questions as I start bumping into problems. Trying hard to do this myself until I get stuck and then getting help as I go. Thanks in advance!
  13. Just like anything else, your categories need an ID. It could be like: PC Printers Keyboards Monitors or like: CAT1 CAT2 CAT3 or like: 1 2 3 etc. In most shopping carts there's a separate table for category creation containing those ID's. Then, in your product table, you'd have a field for category and reference the proper category ID in that in order to assign the product to the right category. Your while loop would run through the product database and display the products as per category. [code]CREATE TABLE category (   id VARCHAR(80) PRIMARY KEY,   title VARCHAR(80), )[/code] Or something like that.
  14. redarrow, the problem he's having is that when displaying his results to the browser there's a rogue 'm' character showing up. After staring at his posted code until i've gone blind, there's no 'echo m' anywhere. There must be an entry in his database that's causing that character to display. Especially when it's being displayed in the sequence shown: [code]echo '<br><a href="buildings/mining_depot.php"><img src="images/buildings/mining_depot.png" alt="Mining Depot"></a>'; echo '<br>Level '; echo $row['mining_depot'];[/code] The results display as this: [quote]Level  m[/quote] The question he has is WHERE is the 'm' coming from.
  15. Then you couldn't use a line number because the line number could change if the file is modified and added to. So, you'd have to use a key which basically would be the string of text. Can you post an example of what would need to be replaced periodically? Please be as specific as you can with your example including any XML tags (if applicable).
  16. Dohhhhhhhhhh!  That's one of those 'What color was George Washington's white horse?' kinda things Ok, question. Will the data you want to change always be in the same location in the file or will the file constantly be changing in size, lines, etc.?
  17. In order to delete OR append a specific line there needs to be a 'key' or an identifier like a line number. [quote]$key = 'whateveryouwanttoreplace';[/quote] What file type is it?
  18. Below are the three basic ways to open a file and the corresponding character that PHP uses.     * Read: 'r' Open a file for read only use. The file pointer begins at the front of the file.     * Write: 'w' Open a file for write only use. In addition, the data in the file is erased and you will begin writing data at the beginning of the file. This is also called truncating a file, which we will talk about more in a later lesson. The file pointer begins at the start of the file.     * Append: 'a' There are additional ways to open a file. Above we stated the standard ways to open a file. However, you can open a file in such a way that reading and writing is allowable! This combination is done by placing a plus sign "+" after the file mode character.     * Read/Write: 'r+' Opens a file so that it can be read from and written to. The file pointer is at the beginning of the file.     * Write/Read: 'w+' This is exactly the same as r+, except that it deletes all information in the file when the file is opened.     * Append: 'a+' This is exactly the same as r+, except that the file pointer is at the end of the file. Open a file for write only use. However, the data in the file is preserved and you begin will writing data at the end of the file. The file pointer begins at the end of the file.
  19. Actually it doesn't matter the name of the field or table. The echo statement is displaying whatever it contains. And, apparently, it contains an 'm' in there somewhere. Not sure what else to tell you except echo means echo. :)
  20. Ok, now that we have that clear :) I know PHP can do a lot of things. But, displaying a character without a source or some code that creates that character is not one of them. If that's all you code (meaning that there's no other parts to this that you haven't displayed) then the only reasonable solution is that your database table being called either contains an 'm' or a set of characters that the browser is interpreting as an 'm'. Your code has these echo statements in it: [code] echo 'you are not logged in'; echo 'You Are Now Logged In '; echo $username; echo '.'; echo '<br><a href="sumthin/summit_else.php"><img src="images/summit/summit_else.png alt="Summit Else"></a>'; echo 'Level '; echo $row['summit_else']; [/code] If we go through these we note that none of them have an extra 'm' in them. Unless, of course, something to do with your encryption is causing this display. But, ruling that out, all of the echo statements are very straight forward. The only one we don't know the results of is the last one summoning the $row since it comes from the database. If there's an 'm' being echoed then it has to be coming from somewhere in that table since, according to your posts, the rogue 'm' is being displayed right after the word 'Level ' which indicates the last echo statement would be the logical choice.
  21. Ok, is it an M or an S ?? Seems to change with each post  ???
  22. The only logical explanation is that this query: [code]echo $row['summit_else'];[/code] has a field or entry with an 's' in it. Otherwise there's nothing else in your posted code that echo's an 's'.
  23. Ok, cool. So, to be perfectly clear, you stated this: [quote]basically im tryin to make it so that the page displays the number in the summit_else field after level. prob it-all it displays is "Level s" which makes me think its echoing the s from summit_else.[/quote] I can't see where it's pulling a stray 's' from but this line needs a closing " after your .png [code]<img src="images/summit/summit_else.png alt="Summit Else">[/code]
×
×
  • 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.