Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How would I do this?

Posted on 2013-02-01
2
Medium Priority
?
233 Views
Last Modified: 2013-02-02
I have a pull down menu that features the full name of a student. The list is based off of a query where I'm just listing all the students and coupling their first and last name as a string (<?php echo stripslashes($first_name).' '.stripslashes($last_name); ?> I need to process that name by breaking it apart and grabbing the id attached to that row that contains both the first name and the last name.

So, I'm thinking that there's some php magic that allows me to break apart the name and then do a select query where it's "select id from students where first_name='$something' and last_name='$something_else'";

What?
0
Comment
Question by:brucegust
2 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 38845685
For starters, stripslashes() is not the right function to use before echo sends the browser output.  You want htmlentities() to avoid sending evil JavaScript commands to the client browser.

Probably your query is looking for the student names in a table that also contains an AUTO_INCREMENT PRIMARY KEY column, right?  Why not SELECT all three columns in the query?

If you want to post the CREATE TABLE statement we can probably give you a query that will get all the fields you need in a single trip to the data base engine.
0
 

Author Comment

by:brucegust
ID: 38846652
Thanks, Ray. I was able to get it done using explode, but I'll take your advice on the htmlentities too.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question