•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 403,363 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,278 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 323 | Replies: 3 | Solved
![]() |
•
•
Join Date: Oct 2007
Location: Penang Island, Malaysia
Posts: 170
Reputation:
Rep Power: 1
Solved Threads: 2
php Syntax (Toggle Plain Text)
<?php // connect to database include("inc/connect.php"); // include auth and nav //include("inc/auth.php"); // begin content //include("inc/nav.php"); // close mysql connection //mysql_close(); // Check if the form has been submitted. if (isset($_POST['Submit'])) { $brandC = $_POST['brandC']; $typeC = $_POST['typeC']; $styleC = $_POST['styleC']; $frameC = $_POST['frameC']; $groupSetC = $_POST['groupSetC']; $errors = array(); // Initialize error array. //If they did not enter a search term we give them an error if (($brandC == "") AND ($typeC == "") AND ($styleC == "All") AND ($frameC == "") AND ($groupSetC == "")) { $errors[] = 'You did not select anything.'; } //If user only enter Bicycle Brand elseif (($brandC!="") AND ($typeC=="") AND ($styleC== "All") AND ($frameC== "") AND ($groupSetC== "")) { $result = mysql_query("SELECT * FROM cycles WHERE brand='$brandC'"); } //If user only enter Bicycle Type elseif (($brandC="") AND ($typeC!=="") AND ($styleC== "All") AND ($frameC== "") AND ($groupSetC== "")) { $result = mysql_query("SELECT * FROM cycles WHERE type='$typeC'"); } //If user only enter Bicycle Frame elseif (($brandC="") AND ($typeC=="") AND ($styleC == "All") AND ($frameC!== "") AND ($groupSetC== "")) { $result = mysql_query("SELECT * FROM cycles WHERE frame='$frameC'"); } //If user only enter Bicycle GroupSet elseif (($brandC="") AND ($typeC=="") AND ($styleC== "All") AND ($frameC== "") AND ($groupSetC!== "")) { $result = mysql_query("SELECT * FROM cycles WHERE groupSet='$groupSetC'"); } if (empty($errors)) { // If everything's OK. echo "<table border=1 style='color:blue'>"; echo "<tr>" ; echo "<td align=center style='color:red'>CID</td>"; echo "<td align=center style='color:green'>Brand</td>"; echo "<td align=center style='color:red'>Type</td>"; echo "<td align=center style='color:green'>Style</td>"; echo "<td align=center style='color:red'>Model</td>"; echo "<td align=center style='color:green'>Gear No</td>"; echo "<td align=center style='color:red'>Frame</td>"; echo "<td align=center style='color:green'>Group Set</td>"; echo "<td align=center style='color:red'>Price</td>"; echo "<td align=center style='color:green'>Release Date</td>"; echo "</tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>" ; echo "<td align=center>".$row['cycleID'] ."</td>"; echo "<td align=center>".$row['brand']."</td>"; echo "<td align=center>".$row['type']."</td>"; echo "<td align=center>".$row['style']."</td>"; echo "<td align=center>".$row['model'] ."</td>"; echo "<td align=center>".$row['gearNo']."</td>"; echo "<td align=center>".$row['frame']."</td>"; echo "<td align=center>".$row['groupSet']."</td>"; echo "<td align=center>".$row['price']."</td>"; echo "<td align=center>".$row['releaseDate']."</td>"; echo "</tr>"; } echo "</table>"; exit(); } // End of if (empty($errors)) IF. mysql_close(); // Close the database connection. } // End of the main Submit conditional. if (!empty($errors)) { // Print any error messages. echo "<h1 style='font-family:Calibri; color:red; text-align:center'>Error!</h1> <p style='font-family:Calibri; color:#0066FF; text-align:center'>The following <span style='color:red'>error(s)</span> occurred:</p>"; foreach ($errors as $msg) { // Print each error. echo " <h5 style='font-family:Calibri; color:orange; text-align:center'> - $msg</h5>\n"; } //echo '</p><p>Please try again.</p>'; echo "<h4 style='font-family:Calibri; color:green; text-align:center'>Please try again....</h4> <br> <p style='font-family:Calibri; color:#0066FF; text-align:center'>You will now be returned to the find Cycle page again. <span style='color:red'>Please follow the rules!</span></p> <META HTTP-EQUIV=\"refresh\" content=\"3; URL=findlist.php\"> "; } // Create the form. ?>
Only the 1st and the 2nd condition working rest not working.
error msg:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\cycle\find.php on line 72.
"I might not be the BEST but I'm not like the REST!"
•
•
Join Date: Apr 2006
Posts: 66
Reputation:
Rep Power: 3
Solved Threads: 11
use $result = mysql_query($sql) or die (mysql_error());
if you have an error in your query it won't be executed and this is why you get that message.
if you have an error in your query it won't be executed and this is why you get that message.
•
•
•
•
#
//If user only enter Bicycle Type
#
elseif (($brandC="") AND ($typeC!=="") AND ($styleC== "All") AND ($frameC== "") AND ($groupSetC== ""))
Or better yet, use
php Syntax (Toggle Plain Text)
elseif(empty($brandC) && !empty($typeC) && empty($frameC) && empty($groupSetC))
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Help! Do/while loop isn't working! (C++)
- For loop problem (Java)
- problem with do...while loop (C++)
- for loop not working right (C++)
- Please help, while loop wont end (C++)
- Number Loop (C++)
- problem with loop back (Networking Hardware Configuration)
- Help with gui loop. (C)
- Not working properly.. (Java)
Other Threads in the PHP Forum
- Previous Thread: PHP codes to search MySQL
- Next Thread: Looking for experienced PHP programmer for online sim game.


Linear Mode