Jump to content

radio button


paulus4605

Recommended Posts

In a form a I have a radio button where the user has to answer the question if his/her dog has a vaccination against hepatitis yes/no

I have a table in my db where all the vaccination types are stored and hepatitis has vaccination_id 3.

 

this value is stored in a session and when I check with print_r($_session) I get my value y or n for the given radio button so far so good.

Now I have to retrieve from my db the right id for hepatitis.(which should have as outcome 3)

first I create an if to see if $_SESSION is Y

so I created this code

<?php session_start();
mysql_connect("127.0.0.1", "root", "pass")or die("cannot connect");

mysql_select_db("tobysplace")or die("cannot select DB");

print_r($_SESSION);
if($_SESSION['hepatitis'] === 'y'){
echo "uw hond is ingeent tegen hepatitis";
}
else {
echo "Uw hond moet ingeent tegen hepatitis zijn voordat hij bij ons binnen komt";
}

this test works like a charm

now I want to run this query $sql = "SELECT vaccination_id FROM `vaccination` WHERE vaccination_name =\'hepatitis\'"; which gives me the value 3 in return.

the next part would be to change the exsisting "y" to 3 and store this id in my table dog_vaccination by doing an insert into that given table.

however I am not able to achieve this.

I tried it with this

<?php session_start();
mysql_connect("127.0.0.1", "root", "pass")or die("cannot connect");

mysql_select_db("tobysplace")or die("cannot select DB");

print_r($_SESSION);
if($_SESSION['hepatitis'] === 'j'){
$query=mysql_query("select vaccination_id from vaccination where vaccination_name=\'hepatitis\'");
$_SESSION['carre'] = $query;
}
else {
echo "Uw hond moet ingeent tegen hepatitis zijn voordat hij bij ons binnen komt";
}

but in this case it's only printing the query without giving me the actual id?

 

what am I missing here?

Link to comment
https://forums.phpfreaks.com/topic/245085-radio-button/
Share on other sites

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.