Jump to content

New to SQL, do I need a hashmap?


dbchris

Recommended Posts

I'm barely even starting to understand SQL and I can't find this detail anywhere.

 

I'm using MySQL 5.5

 

What I'm trying to do is make something display within a SQL code on my page.

 

I'm trying to make this...

 

<name>

<points>

<location>

<type>

 

Turn into this...

 

Name: <name>

Points: <points>

<location>

<type>

 

So basically...

Name: Orchard

Points: 12

Garden

Brush

 

Putting the text "Name: " before the actual name, and putting "Points: " before the amount of points for this.

 

SELECT name FROM `things` WHERE t_id='$t_id'

SELECT points FROM `things` WHERE t_id='$t_id'

SELECT location FROM `things` WHERE t_id='$t_id'

SELECT type FROM `things` WHERE t_id='$t_id'

 

I was told I could do something like make a hashmap that changes a word from its original text, but I don't know how to do any of that.

 

What would I need?

Link to comment
Share on other sites

Not sure exactly what you mean by:

I was told I could do something like make a hashmap that changes a word from its original text,

but look at Example #1:

http://us2.php.net/manual/en/function.mysql-fetch-assoc.php

 

I can barely even understand that that's the basic form I would need to put on my website to display the MySQL information I'd need to show... other than that, I don't see how I can make something like an ITEM TYPE turn into TEXT....

 

like a mapping that changes "1" to "Point: " and if it's "2" it would change the 2 to "Points: " and display that where the <points> section is in my original example above.

 

Same as if I wanted to change 'thistype' to actually display on the site "This type is: " and change 'thattype' to display "That type is: "

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.