Php Homework help...

Discussion in 'Software' started by mars4bb, Apr 23, 2004.

  1. mars4bb

    mars4bb Private E-2

    I am doing a project for PHP. I've gotten everything working except trying to run a search of the database. The assignment says it wants this.

    [font=Verdana, Arial, Helvetica, sans-serif](4) p4-getresult.html: Create another HTML form called p4-getresult.html. This form will accept data from 1 text box -- name. It sends the name requested to the next PHP file.[/font]

    [font=Verdana, Arial, Helvetica, sans-serif](5) p5-theresult.php: Create another PHP file called p5-theresult.php. This file should accept the data from p4-getresult.html and, using a MySQL query, pull the data from the WEBPAGE database and display it on the page. You will need to use the WHERE command in conjunction with the LIKE command such as described on page 226 in the textbook. The WHERE command will specify the name field to match up with the name specified in the form above -- p4-getresult.html. Use the FOR() function to pull all of the web sites listed in the database having the same name.[/font]

    okay...I've done both pages and this is my code for the query on the p5-theresult.php

    mysql_select_db('student');
    $query = "select * FROM webpage WHERE name Like ".$name." order by name";
    $result = mysql_query($query);


    $num_results = mysql_num_rows($result);

    I didn't get a result at all using this...nor do I get an error...any suggestions on what I can change. The database field name is NAME and the text box field name on p5 is $name. Any help would be greatly appreciated!!!
     
  2. Kodo

    Kodo SNATCHSQUATCH

    I don't know PHP but I can tell you this. Naming a field in the database "NAME" is a VERY bad idea. Lots of times it's a reserved word. I suggest renaming the field and altering your code accordingly and trying it to see if that was the issue.
     
  3. goldfish

    goldfish Lt. Sushi.DC

    I'm presuming you've actually echoed out whats in $results... using the for loop as suggested...? And also that youve connected to the DB. I think the error could be in the for loop.. or youve missed a ; somewhere
     
  4. mars4bb

    mars4bb Private E-2

    I agree with you about the name of the field, but our prof. created the database and we can just insert and pull information out of it so I can't do anything about that part. I'm connected to the database and echoing everything right...gonna check again and see maybe if it's just a type-o somewhere since I'm not getting an error...by the way...the ASP project we had got canceled due to server problems. All that time spent down the drain, but I guess that's the way things go sometimes. I'm also taking a class in ASP.net...b/w just standard ASP and ASP.net which do you think would be more worth while in focusing on?
     
  5. goldfish

    goldfish Lt. Sushi.DC

    .NET is probably the way forward... but the only applications ive seen publically is the microsoft website and hotmail. Apparently people use it for intranet applications as well... (Kodo knows more about this than me).

    I attended a small .NET seminar about a year ago, where they showed us how fantastic it was compared to VB 6. Seemed faster (and smaller files...), and the infrastructure of how it works seems like a good idea, but currently i dont think its that well implemented... i.e. you need to download a sorta add-on redist in order to run the programs that use it, and the assembly it creates isnt anything like optimised, as its intereacting with the framework all the time. But thats just my view.
     
  6. Kodo

    Kodo SNATCHSQUATCH

    ASP.NET for sure.. but you REALLY need the Visual Studio to do anything in such a way that it's organized and quickly developed. Writing code-behind and trying to manage all the pages as well is just suicidal..
     
  7. mars4bb

    mars4bb Private E-2

    Hey yall...thanks for the help...I got it to working...in the query I wasn't putting the field name in single quotes like '.name.' but finally got it to working and made a 108% on the project...bonus for creativity...thanks again!!!
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds