PDA

View Full Version : Dreamweaver CS5 PHP MySQL dynamic list


Duncan
06-26-2011, 03:08 PM
Hi Guys,

I'm wondering if you could help me out. I can create dynamic lists perfectly and use them to update my cart with the selections customers make, but now i have a sittuation where I may need more than one selection list/menu that changes dynamically based on if the product has more than one option to it.

My question is simply this, can I add logic to my code so that I do not see a selection list on products that does not have any options? I dont want to display empty dropdown lists if they are not required.

Thanks,
Duncan.

jmichae3
06-26-2011, 07:08 PM
if your options are in a mysql table, then yes, most certainly.
the key is mysql_num_rows. it can tell you before fetching rows what the number of rows is.


$resultset=mysql_query("
SELECT *
FROM optiontable
WHERE option_id='12'
ORDER BY OPTIONTEXT ASC
", $link) or die("OOPS!(2) please contact admin@nowhere.com");
if (0 != mysql_num_rows($resultset)) {
echo "<select name=\"somename\">\n";
while ($row = mysql_fetch_assoc($resultset)) {
echo "<option value=\"".$row['optionvalue']."\">".$row['optiontext']."</option>\n";
}
echo "</select>\n";
}
mysql_free_result($resultset);

Duncan
06-27-2011, 02:37 PM
Thank you jmichae... I'll give that a shot today.

Duncan
06-27-2011, 03:08 PM
Well, Id have to admit that I am not a php coder and merely starting to learn it through Dreamweaver CS5.5 that does everything for me... i know its not the best way to learn. At least I'm trying to change or add code now which helps me learn things better...

Here are my two recordsets that I use to first get all the options from the Product ID passed from the products page... then its using that Product ID to gather all the options from the options table. The second recordset is just to add the selected options into it so i could push them to my ecart.

What should I do to this code in the recordset to hide the options dropdown menu/list when there are no options?

$paramItem_rs_Options = "1";
if (isset($_GET['Product_ID'])) {
$paramItem_rs_Options = $_GET['Product_ID'];
}
mysql_select_db($database_testingtopgear, $testingtopgear);
$query_rs_Options = sprintf("SELECT * FROM Product_Options WHERE Product_Options.ProductID = %s", GetSQLValueString($paramItem_rs_Options, "int"));
$rs_Options = mysql_query($query_rs_Options, $testingtopgear) or die(mysql_error());
$row_rs_Options = mysql_fetch_assoc($rs_Options);
$totalRows_rs_Options = mysql_num_rows($rs_Options);

$var_OptionID_rs_SelectedOptions = "-1";
if (isset($_POST['Options'])) {
$var_OptionID_rs_SelectedOptions = $_POST['Options'];
}

Duncan
06-27-2011, 04:56 PM
Actually, I guess I dont need to change my recordsets, rather the source code in my form... here is what I have right now...
<select name="Options" id="Options">
<option value="">Options (If Available)</option>
<?php
do {
?>
<option value="<?php echo $row_rs_Options['ProductOptionID']?>"><?php echo $row_rs_Options['OptionDescription']?></option>
<?php
} while ($row_rs_Options = mysql_fetch_assoc($rs_Options));
$rows = mysql_num_rows($rs_Options);
if($rows > 0) {
mysql_data_seek($rs_Options, 0);
$row_rs_Options = mysql_fetch_assoc($rs_Options);
}
?>
</select>
http://www.dreamweaverclub.com/forum/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA/8AAAD6CAIAAAB4RWAvAAAgAElEQVR4nO3du3Lyuv/+fZ1TOh1KDkCnkeEM1FIww7+meSpVNPTfIdWqPIuZNCud21/5eQrb2lkyhhA28fs1d0GMbMvcbC7LkqW2262IvK0f8A8AAADAP SnSPwAAALAQpH8AAABgKUj/AAAAwFKQ/gEAAIClyNP/YXhiu0uS+vtRRORjnZf8IP2/lr2StZK1eXQ9bqaxopQYJ0aJig7LKFFKlBLbXLdd0UrcjSop9X qWtbb6f7Q/89/3N18QAABwI0n637Zy2MvbWt72Im2S1A+tbNuQ9buS8RLS/721VtZa2qvW3V2btlor+xsmwFtwopQ4EaNE236ZUWJc8mxVI/o+0bNUzytN//e97gvyk7c0AACYp9rz5xCl//djOeuT/h9mr5Kc1FpZD436Phoe9bBwlKiy+Fgu6cLCvZFW5GSGJUrWauo 04KhlrWU32qbf0c6mu1Cyd7KLCk9UPtOI1iIiVoeAG8frxopxY rUoLc707d9xFA7/hlfFF3PZjtLm8671WutRm3pUUuthI+N61hSvz/gXf+/OpP+XfkG6d/KznWECAPCHlNN/F/f7P3fy1ZazPun/AYrxaD9E5JPpU2Nrh4SdPu7E8bFWcqfk5Pc4bH9+2/9+qOTJhFVOw4OjlmMzbNz0uzs2cjJybMpVCucDZ04/un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f63kTsnJV2PY/rjtP9ShdJoBAACABymk//dj6PaTXxAQ+Zi3kPT/KybC9DiCx63yXWQPzfml5v84/RdL1lL+RPoXLgIAAAA8kTz9f5yq0f9tLdu2EPSLC0n/v6W15eG5+3oTu2+8Pxk5NtUtx+m/WPKa9O9o+wcAAHge+ahfORWa9vv7/+zkq51aSPq/k65RP07n42484sJJQnjWTd3YJ+n3XykZjyreD3VItj9cZ5DhAs JptBEAAAA8SJT+d/KVPte36EfL/W1AywtJ//e0i7ru7Mch2yVdd/yzySBdUyi5jkcLZCXjkcRpZ579sNCfD6zV6IQEAAAAD8ZsX6+v 0PAPAAAAFJD+AQAAgKUg/QMAAABLQfoHAAAAloL0DwAAACwF6R8AAABYCtI/AAAAsBSkfwAAAGAp8vR/GJ7wc3i9H0Ppr2MS37dtXpj0DwAAADytJP1vWzns5W0tb3uRNq T/LPT7wsXlpH8AAADgOVV7/hym0//+p9Gf9A8AAADcWTn9vx+HiwBpz5944eGULyT9AwAAAM+skP7fj 6HbT35BQORjLW9r+TiJDI/9QtI/AAAA8Mz+f1sASrQGpZU3AAAAAElFTkSuQmCC

Duncan
06-28-2011, 01:02 PM
I dont think this works for me... does anybody have any other ideas?

jmichae3
06-30-2011, 08:51 PM
you just needed an else in my code for handling the case for no options.

what's the purpose of the mysql_data_seek? mysql_fetch_assoc will fetch always the next record. are you purposely setting the next record to always the first record (0) in the recordset or is that an accident?


<?php

$num_rows = mysql_num_rows($rs_Options);
if (num_rows >= 1) {
?>
<select name="Options" id="Options">
<option value="">Options (If Available)</option>
<?php
while ($row_rs_Options = mysql_fetch_assoc($rs_Options)) {
?>
<option value="<?php echo $row_rs_Options['ProductOptionID']; ?>"><?php echo $row_rs_Options['OptionDescription']; ?></option>

<?php
}
?></select>
<?php
} else {
?><div>--no options--</div>
<?php
}
?>

I personally don't like throwing around a lot of <?php ?> tags in my code. it clutters things up and makes code hard to read.

so instead:



<?php
$num_rows = mysql_num_rows($rs_Options);
if (num_rows >= 1) {
echo "<select name=\"Options\" id=\"Options\">\n";
echo "<option value=\"\">Options (If Available)</option>\n";
while ($row_rs_Options = mysql_fetch_assoc($rs_Options)) {
echo "<option value=\"".$row_rs_Options['ProductOptionID']."\">".$row_rs_Options['OptionDescription']."</option>\n";
}
echo "</select>\n";
} else {
echo "<div>--no options--</div>\n";
}
?>
</span>

\n is a newline.
\" is an escaped double quote that allows you to put a " inside a double-quoted string.
. concatenates (joins) 2 strings together, or a string and a value.
the logic of else for num rows >= 1 is the opposite, which is < 1, and since the value will never go negative, and even if it did we still want it to be handled with the else, the only value left for else is 0, which means no rows in the resultset, which is just what we want for the else. in the else of the if (condition) {dothisiftrue} else {dothisiffalse} statement, the else condition in your case would contain statements that echo html content which would show the user that there is no stuff. it could be another select statement if you wanted, but with an optgroup or option that states that there are no options to select.

an optgroup (html5 only?) has the advantage of having no selectibility! but if you need to return data with the form, then you might want to set an option tag with some sort of "no values" value.

Duncan
07-05-2011, 02:57 PM
Thank you very much for your help jmichae. I'm an absolute noob when it comes to PHP and the code that you see there has been generated by CS5.5 when I create recordsets.

I normally put a default label there "Options if available" and users could click on it if their given product would expect to have options with it it. If not, then you wont see anything in the list. My question was really if there is a way to hid the selection box at all instead of it hanging around and cluttering the page up if there are no options to select anyway for the given product.

I'm not sure if that is possible to blank compress this selection box if there are no values in the recordset so i wont see it at all.

Correct me if I'm wrong but the code above simply checks for values to put in the selection box and does not actually Hides the box if nothing is there.

jmichae3
07-06-2011, 03:30 AM
easy. don't echo anything in the else - you could put in a comment that

<?php
$num_rows = mysql_num_rows($rs_Options);
if (num_rows >= 1) {
echo "<select name=\"Options\" id=\"Options\">\n";
echo "<option value=\"\">Options (If Available)</option>\n";
while ($row_rs_Options = mysql_fetch_assoc($rs_Options)) {
echo "<option value=\"".$row_rs_Options['ProductOptionID']."\">".$row_rs_Options['OptionDescription']."</option>\n";
}
echo "</select>\n";
} else {
//if there is no data,
//display no select box.
//this is just a comment
}
?>

jmichae3
07-06-2011, 03:32 AM
you seriously need to take some programming php and php+mysql tutorials. google them. there are plenty around. just avoid w3schools.com.

Duncan
07-06-2011, 01:04 PM
you seriously need to take some programming php and php+mysql tutorials. google them. there are plenty around. just avoid w3schools.com.

Thank you very much for all your help good sir. I will def. look into some tutorials as you said. Thanks again :)

