NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page [resolved] My next question (PHP)

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 12-03-2007, 05:12 AM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: Apr 2005
Posts: 394
flishess will become famous soon enoughflishess will become famous soon enough
 



My next question (PHP)


I am trying to get the "platforms" listed in my database to show up where "$platform" is at in the drop down box.

Code:
<?
include("config.php");
?>
<html>
<form method="post" action="cp_admin/submitgame.php">

<h3>Title:</h3>
<input type="text" NAME="title">

<h3>Description:</h3>
<textarea name="description" rows="10" cols="48"></textarea>

<h3>Platform:</h3>
<select name="platform">
  <option value="$platform">
</select>
<br>
<br>
<INPUT TYPE="submit" name="submit" value="submit">
</form>
</html>
can anyone help out?
flishess is offline  
Old 12-03-2007, 05:47 AM   #2 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
$platform is not within php tags. It should be:-

PHP Code:
<?PHP echo $platform ?>
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Old 12-03-2007, 06:15 AM   #3 (permalink)
Danltn.com
 
Daniel's Avatar
Join Date: May 2007
Location: Danltn.com / Nottingham, UK
Posts: 1,201
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
 


Ethan Allen Fund Ethan Allen Fund
Is it even set to a variable yet, from the code it doesn't look like it is, unless you set it in config.php.

I'll be on in a few hours if you need help
Daniel is offline  
Old 12-03-2007, 11:35 AM THREAD STARTER               #4 (permalink)
NamePros Regular
Join Date: Apr 2005
Posts: 394
flishess will become famous soon enoughflishess will become famous soon enough
 



here is what I have now, I tried it with GET and POST - neither of the two work.

Code:
<?
include("config.php");
$platform = mysql_real_escape_string($_GET['platname']);
?>
<html>
<form method="post" action="cp_admin/submitgame.php">

<h3>Title:</h3>
<input type="text" NAME="title">

<h3>Description:</h3>
<textarea name="description" rows="10" cols="48"></textarea>

<h3>Platform:</h3>
<select name="platform">
  <option value="<?PHP echo $platform ?>">
</select>
<br>
<br>
<INPUT TYPE="submit" name="submit" value="submit">
</form>
</html>
I think it needs to say something about selecting the row that the table is, or something like that instead of GET or POST.

I also tried this, and it does not work either:
????: NamePros.com http://www.namepros.com/programming/402651-resolved-my-next-question-php.html

Code:
<?
include("config.php");
$platform = $row['platname'];
while($row = mysql_fetch_array( $result )) {
$result = mysql_query("SELECT * FROM platform") 
or die(mysql_error());
?>
<html>
<form method="post" action="cp_admin/submitgame.php">

<h3>Title:</h3>
<input type="text" NAME="title">

<h3>Description:</h3>
<textarea name="description" rows="10" cols="48"></textarea>

<h3>Platform:</h3>
<select name="platform">
  <option value="<?PHP echo $row['platname']; ?>">
</select>
<br>
<br>
<INPUT TYPE="submit" name="submit" value="submit">
</form>
</html>
Last edited by flishess; 12-03-2007 at 11:50 AM.
flishess is offline  
Old 12-03-2007, 12:43 PM   #5 (permalink)
NamePros Member
 
edit's Avatar
Join Date: Nov 2003
Posts: 107
edit will become famous soon enough
 



Code:
$result = mysql_query("SELECT * FROM platform");

while ($row = mysql_fetch_assoc($result)) {

$platform = '<option value="' . $row['platname']. '">';

}
?>

<select name="platform">
<?php echo $platform; ?>
</select>
Not sure if that will work in this situation, as its just off the top of my head but test it out and let me know.
__________________
Complete Resource Management Script - Myspace / Social Network Layout and Graphic Script
Online business lens - My personal experiences in internet business.
edit is offline  
Old 12-03-2007, 03:52 PM THREAD STARTER               #6 (permalink)
NamePros Regular
Join Date: Apr 2005
Posts: 394
flishess will become famous soon enoughflishess will become famous soon enough
 



edit, I don't get any errors with your version, but It doesn't show up either with the platforms.
flishess is offline  
Old 12-03-2007, 06:25 PM   #7 (permalink)
NamePros Member
 
edit's Avatar
Join Date: Nov 2003
Posts: 107
edit will become famous soon enough
 



I actually forgot a pretty important part of that code

Code:
$platform = '<option value="' . $row['platname']. '">';
Should be

Code:
$platform = '<option value="' . $row['platname']. '">' . $row['platname'] . '</option>';
__________________
Complete Resource Management Script - Myspace / Social Network Layout and Graphic Script
Online business lens - My personal experiences in internet business.
edit is offline  
Old 12-04-2007, 11:18 AM THREAD STARTER               #8 (permalink)
NamePros Regular
Join Date: Apr 2005
Posts: 394
flishess will become famous soon enoughflishess will become famous soon enough
 



Edit, that worked, however there are more than one Platforms listed in the database and it only shows the last one.
flishess is offline  
Old 12-04-2007, 01:30 PM   #9 (permalink)
NamePros Member
 
edit's Avatar
Join Date: Nov 2003
Posts: 107
edit will become famous soon enough
 



try adding

Code:
$platform = '';
prior to the while statement. I ran a quick test on this on my home server and all came out ok. If this doesn't work, let me know and I'll continue to troubleshoot.
__________________
Complete Resource Management Script - Myspace / Social Network Layout and Graphic Script
Online business lens - My personal experiences in internet business.
edit is offline  
Old 12-04-2007, 02:47 PM THREAD STARTER               #10 (permalink)
NamePros Regular
Join Date: Apr 2005
Posts: 394
flishess will become famous soon enoughflishess will become famous soon enough
 



Like, this: it didn't work...

Code:
$result = mysql_query("SELECT * FROM platform");
$platform = '';
while ($row = mysql_fetch_assoc($result)) {

$platform = '<option value="' . $row['platname']. '">';

}
?>

<select name="platform">
<?php echo $platform; ?>
</select>
flishess is offline  
Old 12-04-2007, 03:00 PM   #11 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




Try this:

PHP Code:
$result = mysql_query("SELECT * FROM platform");
$platform = '';
while ($row = mysql_fetch_assoc($result)) {

$platform .= '<option value="' . $row['platname']. '">' . $row['platname']. '</option>';

}
?>

<select name="platform">
<?php echo $platform?>
????: NamePros.com http://www.namepros.com/showthread.php?t=402651
</select>
Barrucadu is offline  
Old 12-04-2007, 04:06 PM THREAD STARTER               #12 (permalink)
NamePros Regular
Join Date: Apr 2005
Posts: 394
flishess will become famous soon enoughflishess will become famous soon enough
 



mikor: Thanks that fixed it! Thanks to all those that helped!
flishess is offline  
Old 12-04-2007, 07:20 PM   #13 (permalink)
NamePros Member
 
edit's Avatar
Join Date: Nov 2003
Posts: 107
edit will become famous soon enough
 



There we go, Thanks Mikor I knew I was missing a character somewhere
__________________
Complete Resource Management Script - Myspace / Social Network Layout and Graphic Script
Online business lens - My personal experiences in internet business.
edit is offline  
Closed Thread


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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 08:44 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger