Solved

How would I do this?

Posted on 2013-02-01
2
227 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 110

Accepted Solution

by:
Ray Paseur earned 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

733 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