Solved

How would I do this?

Posted on 2013-02-01
2
221 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 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
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
Comment Utility
Thanks, Ray. I was able to get it done using explode, but I'll take your advice on the htmlentities too.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now