My code
Search_restl.php

<html>
<body>
<head>
<font size="3"><strong>
<?php // Connects to your Database 
    mysql_connect("mysq.com", "bd", "pass") or die(mysql_error());
    mysql_select_db("products") or die(mysql_error());
$q = mysql_real_escape_string($_GET['query']);
$data = mysql_query("SELECT * FROM Products where name LIKE '%$q%'")
    or die(mysql_error()); 
    while($info = mysql_fetch_array( $data ))
    { 
echo "Product Name: $info[name]<br>";
echo "Grade A: $info[good]<br>";
echo "Grade B: $info[poor]<br>";
echo "Grade C: $info[faulty]<br><br>";

    } 
    ?>

Prob:
i want that the stored values or price of (Grade A ,Grade B, Grade C) is retrived by RadioButton.
Eg: if i select select Grade A then i get value of Grade A etc

Recommended Answers

All 10 Replies

Any body ??

Is this the extent of your code? Do you have code for a form with the radio buttons? Or are you asking how to create a form for that? The question is a bit vague.

no i didnt have any other code i have one anoter for for radio buttons.
but i didnt have any idea how i implement this in my code??

<input type="radio" id="RadioButton" name="" value="on" style="position:absolute;">

Think about the way you want it to perform before you write any code.

The customer selects a product and is presented with a form to select grade.
Grade is selected and a table is presented with price and ordering info.

Separate the queries.
1st, form with search and search query to retrieve product info.
2nd, form with radio buttons to select grade and query to retrieve that info.

Give all the radio buttons the same name so only one can be selected, and the value is sent to the server for the '$_POST' value.

Hope that helps you to work it out for yourself.

gve me sme example

The form (or part of)

<form name='somename' action='somescript' method='post'>
<input type='radio' name='grade'  value='low'>Low grade<br>
<input type='radio' name='grade'  value='mid'>Mid grade<br>
<input type='radio' name='grade'  value='high'>High grade<br>
<input type='submit' value='Send' />

</form>

and the script (or part of)

<?php
$grade=$_POST['grade'];
$query=mysql_query("SELECT * FROM sometable WHERE grade='$grade'");
while($row=mysql_fetch_array($query)){
$price=$row['price'];
}
echo"You chose".$grade." which is".$price." per qty";
?>

or something similar.
The radio buttons all have the same name, so only one can be selected,
The value is what is sent when the submit is clicked,
The php then fetches the relevant row and column from the db and echos it on screen,
and you can fit that into a table or divs.

bro i new in php stuff can u give me similar example or code .
iry it but no result .

this is my table

id int 32
Pro_name 50 Var
Grade_a 15 Var
Grade_b 15 var
Grade_c 15 var

bro every thing is working
but i want only one change
look out my script

i want there ratiobuxes for Grade A ,Grade B and Grade C
when user click on Grade A they Grade A Value etc.

DB_Table is Products

id int 32
Pro_name 50 Var
Grade_a 15 Var
Grade_b 15 var
Grade_c 15 var

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.