adman4054 Posted April 7, 2014 Share Posted April 7, 2014 I've searched Google and can quite get this to work after hours of searching. I'm trying to use an unordered list. Like this: <ul id="demoOne" class="demo"> <li class="ln-_" style= "display: none;"> <a href="#"> 411 Services </a> <li> <li class="ln-a;"> <a href="#"> Adams </a> <li> <li class="ln-z;"> <a href="#"> fake </a> <li> </ul> Using this code, I cant get the <UL> to only appear once in the code. Can I still use "echo" when trying to use the above? while($company = mysql_fetch_array($query)) { echo "<tr><td width='125' class='bodyTxt'>". $company['t2'] ." </td><td class='bodyTxt'><a href='CompanyContact.php?companyID=".$company['t2']. "'class='adminLink'>" . "<li>" . $company['t1'] ." </li></a></td></tr>"; As shown in the above code, I need $company[t1] to be the list itself (<li>company a </li> under the <ul> as shown in my first code block.) $company [t2] is just a number and needs to appear with [t1], but isn't part of the <li> list. Any help is appreciated Thanks Query include("../inc/conn.php"); //$query = mysql_query("SELECT company.companyName t1, company.companyID t2, companycontact.contactID t3 from company, companycontact where company.companyID=companycontact.companyID ORDER BY company.companyName"); $query = mysql_query("SELECT company.companyName t1, company.companyID t2 from company ORDER BY company.companyName"); $num_rows=mysql_num_rows($query); Quote Link to comment https://forums.phpfreaks.com/topic/287580-and-using-php/ Share on other sites More sharing options...
Ch0cu3r Posted April 7, 2014 Share Posted April 7, 2014 411 Services, Adams and fake are example of companies? and you want all companies returned from your query to be in an unordered list? and not a table? Quote Link to comment https://forums.phpfreaks.com/topic/287580-and-using-php/#findComment-1475228 Share on other sites More sharing options...
davidannis Posted April 7, 2014 Share Posted April 7, 2014 I'm not sure that I understand the question, but I think what you want is: echo '<ul class=...."';//note outside while loop while($company = mysql_fetch_array($query)) { echo "<li> <a href=\"#\" >" . $company['t1'] ." </li></a>\n"; } echo '</ul>';//note outside while loop Quote Link to comment https://forums.phpfreaks.com/topic/287580-and-using-php/#findComment-1475229 Share on other sites More sharing options...
adman4054 Posted April 7, 2014 Author Share Posted April 7, 2014 That makes perfect sense. It isn't working, but its doing exactly what I needed it to do. Thank you both for responding. Quote Link to comment https://forums.phpfreaks.com/topic/287580-and-using-php/#findComment-1475234 Share on other sites More sharing options...
cyberRobot Posted April 7, 2014 Share Posted April 7, 2014 Note that the close </a> tag needs to go inside the close </li> tag. <?php echo '<ul class=...."'; while($company = mysql_fetch_array($query)) { echo "<li><a href=\"#\">" . $company['t1'] . "</a></li>"; //<-- NOTE: close </a> tag was moved inside the close </li> tag } echo '</ul>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/287580-and-using-php/#findComment-1475238 Share on other sites More sharing options...
adman4054 Posted April 7, 2014 Author Share Posted April 7, 2014 So when I look at the source when putting the code outside the loop, it says "Start <ul> inside a table.." in red, so I assume I need to place that outside the table that Ch0cu3r was asking? The entire page is "tableized" (dont think that is a real word, but......). any place else I put it, it doesn't start with the <ul> I'm using a jquery called ListNav and it isnt picking up the structure that it needs to work; ul id="demoOne" class="demo"><li class="ln-_" style= "display: none;"> <a href="#"> 411 Services </a> <li><li class="ln-a;"> <a href="#"> Adams </a> <li><li class="ln-z;"> <a href="#"> fake </a> <li></ul> So do I need to somehow get rid of the tables for this to work? Appreciate the time Quote Link to comment https://forums.phpfreaks.com/topic/287580-and-using-php/#findComment-1475239 Share on other sites More sharing options...
adman4054 Posted April 7, 2014 Author Share Posted April 7, 2014 Thank you cyberRobot! Quote Link to comment https://forums.phpfreaks.com/topic/287580-and-using-php/#findComment-1475240 Share on other sites More sharing options...
Ch0cu3r Posted April 7, 2014 Share Posted April 7, 2014 You have not answered my question in my previous post. It is not possible to have a <ul> list that spans multiple table cells and rows at the same time. Quote Link to comment https://forums.phpfreaks.com/topic/287580-and-using-php/#findComment-1475245 Share on other sites More sharing options...
adman4054 Posted April 7, 2014 Author Share Posted April 7, 2014 Sorry Ch0cu3r, I wasn't aware the you cannot have a <ul> list in tables, but that makes sense. I do have the list within multiple tables, I'll try and sort that out. appreciate your post, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/287580-and-using-php/#findComment-1475248 Share on other sites More sharing options...
Ch0cu3r Posted April 7, 2014 Share Posted April 7, 2014 No, no you can have a list within a table, along as it is in a table cell (<td></td>). <table> <tr> <td> text <ul> <li>item 1</li> <li>item 2</li> </ul> </td> </tr> .... </table> The way how you are describing your problem is you're wanting the list to do something like this <ul> <table> <tr> <td> text <li>item 1</li></td> </tr> <tr> <td> another <li>item 2</li></td> </tr> </table> </ul> Which you cant do. Quote Link to comment https://forums.phpfreaks.com/topic/287580-and-using-php/#findComment-1475251 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.