Jump to content

Recommended Posts

Being brand new to PHP I am trying to put together a simple script that will allow users to select "this or that" by simply clicking on an image link. The URL format I was thinking would work is:

vote.php?winner=4321&loser=1234

4321 and 1234 would be the id's of each available link that would update the database by 1 in the win or loss column. So far I know to add this would be:

add($row_name['wins'], 1)

How do I assign this variable and allow it to pass to mysql? I assume it would be something like:

Code:

$winner = add($random_rows[1]['wins'], 1)

How can I pass that to the db though? Hope this question makes sense.
Link to comment
https://forums.phpfreaks.com/topic/33407-passing-variable-to-sql-help/
Share on other sites

Thanks that worked!  Now the next question though. I am generating random id's from the database by using:

[code]
$sql = "SELECT id, name, wins FROM users ORDER BY rand() LIMIT 2";
$sql_result = mysql_query($sql);


// if records present
if (mysql_num_rows($sql_result) > 0)
{
    // iterate through resultset
    // print
while ($row = mysql_fetch_array($sql_result)) {
  $random_rows[] = $row;
}
[/code]

How do carry the variables from the previous page to the current?  Meaning if I click a link how do I take the previous pages randoms and apply them onto the new page? Basically I want to be able to display the results of the previous poll while displaying a new poll.

I guess basically I am having a tough time trying to figure out how to set the vote.php?winner=1234&loser=4321 variable within the url and take those results and pass them onto the next page. I know if this was a form I could use the $_POST data to accomplish this. Instead I just want the link to pass the data. This make any sense?

Thanks again for the help.
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.