Solved

How would I do this?

Posted on 2013-02-01
2
225 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 109

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

777 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