Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

do this if 1

Status
Not open for further replies.

digatle

Technical User
Oct 31, 2003
85
US
I'm having trouble with one piece of my php code. My problem is I have this routeen:

---
print &quot;<select name=\&quot;app\&quot; style=\&quot;font-size: 10px\&quot; onChange=\&quot;location=document.jump.app.options[document.jump.app.selectedIndex].value;\&quot; value=\&quot;GO\&quot;>&quot;;
print &quot;<option value=\&quot;application\&quot;>Applications</option>&quot;;
while ($a_row = mysql_fetch_array( $applications ) ) {
$app_url=$a_row['url'];
$app_title=$a_row['description'];
print &quot;<option value=\&quot;$app_url\&quot;>$app_title</option>&quot;;
}
print &quot;</select>&quot;;
---

What I need it to do though is to show this <select></select> if there is something there. If there isn't anything there I don't want anything to show up. But I can't write the code without saying &quot;select&quot; with nothing in it.

Help :)

Digatle
 
let me see if i got your point, if your query doesn't return any application you don't want the <select> do show up ? just use a

Code:
if (mysql_num_rows($application) != 0) {


// that code here


}

that way if there are 0 applications the print code will be avoided

jamesp0tter,
jamespotter@netcabo.pt

p.s.: sorry for my (sometimes) bad english :p
 
Yeah I want it so if the results are 0 that it does not perform the <select> option. I'll try this and let you know, thank you!!
 
I just tried the code and got the following error:

Notice: Undefined variable: application in /var/ on line 41

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/ on line 41


if (mysql_num_rows($application) != 0) {
print &quot;<select name=\&quot;menu\&quot; style=\&quot;font-size: 10px\&quot; onChange=\&quot;location=document.jump.menu.options[document.jump.menu.selectedIndex].value;\&quot; value=\&quot;GO\&quot;>&quot;;
print &quot;<option>$siteID Applications</option>&quot;;
while ($a_row = mysql_fetch_array( $menubar ) ) {
$menu_url=$a_row['url'];
$menu_title=$a_row['description'];
print &quot;<option value=\&quot;$menu_url\&quot;>$menu_title</option>&quot;;
}
print &quot;</select>&quot;;
}


The if statement is line 41.

Digatle
 
Figured it out. In fact the code works perfectly now. The application wasn't changed to menubar. Perfect!!

Digatle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top