jamesreno20
-
Posts
9 -
Joined
-
Last visited
Posts posted by jamesreno20
-
-
Add each less than or greater than condition separately. Example
SELECT ref,artist,composer,genre,title,album,label,price,description FROM music WHERE price >= 3 AND price <= 8
Or use a BETWEEN clause
SELECT ref,artist,composer,genre,title,album,label,price,description FROM music WHERE price BETWEEN 3 AND 8
i need the numbers to be input from the user do you know how to do this
-
hi im trying to use query to select from a table where the price is between to values that the user has to input such as min of 3 and max of 8 and return all the fields from the database where it is true im unsure how to do this but this is what i have so far
$res = pg_query ($conn, "SELECT ref,artist,composer,genre,title,album,label,price,description FROM music WHERE price = < && > ");echo "<table border='1'>";echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>"; -
i have checkboxes on the database page and if checked they send to the shopping basket i have the items selected to display but like this
Array ( [0] => Imagine DragonsImagine DragonsRockI Bet My LifeKIDinaKORNER1.25Brand new single from the incredible Imagine Dragons )
i want it to be like thishere is my code
____________________________________________________________________
database.php
<form name="test" method="post" action="shoppingbasket.php" >
$res = pg_query ($conn, "SELECT ref,artist,composer,genre,title,album,label,price,description FROM music");echo "<table border='1'>";echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th> <th>Price</th><th>Description</th></tr>";while ($row = pg_fetch_row($res)){echo "<tr>";echo '<td><input type="checkbox" name="check_list[]" value="'. $row[1]. $row[2]. $row[3].$row[4].$row[5].$row[6].$row[7].$row[8].$row[9].'"></td>';for ($column = 1; $column < pg_num_fields($res); $column++){echo "<td>" . $row[$column] . "</td>";}echo "</tr>";}echo "</table>\n";?><input type="submit" value="Submit" >__________________________________________________________________________-shppingbasket.php<?phpprint "<pre>";print_r($_POST['check_list']);print "</pre>";?> -
i have checkbox in a table and want to put the value as the id in the database then when i press submit it displays all the row data for each checkbox$res = pg_query ($conn, "SELECT artist,composer,genre,title,album,label,price,description FROM music");echo "<table border='1'>";echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>";while ($row = pg_fetch_row($res)){echo "<tr>";echo '<td><input type="checkbox" name="check_list[]" value="' . $row['res'] .'"></td>';for ($column = 0; $column < pg_num_fields($res); $column++){echo "<td>" . $row[$column] . "</td>";}echo "</tr>";}echo "</table>\n";________________________________________________--basket.phpecho "<table border='1'>";echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>";echo "<pre>\n";print_r($_POST['check_list']);echo "</pre>\n";
-
it doesnt ouput anything im not sure how you get the values from each row from teh checkbox to display to the basket
-
so i have my database form which you can select a some data using the checkbox and when submitting it should get the row info and display it on the next page iv been struggling for days on this and cant work out how to do it please could i have some help
<form name="test" method="post" action="shoppingbasket.php" >
<input type="submit" value="Submit" ><?php$conn = pg_connect("host=db.dcs.aber.ac.uk port=5432dbname=teaching user=csguest password=r3p41r3d");$res = pg_query ($conn, "SELECT artist,composer,genre,title,album,label,price,description FROM music");echo "<table border='1'>";echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>";while ($row = pg_fetch_row($res)){echo "<tr>";echo '<td><input type="checkbox" name="check_list[]" value="' . $row['ref'] . $row['artist'] . '"></td>';for ($column = 0; $column < pg_num_fields($res); $column++){echo "<td>" . $row[$column] . "</td>";}echo "</tr>";}echo "</table>\n";___________________________________________________________________________________________________shopping basket.php<?phpecho "<table border='1'>";echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>";if(!empty($_POST['check_list'])){foreach($_POST['check_list'] as $row){echo "$row was checked! ";}}?></form></body></html> -
database.php
________________________________________________________________________________________
$res = pg_query ($conn, "SELECT artist, composer, genre, title, album, label, price, description FROM music");
echo "<table border='1'>";
while($a = pg_fetch_array($res)){
echo "<td>" . $a['1'] . "</td>";
echo "<td>" . $a['2'] . "</td>";
echo "<td>" . $a['3'] . "</td>";
echo "<td>" . $a['4'] . "</td>";
echo "<td>" . $a['5'] . "</td>";
echo "<td>" . $a['6'] . "</td>";
echo "<td>" . $a['7'] . "</td>";
echo '<td><input type="checkbox" name="music[]" value="$ref"' . $row['0'] . $row['1'] . $row['2'] . $row['3'] . $row['4'] . $row['5'] . $row['6'] . $row['7'] . '"/></td>';
echo"</tr>";
}
echo "</table>\n";
?>_____________________________________________________________________________-
shoppingbasket.php
_____________________________________________________________________________-
<form action="shoppingbasket.php" method="POST">
Send To Basket: <name="music">
<input type="submit" value="submit">
</form>cant get it to send data from database to this page shoppingbasket.php
if(isset($_POST['music'])){
if (is_array($_POST['music'])) {
foreach($_POST['music'] as $row){
echo $row;
}
} else {
$row = $_POST['music'];
echo $row;
}
} -
database.php
$res = pg_query ($conn, "SELECT artist, composer, genre, title, album, label, price, description FROM music"); echo "<table border='1'>"; while($a = pg_fetch_array($res)){ echo "<td>" . $a['1'] . "</td>"; echo "<td>" . $a['2'] . "</td>"; echo "<td>" . $a['3'] . "</td>"; echo "<td>" . $a['4'] . "</td>"; echo "<td>" . $a['5'] . "</td>"; echo "<td>" . $a['6'] . "</td>"; echo "<td>" . $a['7'] . "</td>"; echo '<td><input type="checkbox" name="music[]" value="$ref"' . $row['0'] . $row['1'] . $row['2'] . $row['3'] . $row['4'] . $row['5'] . $row['6'] . $row['7'] . '"/></td>'; echo"</tr>"; } echo "</table>\n"; ?> <form action="shoppingbasket.php" method="POST"> Send To Basket: <name="music"> <input type="submit" value="submit"> </form>
cant get it to send data from database to this page shoppingbasket.php
if(isset($_POST['music'])){ if (is_array($_POST['music'])) { foreach($_POST['music'] as $row){ echo $row; } } else { $row = $_POST['music']; echo $row; } }
jquery help
in Javascript Help
Posted · Edited by cyberRobot
Surrounded code with [code][/code] tags