SunQuest
 
           PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old February 21st, 2004, 05:18 AM
Robbo Robbo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 14 Robbo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Using select with PHP

Im trying to use the following functions to create a drop down box populated with information from a table but with a default value aswell.
Im trying trouble as it not outputting the first row of the table and i cant set the default value name although i can get the default id.

Can anyone help??

Code:


function PrintAddressForm($row, $prefix) {
echo "Address Details <br> id=",$row['address_addresstype_id'];
GetCombo('address_addresstype_id','addresstype_tbl ', $row['address_addresstype_id']);
echo "Address Type <br>";
echo "<input type='text' name='",$prefix,"address_housenumber' value =", $row['address_housenumber'],">";
echo "House Number <br>";
echo "<input type='text' name='",$prefix,"address_road' value =", $row['address_road'],">";
echo "Road <br>";
echo "<input type='text' name='",$prefix,"address_city' value =", $row['address_city'],">";
echo "City <br>";
echo "<input type='date' name='",$prefix,"address_county' value =", $row['address_county'],">";
echo "County <br>";
echo "<input type='text' name='",$prefix,"address_postcode' value =", $row['address_postcode'],">";
echo "Post Code <br>";
echo "<input type='text' name='",$prefix,"address_email' value =", $row['address_email'],">";
echo "Email <br>";
echo "<input type='text' name='",$prefix,"address_contactphoneno' value =", $row['address_contactphoneno'],">";
echo "Contact No <br>";

}


function GetCombo($ComboName, $TableName, $SelectedID) {

$query3 = "SELECT * FROM $TableName";
$result3 = mysql_query($query3)
or die ("Could Not Execute Query3");
$row3 = mysql_fetch_array($result3);
echo "<select name=$ComboName>";
while ($row3 = mysql_fetch_array($result3)) {
echo "<option value=",$row3['addresstype_id'];
if ($row3['addresstype_id']==$SelectedID) echo "selected";
echo "\n",">",$row3['addresstype_name'];
}
echo "</select>";
}

Thanks

Reply With Quote
  #2  
Old February 21st, 2004, 08:56 AM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
what exactly do u mean by a default value

Reply With Quote
  #3  
Old February 21st, 2004, 09:02 AM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
and another thing, there should not be any commas before $prefix or after it, so a line should look like this

PHP Code:
echo "<input type=\"text\" name=".$prefix."_address_contactphoneno value=\"$row['address_contactphoneno']\">"


and another question what is adress_contactphoneno are u trying to say the variable is $prefix_$address_contactphoneno or are u trying to say its something like $prefix is your variable and adress_contactphoneno is the rest of it, in that case u can try as it is above

Reply With Quote
  #4  
Old February 21st, 2004, 01:43 PM
Robbo Robbo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 14 Robbo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The idea to to get a members address details from a database for them to be updated so the default should be set to the actual value from the database whilst the rest of the select should be filled with the remaining addresstypes

the prefix is used so if there is more than one address it gives them a different variable value so they can be updated.

Hope this clears it up a bit

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Using select with PHP


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway