English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm looking for some PHP code, that will display my table results in random areas (chosen by me) in a page. For instance, I have my user enter a URL of their picture and hit post. When they check they're page, they see their picture. (I already know how to do this), but what I'm having trouble with...is like getting their name to display on the page, and their favorite foods, etc. Here's what I have so far:

$result = mysql_query("SELECT id, url FROM contact WHERE id = '$idno'");
$imgres = mysql_fetch_row($result);
?>

appropriate alt





This is only the picture. There are other fields on my database such as name, age, favorite foods, etc. I want these things to display as well...how do I do that?

2006-09-18 13:13:33 · 4 answers · asked by detroitkid17 2 in Computers & Internet Programming & Design

4 answers

OK, here is your query:

SELECT id, url FROM contact WHERE id = '$idno'

Note that it retrieves only two fields (id and url) per record from the database. When you use mysql_fetch_row() on the result obtained by executing this query, it returns an array of two values, numbered 0 and 1. If you have more fields in the query, there will be more values in the array returned by mysql_fetch_row().

Alternatively, you could use mysql_fetch_array(), which would allow you to refer to fields by name:

$result = mysql_query ("SELECT id, url FROM contact WHERE id = '$idno'");
$imgres = mysql_fetch_array ($result);
echo $imgres['url'];

Read the PHP Manual's section on MySQL:

http://www.php.net/mysql

__________

2006-09-19 07:51:09 · answer #1 · answered by NC 7 · 0 0

The default way of pulling records in php is a bit too complex for a newcomer. Check to see if you have installed Adodb, http://adodb.sourceforge.net/

adodb works for most databases that you will run into with php, and the code is much more readable, which will make it easier for you to catch up with it.

A nice side-effect of this is that if you ever switch to asp or asp.net you will notice most of the database calls are very similar, adodb was written this way on purpose.

2006-09-18 13:34:29 · answer #2 · answered by veraperezp 4 · 0 0

There is a sample source code about database access in this site: http://smartcoder.awardspace.com
Go to the PHP category and check the 'Accessing MySQL' sample.


KaBalweg
http://smartcoder.awardspace.com

2006-09-18 16:35:12 · answer #3 · answered by dabsani 3 · 0 0

have you tried doing it by going into Powerpoint, then your charts box

2006-09-18 13:17:38 · answer #4 · answered by Nadine P 1 · 0 1

fedest.com, questions and answers