daviddoria 334 Posting Virtuoso Featured Poster

I'll start a new thread since this is way off the original topic now. Thanks for answering the original question :)

daviddoria 334 Posting Virtuoso Featured Poster

Great - the stopped the collapsing margins. There is another overflow problem though - the gray background is larger than the screen - i.e. scroll bars (the real browser scroll bars) appear even though the content is not long enough to warrant them.

Thoughts?

daviddoria 334 Posting Virtuoso Featured Poster

Ok, I removed that "float:left" from ul.dropdown and it is centered now. HOWEVER, the <br /> after the menu does not seem to be working again - the text starts on the same line as the menu. I tried adding a <div> after the menu as well, but that didn't push the text down either. Any thoughts?

daviddoria 334 Posting Virtuoso Featured Poster

Very strange - it was hidden (commented) in chrome but I indeed saw 2 in firefox! I removed the div one so now you will see the one I attempted to center via the UL tag that is still not centered:

http://ewh.ieee.org/r1/schenectady/New/

Also, those were good things to know about the overflow property, but I still don't get what I'm doing wrong. With the overflow auto, the scrollbar appears when I don't think it should. Without the overflow auto, the margin of the whitebox is not applied (i.e you can't see any blue at the top). Is there a better way to stop the collapsing margins besides the overflow property?

daviddoria 334 Posting Virtuoso Featured Poster

I was told to add the overflow: auto to the bluegradient in order to fix the collapsing margins. You can see now that the whitebox is at the very top of the bluegradient even though there is a top margin on the whitebox. If you have a better way to fix that, I'm all ears.

Thanks for your help on all of these issues,

David

daviddoria 334 Posting Virtuoso Featured Poster

One of them is commented - this should be what you see:

<!--
  <div style="margin-left: auto; margin-right: auto; text-align:center; width: 50%;">

    <ul id="nav" class="dropdown dropdown-horizontal">
      <li><a href="./">Home</a></li>
      <li><span class="dir">Events</span>
	<ul>
	  <li><a href="Events.php">Upcoming Events</a></li>
	  <li><a href="Calendar.php">Calendar</a></li>
	  <li><a href="News.php">News</a></li>
	  <li><a href="Newsletters.php">Newsletters</a></li>
	  <li><a href="Volunteers.php">Call for Volunteers</a></li>
	</ul>
      </li>
      <li><span class="dir">Who We Are</span>
	<ul>
	  <li><a href="Whoweare.php">Executive Committee</a></li>
	  <li><a href="Societies.php">Societies</a></li>
	  <li><a href="AwardNominations.php">Award Nominations</a></li>
	  <li><a href="Bylaws.php">Bylaws</a></li>
	</ul>
      </li>
      <li><span class="dir">Member Benefits</span>
	<ul>
	  <li><a href="Jobs.php">Job Opportunities</a></li>
	  <li><a href="Discounts.php">Discounts</a></li>
	  <li><a href="Links.php">Links</a></li>
	  <li><a href="Videos.php">Video Library</a></li>
	</ul>
      </li>

    </ul>
  </div> <!-- end center -->

    <ul id="nav" class="dropdown dropdown-horizontal" style="margin-left: auto; margin-right: auto; text-align:center; width: 50%;">
      <li><a href="./">Home</a></li>
      <li><span class="dir">Events</span>
	<ul>
	  <li><a href="Events.php">Upcoming Events</a></li>
	  <li><a href="Calendar.php">Calendar</a></li>
	  <li><a href="News.php">News</a></li>
	  <li><a href="Newsletters.php">Newsletters</a></li>
	  <li><a href="Volunteers.php">Call for Volunteers</a></li>
	</ul>
      </li>
      <li><span class="dir">Who We Are</span>
	<ul>
	  <li><a href="Whoweare.php">Executive Committee</a></li>
	  <li><a href="Societies.php">Societies</a></li>
	  <li><a href="AwardNominations.php">Award Nominations</a></li>
	  <li><a href="Bylaws.php">Bylaws</a></li>
	</ul>
      </li>
      <li><span class="dir">Member Benefits</span>
	<ul>
	  <li><a href="Jobs.php">Job Opportunities</a></li>
	  <li><a href="Discounts.php">Discounts</a></li>
	  <li><a href="Links.php">Links</a></li>
	  <li><a href="Videos.php">Video Library</a></li>
	</ul>
      </li>

    </ul>

