2 Replies - 147 Views - Last Post: 01 February 2012 - 08:39 AM Rate Topic: -----

Topic Sponsor:

#1 blitzfx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-August 09

Generating multiple buttons

Posted 31 January 2012 - 10:10 AM

Hi,

I'm not sure how to word this but I'll start off with some code I have:
$result = mysql_query("SELECT * FROM Music") or die(mysql_error());  
while($row = mysql_fetch_array($result))
{
echo htmlentities($row['Title']);
echo htmlentities($row['parta']);
echo htmlentities($row['partb']);
echo htmlentities($row['partc']);
echo "<p>";
}

This outputs to a html page.
I have another php script which accepts multiple variables

I want to be able to generate a (radio)/submit button at the end of each iteration of the while loop that will send the data from $row['parta'], $row['partb'] etc. to my other php script using post (get is too small).

I was thinking that maybe I could generate forms with 4 un-editable textareas with $row['parta'] etc displayed in it or something and submit using post but then I got lost.

Previously with the other script, I had it using GET and working as:
<?p
...
...
 echo "<a href=\"[url]/myscript.php?a=$row['parta']&b=$row['partb']\">Link</a>";
...
?>


Not sure if my description was clear enough, but thats what I needed to change.

Is This A Good Question/Topic? 0
  • +

Replies To: Generating multiple buttons

#2 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 876
  • View blog
  • Posts: 2,250
  • Joined: 15-February 11

Re: Generating multiple buttons

Posted 31 January 2012 - 10:41 AM

One submit button would suffice. The radio button would only need the ID of the row. All the information shown such as Title, parta, partb etc are for the users.

You're radio button after generated could look like this
<input type="radio" name="music" value="ROW_ID"> The ROW_ID is simply the primary key of your Music table. Within the script that accepts the form submission you would then get the value of the music radio button.
$value = $_POST['music'] //name of our radio button
Don't worry about all your radio buttons having the same name. This just let's the browser know that you can only select one radio button at a time. To get the information again a query with a WHERE condition will work.
SELECT * FROM Music WHERE ...


So you see you don't need to send parta and partb to the other script. The primary key should work just fine.
Was This Post Helpful? 1
  • +
  • -

#3 blitzfx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-August 09

Re: Generating multiple buttons

Posted 01 February 2012 - 08:39 AM

Thanks,

I managed to get what I needed with that bit of info :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1