Jump to content

form with POST and blank spaces


timecut

Recommended Posts

hi guys, need bit of help with my script if u can. i've a db "album" with a field 'band' and more fields for details bout every single album of this band. in my index page i have a form that show all the bands in my db and, between brackets, how many album each. the user can select the band clicking the name in the form and i linked it to a band.php page where i receive the name of the band select with the method post. it's workinf if the band has a name with no blank spaces (ex. ministry) but not if the name is composed (ex.nine inch nails). well, i echoed the var that i post and it came out just 'nine' (for the previous example). anyone has got any idea of what's goin' on? i'm not so good in php so maybe is a basic error!!!

thanx a lot

???

Link to comment
https://forums.phpfreaks.com/topic/41963-form-with-post-and-blank-spaces/
Share on other sites

yeah, know what u mean but i'd like to keep the form showing the correct name of the band. if i trim the name before storing it into the db, then the form is gonna show it all together (ex.nineinchnails).

thanx anyway for ur kindness. do u know any other way?

 

thanx a lot guys but the id is more related to the albums. the band name is a field that is repeated in the database: i can have 2 albums by "nine inch nails" so i can't collect the just of the band. to make it more clear i'll show you my database structure:

 

  `id_p` int(11) default NULL auto_increment,

  `band` varchar(100) default NULL,

  `title` varchar(100) default NULL,

  `cover_image` varchar(100) default NULL,

  `short_description` varchar(255) default NULL,

  `complete_description` longtext,

  PRIMARY KEY (`id_p`)

 

hope it can be more clear if u'r still up to give me an help.  bout the double quotes, i use this code in my index page to recall the name band (and the script item just shw how many albums...between brackets):

 

<form method=post action=band.php><select name=band style="font-size: 9 px; font-family: arial; background-color:B8AF9E" size="1">

      <option selected>Select a band</option>

      <?php

      include("config.php");

      mysql_connect($host,$user,$password)or die("can't conect");

      mysql_select_db("$xxxx")or die("can't connect to the db");

      $dati=mysql_query("select distinct band from album");

      $numofrows=mysql_num_rows($dati);

      while($array=mysql_fetch_array($dati)){

      echo"<option value=$array[band]>$array[band]";

      $a=$array[band];

      item($a);echo"</option>";

  }

      ?>

      </select><input type=submit value=go style="font-size: 9 px; font-family: arial; font-weight: bold">

      </form>

 

 

dont no if this would work but the idear is to get the id from the select

 

statement then search the database for that band from the like statement.

 

<?php

$db=mysql_connect("localhost","username","password");
mysql_select_db("database_name",$db);

$query1="select id,bands from music where ".$_GET['id']." LIKE "%bands%" ";
$result1=mysql_query($query1) or die(mysql_error());

while($c=mysql_fetch_assoc($result1){

echo" ".$c['band_name']." <br> ".$c['music_playing']." <br>";

}

echo"<form method='POST' action''>";
echo"<select name='bands'>";

$query2="select id,bands from music";
$result2=mysql_query($query2);

while($x=mysql_fetch_assoc($result2)){

echo"<option value='".$x['id']."'>".$x['bands'],"</option>";
}
echo"<br>";
echo"<input type='submit' name='submit' value='Get The Band'>";

echo"</select>";
echo"</form>>";
?>

i see what u mean... it's probably the best method to do that. if i understood properly i should create a simple table where i've all the bands with an id. on my album database i can recall the band's id instead of the real name and print it on the screen with blank spaces cuz i query on the id instead of the name. is it what ur code suggest, isn'it?

:)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.