We would have seen two menus if there were two UL's, no?

daviddoria 334 Posting Virtuoso Featured Poster

Thanks, I removed the erroneous /p tag. However, you were right that that didn't affect the UL. I changed it to:

<ul id="nav" class="dropdown dropdown-horizontal" style="margin-left: auto; margin-right: auto; text-align:center; width: 50%;">

but you can see that it is left justified:
http://ewh.ieee.org/r1/schenectady/New/

David

daviddoria 334 Posting Virtuoso Featured Poster

Hm, I see

body
{
height: 100%;
/*overflow: scroll;*/
}

I had to do that because apparently the 80% on the bluegradient doesn't work unless the parent (body) also has a height.

daviddoria 334 Posting Virtuoso Featured Poster

I had tried that but it didn't work.

daviddoria 334 Posting Virtuoso Featured Poster

What are you trying to do? I'll assume simply run something in another thread?

You could use boost threads:
http://programmingexamples.net/index.php?title=CPP/Boost/Threads

or Qt threads:
http://programmingexamples.net/index.php?title=Qt/Widgets/Thread

daviddoria 334 Posting Virtuoso Featured Poster

I got it to work by enclosing the normal <ul> tag inside of a

<div style="margin-left: auto; margin-right: auto; text-align:center; width: 50%;">

I had tried the same thing with p:

<p style="margin-left: auto; margin-right: auto; text-align:center; width: 50%;">

but it didn't work - strange because I thought p and div were both "block" elements?

daviddoria 334 Posting Virtuoso Featured Poster

Ok it's working on the text now. I'm on board with following the new rules, they're just not explained very well sometimes!

Back to the actual problem now - the <center> tags didn't work on the UL object, and neither does the text-align and auto margin method:

<ul id="nav" class="dropdown dropdown-horizontal" style="margin: auto; width:50%; text-align:center;">

You can see the menu is still on the left:
http://ewh.ieee.org/r1/schenectady/New/

Why would it not apply to this object?

daviddoria 334 Posting Virtuoso Featured Poster

Attempt #3... haha

<html>
<body width=100%>

<p>Test heading</p>
<br/>
<p style="margin: auto; width:50%">Test heading</p>

<center><p>Test heading</p></center>

</body>
</html>

This results in a left justified, a weird kind of center/left justified, and then I used center tags to see an actual center justified.

A body with of 100% should be the full page, right? Then what does 50% width for the p mean? We must still be missing something?

daviddoria 334 Posting Virtuoso Featured Poster

I tried this:

<html>
<body>

<p>Test heading</p>
<br/>
<p style="margin: auto;">Test heading</p>

</body>
</html>

Expecting the first one to be left justified and the second one to be centered, but they are both the same (left).

daviddoria 334 Posting Virtuoso Featured Poster

Ah, I changed <p/> to <p>&nbsp;</p> and then it worked as expected. So what does <p/> do then?

Also another thing - the <center> tags around the UL (the menu) don't seem to work (as the menu is not centered) - any thoughts on that?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

On this page:
http://ewh.ieee.org/r1/schenectady/New/

I have the title image and title text:

<center>
<a href="index.php"><img style="vertical-align:middle;" src="/r1/schenectady/images/IEEE.gif"></a>
<span id="lightblue" style="vertical-align:middle; font-size: 40pt;" >Schenectady Section</span>
</center>

then a paragraph break:

<p/>

then a row of drop down lists, then another <p/> then some text.

The problem is that the text is starting on the same line as the drop down lists - should the <p/> cause the text to start below the drop down lists?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

On this page: http://ewh.ieee.org/r1/schenectady/New/

