PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 29th, 2000, 01:38 AM
thedude thedude is offline
The Dude Abides
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2000
Location: grass valley,ca
Posts: 1,062 thedude User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 10 h 1 m 34 sec
Reputation Power: 15
Need a little help. I'm trying to print search results from a mysql database. In the results I need the following:
print ("<INPUT TYPE="CHECKBOX" NAME="addit" VALUE="item description^price^1">")

the info in the value area needs to be called from a mysql database. The ^ symbols need to be between each of the mysql results. I've tried a few different methods but none seem to display the results.

Suggestions???

Thanks in advance

------------------
Chris Staniar

Reply With Quote
  #2  
Old February 29th, 2000, 08:22 AM
'tantrum 'tantrum is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 79 'tantrum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Why would u want to put more than 1 results in as the default value for a checkbox anyway?


Basil

Reply With Quote
  #3  
Old February 29th, 2000, 11:45 AM
jodonnell jodonnell is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: durham, nc, usa
Posts: 14 jodonnell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to jodonnell
I am not sure I understand the poster's question. You are having trouble outputting your parse delimiters (^)? or you are having trouble getting proper html output in general?

When I do something like this I am generally in a loop outputting html table rows for (for instance) a shopping cart. I have the results of my SQL query in separate variables (i.e., $sku, $qty, $description, etc.) and use printf with an appropriate format string.
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>printf ("<tr><td><input type=checkbox name="addit[]" value = "%s^%d^">%s</td></tr>n", $description, $price, $description);[/code]

It's freehand, so it may be a little whacky. If so, I'll correct it as soon as I get home, but it should work out and output something like

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre><tr><td><input type=checkbox name=addit[] value = "testitem^2.23^>testitem</td></tr>[/code]

You may want to reexamine the value field, which looks as though you're trying to combine a key with a price. If this info is in your base already, why not just pass the sku number (or whatever)?

Also, If you're dealing with multiple items, be sure to name the checkbox with name = "addit[]" or whatever so that it knows to send PHP an array of items. good luck.

jim


[This message has been edited by jodonnell (edited February 29, 2000).]

[This message has been edited by jodonnell (edited February 29, 2000).]

Reply With Quote
  #4  
Old March 1st, 2000, 12:15 AM
thedude thedude is offline
The Dude Abides
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2000
Location: grass valley,ca
Posts: 1,062 thedude User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 10 h 1 m 34 sec
Reputation Power: 15
Sorry, I should have been more specific. The value of the checkbox needs to be this way in order to pass data to a shopping cart. The ^ symbols break up the data so the shopping cart can utilize the data. The ^ symbols are not going to be printed from the database, only the product description and price.

Where you see description^price these need to be separate values called from a mysql db. Below is a more detailed section of the code.

Thanks


mysql_select_db (chrisdb);

if ($prodname == "")
{$prodname = '%';}

$result = mysql_query ("SELECT * FROM products
WHERE prodname LIKE '$prodname%'
");

if ($row = mysql_fetch_array($result)) {

do {
print ("<TR><TD>");
print ("<INPUT TYPE="CHECKBOX" NAME="addit" VALUE="description^price^1"></TD>");
print ("<TD>");
print $row["prodname"];
print ("</TD><TD>");
print $row["description"];
print ("</TD><TD>");
print $row["price"];
print ("</TD><TD><INPUT TYPE="submit" VALUE="Order"></TD></TR></TABLE>");
} while($row = mysql_fetch_array($result));

} else {print "Sorry, no records were found!";}

Reply With Quote
  #5  
Old March 1st, 2000, 07:46 AM
timbo timbo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 1999
Location: London
Posts: 110 timbo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 26 sec
Reputation Power: 0
the following code should do it, its only a couple of changes to your original...

<?
mysql_connect("whatever");
$result = mysql_db_query ("databasename","SELECT * FROM products WHERE prodname LIKE '$prodname%'");
if ($row = mysql_fetch_array($result))
{
do
{
print ("<TR><TD>");
print ("<INPUT TYPE="CHECKBOX" NAME="addit" VALUE="".$row["0"]."^".$row["1"]."^".$row["2"].""></TD>");
print ("<TD>");
print $row["0"];
print ("</TD><TD>");
print $row["1"];
print ("</TD><TD>");
print $row["2"];
print ("</TD><TD><INPUT TYPE="submit" VALUE="Order"></TD></TR></TABLE>");
}
while($row = mysql_fetch_array($result));
} else {print "Sorry, no records were found!";}
?>

hth

timbo

sorry should have said just replace the "0" "1" etc with whatever your column names are
------------------
cheers


[This message has been edited by timbo (edited March 01, 2000).]

Reply With Quote
  #6  
Old March 2nd, 2000, 12:28 AM
thedude thedude is offline
The Dude Abides
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2000
Location: grass valley,ca
Posts: 1,062 thedude User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 10 h 1 m 34 sec
Reputation Power: 15
Thanks, that worked great!

------------------
Chris Staniar

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > form values

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap