Jump to content

select box + SQL


Possibility

Recommended Posts

I am trying to make a select box that automatically displays and updates the names of the strategies, and when clicked takes you to that respective strat.

 


// Create a table.

print ("<TABLE WIDTH="60%" BORDER=1 BORDERCOLOR=#000000 CELLSPACING=0 CELLPADDING=4 ALIGN=CENTER  class=content>n" );

 print ("<TR ALIGN=CENTER VALIGN=TOP>n" );

 print ("<TD ALIGN=left VALIGN=TOP colspan=2>

  <form action="egyptian2.php" method=post> 

  <select name="Display" id="Display"> 

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

     echo \'<option value="\', $row[God], \'">\' , $row[God], \'</option>\'; 

  } 

  </select> 

  <input type="submit" name="Display" value="Display"> 

</TD>n" );

print ("</TR>n" );

 

Look here:

 

http://www.the-barracks.com/aom/egyptian2.php

 

No strat names are displayed (strat and god are switched around, for some reason)

Link to comment
Share on other sites

Typo in code...

 

CHeck the resulting page source....

 


 <form action="egyptian2.php" method=post> 

  <select name="Display" id="Display"> 

while( = mysql_fetch_array()) { 

     echo \'<option value="\', , \'">\' , , \'</option>\'; 

  } 

  </select> 

  <input type="submit" name="Display" value="Display"> 



 

P.

Link to comment
Share on other sites

<form action="egyptian2.php" method=post> 

  <select name="Display" id="Display"> 

while( = mysql_fetch_array()) { 

     echo \'<option value="\', $row[God], \'">\' , $row[God], \'</option>\'; 

  } 

  </select> 

  <input type="submit" name="Display" value="Display">

 

Doesn\'t work :(

 

Once I fixed the parse errors it still didn\'t show any results.

Link to comment
Share on other sites

When I was displaying the data on a previous system, I would use $Row[God] (not in a select box, just for setting up the title/information of the text results) and it would display properly. I just looked at the source code, and found this where the select box is (even though this doesn\'t show up on the page)

 


<b>Warning</b>:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>/home/the-barr/public_html/aom/egyptian2.php</b> on line <b>38</b><br />

 

Line 38 is:

 

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

 

To put it in context:

 




<table WIDTH="60%" BORDER=1 BORDERCOLOR=#000000 CELLSPACING=0 CELLPADDING=4 ALIGN=CENTER  class=content>





  <tr align="center" valign="top"> 

  <td align="center" valign="top" colspan="2"> 

  <form action="egyptian2.php" method="post"> 

  <select name="Display" id="Display"> 





<br />

<b>Warning</b>:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>/home/the-barr/public_html/aom/egyptian2.php</b> on line <b>38</b><br />



  </select> 

  <input type="submit" name="Display" value="Display"> 

  </td> 

</tr> 

<tr align="center" valign="top"> 

<td align="center" valign="top" colspan="2">Egyptian Strategies</td> 

</tr> 



</table>

 

I have changed the code to this:

 


//... Code above 

?> 



  <tr align="center" valign="top"> 

  <td align="center" valign="top" colspan="2"> 

  <form action="egyptian2.php" method="post"> 

  <select name="Display" id="Display"> 



<?php 



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

     echo \'<option value="\', $row[\'God\'], \'">\' , $row[\'God\'], \'</option>\'; 

  } 



?> 

  </select> 

  <input type="submit" name="Display" value="Display"> 

  </td> 

</tr> 

<tr align="center" valign="top"> 

<td align="center" valign="top" colspan="2">Egyptian Strategies</td> 

</tr> 

<?php 

//..CODE below 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.