I have two elements, "bluegradient" and "whitebox".

The bluegradient height is 80% (of the page, right?).

The whitebox height is 80% (I think this "80% of the height of the bluegradient" since it is nested, right?). The whitebox has top and bottom margins of 10% (this is 10% of the whitebox height, right?). Therefore the total whitebox should be 80 + 8 + 8 = 96% of the bluegradient height. However, a vertical scrollbar appears on the bluegradient (due to overflow: auto;) - but shouldn't the whitebox be small enough not to warrant this scrollbar?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

Please use code tags when you post code. Also, this doesn't really sound like a c++ question - maybe you should post here:
http://www.daniweb.com/forums/forum71.html

daviddoria 334 Posting Virtuoso Featured Poster

It builds fine for me after I add main:

int main()
{
}
daviddoria 334 Posting Virtuoso Featured Poster

Perfect - thanks!

daviddoria 334 Posting Virtuoso Featured Poster

Ohhhh, I see it now. Is there a way to force a page display the scroll bar even if it isn't long enough to need to scroll? It seems silly that if I click a link from one page that is short to go to a page that is long that the page would shift like this, doesn't it?

David

daviddoria 334 Posting Virtuoso Featured Poster

This is my page with only the header row of the table:
http://ewh.ieee.org/r1/schenectady/New/test2.html

When I start adding rows, everything looks good, until I add row 13. Here is an example:
http://ewh.ieee.org/r1/schenectady/New/test.html

You can see the header (the grey box) "wiggles" just a little bit. I thought there may have been an invalid character or something in the 13th row, but as a test I duplicated the 12th row and the wiggle still happens!

Surely this doesn't have anything to do with the number of rows, but can anyone see what else may be going wrong?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