edbr
07-07-2011, 01:20 AM
you could start by looking at the tutorials on this forum

jmichae3
07-10-2011, 08:34 AM
do you want to HIDE the box, or not generate one? the code I just gave you in the else case does not generate one.

if you want to hide the select box, you would need to figure out what kind of options you want for a select box and display it in the else section using an echo statement or using PHP tags whichever you are more comfortable with. then, to hide it, your else would look like

<?php
$num_rows = mysql_num_rows($rs_Options);
if (num_rows >= 1) {
echo "<select name=\"Options\" id=\"Options\">\n";
echo "<option value=\"\">Options (If Available)</option>\n";
while ($row_rs_Options = mysql_fetch_assoc($rs_Options)) {
echo "<option value=\"".$row_rs_Options['ProductOptionID']."\">".$row_rs_Options['OptionDescription']."</option>\n";
}
echo "</select>\n";
} else {
echo "<select name=\"Options\" id=\"Options\" style=\"display:none;visibility:hidden;\">\n";
echo "<option value=\"\">Options (If Available)</option>\n";
echo "</select>\n";
}
?>


notice the change: I added CSS to hide the select box, and a copy of basically a dummy select box (I don't know what happens if there are no options, no value gets returned or it returns an empty string, one of the two).

Duncan
07-11-2011, 01:19 PM
Yes thanks again, I've figured out how to hide the select box based on your code from earlier. You were a great help!

Duncan
07-11-2011, 01:21 PM
Here's the code i used to just hide if there are no rows.


<label for="Options"></label>
<?php $rows = mysql_num_rows($rs_Options);
if($rows > 0) {
echo "<select name=\"Options\" id=\"Options\">\n";
echo "<option value=\"\">Options</option>\n";
while ($row_rs_Options = mysql_fetch_assoc($rs_Options)) {
echo "<option value=\"".$row_rs_Options['ProductOptionID']."\">".$row_rs_Options['OptionDescription']."</option>\n";
}
echo "</select>\n";
} else {}

?>