Current location: Hot Scripts Forums » Programming Languages » PHP » Is this possible with PhP & MySQL


Is this possible with PhP & MySQL

Reply
  #1 (permalink)  
Old 04-14-06, 03:15 PM
KeYBLeR KeYBLeR is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Question Is this possible with PhP & MySQL

Hello everyone,
I have setup a MySQL database with 5 feilds. I have made the primiry key thing a number. Is there anyway to do a php command, simlar to INCLUDE. That would include the 5 database feilds into a viewable format with HTML.

Basicly Grabing certain information using a number.

Is this possible?

Thanks Keith
Reply With Quote
  #2 (permalink)  
Old 04-14-06, 05:47 PM
NoMercy's Avatar
NoMercy NoMercy is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Can you add a little more detail for what your asking. I dont' really know what your asking. Do you just want to display information from your MySQL database? I don't really understand what you want.
Reply With Quote
  #3 (permalink)  
Old 04-14-06, 06:03 PM
KeYBLeR KeYBLeR is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

echo("<tr><td align=center width=55px><font class=textsmall>$row[id]</font></td><td width=250px><font class=textsmall>$row[product_name]</font></td><td width=300px><font class=textsmall>$row[product_description]</font></td><td width=100px><font class=textsmall>$row[product_price]</font></td><td width=100px><font class=textsmall>$row[product_weight]</font></td>"); 

Thats how I display information in a database.

Do you see the $row[id]

Is there anyway I can do something like this,
PHP Code:

include("$row[id]"); 

and that will then pull all the values?

Basicly I have a product database, I just add products to the list. I would like to be able to call on a certain product with a number.

Does that make more sense?
Thanks for your time, Keith

Last edited by Christian; 04-16-06 at 12:13 PM. Reason: Please use [PHP][/PHP] when posting PHP code!
Reply With Quote
  #4 (permalink)  
Old 04-14-06, 06:53 PM
Wuiqed Wuiqed is offline
Wannabe Coder
 
Join Date: Aug 2004
Location: Sverige
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
I assume that each product in the database has a unique id, then you can pull the product from the database with a WHERE clause in the query:
PHP Code:

$query  "SELECT * FROM  product WHERE id=1";

 
$result mysql_query($query) or die(mysql_error() ."<br />"$query);
 
$row    mysql_fetch_assoc($result); 
The product with id#1 would the be found in the $row array.
Reply With Quote
  #5 (permalink)  
Old 04-15-06, 08:19 AM
KeYBLeR KeYBLeR is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, I'm at about here with this,

PHP Code:

include("config_settings.php");

$query  "SELECT * FROM `list` WHERE id=2"
$result mysql_query($query) or die(mysql_error() ."<br />"$query); 
$row    mysql_fetch_assoc($result); 

Then I've tryed to echo the $result with no luck

When I echo $row it just says ARRAY

Am I missing something to display the information, or is this mysql script, not pulling information correctly.

Thanks for your time. Keith


PS, Something I just thought of, Someone gave me this code along time ago to SEARCH for a value in the database,

I would use a HTML from to type in the ID number, then submit it to this part of the script.
PHP Code:

$id $_POST['id'];

$result mysql_query("SELECT * FROM list WHERE id='$id'");
if(
mysql_num_rows($result) == 0){echo("No Matches Found");}
while (
$row mysql_fetch_assoc($result)) { 
$id "$row[id]";
$name "$row[name]";
$email "$row[email]";
echo(
"<table align=left cellpadding=0 cellspacing=0><tr><td align=\"center\" width=\"50px\"><font class=textsmall>$row[id]</font></td><td width=\"300px\"><font class=textsmall>$name</font></td><td width=\"350px\"><a href=\"?page=sendemail&sendemail=single&email=$email\"><font class=textsmall>$email</font></a></td><td width=\"100px\"><font class=textsmall><a href=?page=members&members=edit&id=$row[id]>Edit</a> | <a href=?page=members&members=delete&id=$row[id] onClick=\"return confirm('Are you sure to delete $email from the list?');\">Delete</a></font></td></tr></table><BR>");

is this bascily the same thing? Could I use this script I already have.

Thanks again, Keith

Last edited by Christian; 04-16-06 at 12:14 PM. Reason: Please use [PHP][/PHP] when posting PHP code!
Reply With Quote
  #6 (permalink)  
Old 04-15-06, 08:39 AM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
nearly there instead of just echo $row you need to say what you want to echo. that like saying echo database (well more or less)

echo $row['name'];

would echo what you have queried.

hope this helps
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Reply With Quote
  #7 (permalink)  
Old 04-15-06, 08:47 AM
KeYBLeR KeYBLeR is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks everyone, I got this now. I had the answer in front of my face!

Thanks again!
Keith
Reply With Quote
  #8 (permalink)  
Old 04-15-06, 09:50 AM
KeYBLeR KeYBLeR is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Another small question, not worth starting another topic over.

I'm having trouble editing my PRIMARY KEY . Everything will edit just fine in the database, execpt the primary key. I was just wondering if its possible to change the primary key?

Thanks keith
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
Php Mysql Bug??? tranquilraven PHP 4 03-01-06 03:06 AM
Need help with some php mysql TheTinkeringToad PHP 9 02-01-06 10:56 AM
IIS MYSQL and PHP nommiiss PHP 6 01-31-06 04:30 PM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM


All times are GMT -5. The time now is 07:09 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.