Excellent - I'm glad it's working, and I'm even more glad you've learned something! Yes, you definitely want to split the code into as many functions as possible (ok, ok, don't go crazy), but more functions typically makes code easier to debug and test.

Also, please mark the thread as solved.

David

daviddoria 334 Posting Virtuoso Featured Poster

The declaration of GetEncoderClsid must come before the definition of gdiscreen() (since gdiscreen() calls GetEncoderClsid). A good practice is to put all of your function declarations right after the includes. Putting it inside main() as you have done doesn't make sense.

daviddoria 334 Posting Virtuoso Featured Poster

If that is your entire program, you are definitely missing main(). From main, it looks like you should call gdiscreen(). The "identifier not found" would be fixed by adding a declaration before you call the function:

int GetEncoderClsid(const WCHAR* format, CLSID* pClsid);

David

daviddoria 334 Posting Virtuoso Featured Poster

You could email the guys in charge: http://sqliteman.com/page/7.html and tell them you are interested in writing this and see if they can point you in the right direction. Sometimes they will give you the best free tutorial you can imagine, sometimes they will yell at you and tell you go to away, and sometimes they will simply ignore you. You have to be prepared for all three scenarios.

daviddoria 334 Posting Virtuoso Featured Poster

I suggest you make a small compilable example. What is the problem? Compiler errors? Crash? Incorrect result?

daviddoria 334 Posting Virtuoso Featured Poster

sudeepjd, yep - that'll do it. You're right, I had typed the code directly in Daniweb and the ? is indeed in the wrong place - just a typo.

Thanks,
David

daviddoria 334 Posting Virtuoso Featured Poster

I have a drop down box like this:

<select name="DateDropDown">
<option value="2010 selected">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
</select>

I use the value that the user selects to refresh the page and perform a query on a database. Is there a better way than the following to keep the drop down box in the correct position?

<php?
echo '<select name="DateDropDown">';
if($MyDate = '2010')
{
echo '<option value="2010 selected">2010</option>';
}
else
{
echo '<option value="2010">2010</option>';
}

... same for each entry ...

</select>
?>

?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

Wow, so silly! I HATE it that an error doesn't get displayed somewhere that I can access it (I only have ftp access). It may also be that php is just one of those languages that doesn't care if you use variable names that aren't defined - which always seemed insane to me.

Thanks for the catch.

David

daviddoria 334 Posting Virtuoso Featured Poster

I have a database, test.db, with a table called Events. I tried this:

<?php
try
{
  // open the database
  $database = new PDO('sqlite:test.db');
  $result = $db->query('SELECT * FROM Events');
  foreach($result as $row)
  {
    // both of these lines produce a blank page
    //echo $row['EventName'] . ' | ' . $row['Location'];
    echo $row;
  }
}
catch(Exception $e)
{
  die('Could not connect to database.');
}
?>

but the resulting page is blank. Can anyone see anything wrong with my syntax?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

How would I go about entering the data into an sqlite database (I want to just have a file, not run a server process). With XML I would just edit a text file, with mdb I would use Access, but surely there is a better way than the command line (which is what I see in all of the tutorials) for sqlite?

Also, what do you mean by "Interoperability" purposes only?

Thanks,
David

daviddoria 334 Posting Virtuoso Featured Poster

Hi all,

I am transitioning a bunch of data from html (yuck!) to some sort of separated schema. I was going to use xml:

<events>
 <event>
  <title>
  <date>
  <speaker>
  <description>
 </event>
</events>

but now I am wondering if I should use a real database instead. Can anyone comment on when it is appropriate to use XML and the difference in the case when you would want to use SQL?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

I actually had to change it to :

$res = $xml->xpath("/bookstore/book[title = '".$_GET["title"]."']");

(added single quotes around the GET part of the command string).

Thanks for all of the help!

daviddoria 334 Posting Virtuoso Featured Poster

@P0lT10n
Thanks for the suggestion. It seems like extra work though to add an id when there is already a unique field for each book.

@rje7
The error seems to happen in the xpath line (when I comment the echo line after it, the 500 error still occurs, then when I comment the xpath line itself, the error goes away).

I was told to drop the ' ' around "title" in your suggestion:
i.e.

$res = $xml->xpath("/bookstore/book[title = $_GET['title']]/author");
$res = $xml->xpath("/bookstore/book[title = $_GET[title]]/author");

(I tried it both ways, both give 500 errors)

My original line ( to get the whole object instead of just the author) also produces the 500 error:

$res = $xml->xpath("/bookstore/book[title = $_GET[title]]");

I did this:

echo $_GET['title']

to make sure the GET is working correctly and indeed it is.

Any more thoughts?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

This works (to display the author of a particular title):

<?php
$xml = simplexml_load_file("bookstore.xml");

$res = $xml->xpath("/bookstore/book[title = 'Everyday Italian']"); 

echo $res[0]->author

?>

So I tried this:

<?php
$xml = simplexml_load_file("bookstore.xml");

$res = $xml->xpath("/bookstore/book[title = $_GET['title']]"); 

echo $res[0]->author

?>

after clicking the link which expands to

bookdetails.php?title="Everyday Italian"

but I get a 500 error.

Did I get something wrong in the GET syntax?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

I got the first part working:

<?php
$xml = simplexml_load_file("bookstore.xml");

foreach($xml->children() as $child)
  {
  echo "<a href=bookdetails.php?title=" . $child->title . ">" . $child->title . "</a> <br/>";
  }
?>

(I believe what I have done is pass a named parameter where the code you posted passed an unnamed parameter - is this correct?)

The above code lists all of the book titles and passes the title as a parameter to the bookdetails.php page.

However, now I need to get the child that has a 'title' that matches the 'title' parameter in bookdetails.php. I don't want to have to iterate through all of the children of the root element and compare their titles to the parameter - there must be a better way :)

Thanks for your help so far!

David

daviddoria 334 Posting Virtuoso Featured Poster

Please excuse my newness. Currently I know how to execute a php script by simply naming the script [filename].php and browsing to that file on my webserver. I have also learned how to parse and display an xml file using php. What I want to do is have a .xml file like:

<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
  <book category="COOKING">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
  </book>
  <book category="CHILDREN">
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
  </book>
</bookstore>

Current I can display all of the information like:

<?php
$xml = simplexml_load_file("test.xml");

echo $xml->getName() . "<br />";

foreach($xml->children() as $child)
  {
  foreach($child->children() as $subchild)
    {
    echo $subchild->getName() . ": " . $subchild . "<br />";
    }
  }
?>

But instead, what I want to do is on one page, say bookstore.html, list all of the book titles. Then if I click on a book title, I want to display a new page with all of the information about that book. The only way I can figure out to do this is to manually make a [booktitle].php for each book, but that is completely defeating the purpose of using xml :)

