GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Sep-2009, 21:15
sjcosh sjcosh is offline
New Member
 
Join Date: Sep 2009
Posts: 2
sjcosh is on a distinguished road
Smile

Newbi Help please


Can someone please help with the below code.

PHP Code:

<tr>
    <td>Application:</td>
    <td><select name="application">
        <option value="<?php echo $appid; ?>"><?php echo $appname;?></option>";
<?php
//for each row we get from mysql, echo a form input
while ($row = mysql_fetch_array($rsapps)) {
echo "<option value=\"$row['`Application Code`']\">$row['`Application Description`']</option>\n";
}
?>
</select></td>
</tr> 


I know you should not have spaces in the field names of a mysql table but i didn't design the database so I'm stuck with it.

I'm getting an error on this line of code

Code:
echo "<option value=\"$row['`Application Code`']\">$row['`Application Description`']</option>\n";

Any help would be fantastic.

Thanks.
Last edited by admin : 29-Sep-2009 at 01:54. Reason: Please insert your example PHP codes between [PHP] and [/PHP] tags
  #2  
Old 29-Sep-2009, 07:52
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Newbi Help please


I don't think the back-ticks are necessary, they are probably NOT included with the column name, and that could be causing trouble. Having the column name between the single quotes should be enough.

To see what information you are getting, simply do a print_r() on each $row inside the while loop.
PHP Code:

print_r($row);  // inside the loop. This will show the column => value pairs for each row. 



EDIT:
Also, there appears to be a stray double-quote after the </option> tag before the loop.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
Last edited by TurboPT : 29-Sep-2009 at 08:24.
  #3  
Old 29-Sep-2009, 19:17
sjcosh sjcosh is offline
New Member
 
Join Date: Sep 2009
Posts: 2
sjcosh is on a distinguished road

Re: Newbi Help please


Thanks for a push in the right direction, but the only way i could get it to work was to create 2 variables and asign the field names to the variables, then put the variables in the loop.

If i put the field names in there with the spaces i kept getting syntax errors.

Thanks
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:36.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.