Current location: Hot Scripts Forums » Programming Languages » PHP » Newbie with a problem


Newbie with a problem

Reply
  #1 (permalink)  
Old 03-17-09, 04:38 PM
timcadieux timcadieux is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Newbie with a problem

So, I'm a .Net programmer, I know I know, I apologise in advance :-)

I was building a website for a charity when someone in their organization decided to move their host to a PhP system. A buddy of mine who's supposedly a whiz in PhP told me, 'no problem, he would do it for me and it would be a good learning experience from me. That was about 6 weeks ago and I've gotten about 100lines of code so far, and it's buggy.

Here's the scenario, the site is a Veterans site and has the names and photos of about 125 000 soldiers in a mySQL db. I just need a search page that would have an A-Z type layout and a search button on the last name. Secondly, an Advanced Search with multiple dropdowns, one for each things like Service, Country, Rank etc that would allow the user to narrow the searches.

In .Net I could do that in about 1 day but I'm completely lost in Php, also largely in part because he's using these custom classes he wrote himself to separate the PhP from the HTMl, argh!

If anyone has some pointers, I'm all ears.

Thx in advance!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-17-09, 06:53 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
What you are talking about is not all that hard, and is easily accomplished in about a day (or less).

Once you have the syntax down, it's really very easy.

I would start here at W3Schools(dot)com <-still under 5 post limit.
and pay particular attention to $_POST, Forms, and MYSQL Select.

PHP Code:

<?php
//To help you get started, use:
//Assuming your table looks like:

$table 'soldier';
$column 'lastname';
 
// By using a wildcard (% = Denotes 0 or more characters) 
//we can pull any lastname that starts with this letter.
$pattern 'a%';  //will pull any name starting with letter A.

//To search through a database use LIKE in your queries
$sql "SELECT * FROM $table WHERE $column LIKE '$pattern'";
$query mysql_query($sql);

//loop through the array
while($row mysql_fetch_array($query))
   {
     
// Build your table here;
    //Edit: pull from table using;
       
$lastname $row['lastname'];
   }
?>
Of course, you can change those variables with $_POST from your form. I really see no need for a class (OOP) here, although I do confess of being to lazy to use much. A couple of good functions to pull the data, and a display page is all you should need.

Last edited by Jcbones; 03-17-09 at 06:58 PM. Reason: clarification - I didn't pay attention in Preview
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-21-09, 05:07 AM
timcadieux timcadieux is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
I just wanted to mention that I did take this on myself and its goign well now, thx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
perl newbie has a problem... fowler23 Perl 4 03-24-10 06:14 PM
Newbie With A Problem At Hand alexamag New Members & Introductions 0 09-27-07 06:32 AM
Newbie found a solution to a date problem. mickey_kamer Perl 4 05-09-07 06:54 AM
Newbie PHP problem ^^; Xestrix PHP 5 03-08-07 06:48 PM
Newbie problem with OnClick newwindow and ASP ianric JavaScript 1 11-30-05 06:32 AM


All times are GMT -5. The time now is 12:01 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.