Can anyone point me in the right direction?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

Thanks Kraai! I actually didn't really follow that tutorial, but from some keywords I found there I found this:

http://www.w3schools.com/xsl/xsl_transformation.asp

which demonstrates the concept very well. This is some awesome stuff!

David

daviddoria 334 Posting Virtuoso Featured Poster

Is there no "built in" function to extract the contents of a tag? This seems like a pretty basic thing to do - if it is no built in, does anyone have a script that I could use?

The goal is to do this:

<html>
...

<a href=...> <Event1 Title> </a>
<a href=...> <Event2 Title> </a>
...
</html>

Where I can have the same "template", a page that displays the <Event N title> and <Event N Body>. I currently have Event1.html, ... EventN.html but it seems silly to have the same code copied over and over in all of the Event*.html pages, so I was trying to have an EventTemplate.html and "pass" it the contents of the Nth event to display (which were extracted from the <titletag> and <bodytag> tags of the "xml" style file.

Any thoughts?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

I want to have files like this:

File1.xml

<titletag>
Title1 goes here
</titletag>

<contenttag>
Content1 goes here
</contenttag>

and then use this data with something like:

<html>
<body>
...

Place <contents of titletag from File1.xml> here

</html>

Is this a reasonable request? How would I do such a thing?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

Check out the insert() and copy() function. There are examples here:
http://programmingexamples.net/index.php?title=CPP/STL/Vector

David

daviddoria 334 Posting Virtuoso Featured Poster

Awesome - you won't always find that, so you got very lucky! Definitely take advantage of this opportunity!

daviddoria 334 Posting Virtuoso Featured Poster

Can you use vectors instead of arrays? Then you get a .size() function :)

daviddoria 334 Posting Virtuoso Featured Poster

My suggestion was to make a graph that you can sanely do the computations by hand. Maybe a graph with 5 nodes or so? If you don't know every step of the solution, your implementation will be almost impossible to debug.

daviddoria 334 Posting Virtuoso Featured Poster

What was your example graph? What is your hand computed solution? What is the programs computed solution?

daviddoria 334 Posting Virtuoso Featured Poster

So what is the problem? Are there compiler errors? Does it crash? Do you get the wrong result?

I suggest hard coding a simple input that you can compute the entire algorithm by hand. Then you can check your programs state every step of the way.

daviddoria 334 Posting Virtuoso Featured Poster

I bet you can demonstrate the same problem in < 30 lines (down from 265 :) )

daviddoria 334 Posting Virtuoso Featured Poster

Nope, if you have a Makefile, all you have to do is type 'make' :)

daviddoria 334 Posting Virtuoso Featured Poster

MylesDBaker,

Is this for a course (where they have made you write your own graph class, etc)? Or because you actually need to use a maxflow algorithm? If it is the later, I would like to suggest that you use an existing graph library (I use vtkGraph from VTK (vtk.org) ). Unfortunately it does not have a maxflow function already, but I've been meaning to write one for a long time, so I'd like to recruit your help!

I have started the infrastructure here:
https://github.com/daviddoria/vtkGraphCut

(which algorithm do you plan to implement?)

If you are interested, please let me know and I'll get you some instructions to compile VTK etc and show you the basics (most of which can be found here: http://www.vtk.org/Wiki/VTK/Examples/Cxx#Graphs )

Thanks,

David

kvprajapati commented: Awesome! +11