Jump to content


Photo
- - - - -

Yet another mysql issue...


  • Please log in to reply
2 replies to this topic

#1 Madar

Madar

    SCRiPT KiDDie

  • Members
  • 26 posts

Posted 21 November 2005 - 10:37 PM

Hello again,

I'm trying to rebuild my website to draw data dynamically out of a database (mysql) and I'm at a bit of a roadblock (because I have know idea what %$#@ I'm doing :) ). I'm sure this must be easy enough to do but the logic evades me so I'm hoping someone here can help get me pointed in the right direction. Basically the situation is as follows:

My website http://www.nakedpresident.com has a table grid of cells with each cell holding five pieces of information (call_name, call_text, alt_text, call_photo, and call_audio). I have set up a database that holds the info for each of these cells along with an “id” number for each entry (the five pieces of cell data).

I am off to a pretty good start (or at least it feels that way) in that I am able to extract info from the DB as a group of stings: $call_name, $call_text, etc for the first cell on the page. I can plug these strings into the first cell and they appear to work, hurray! :) The problem (for me) is that I have many cells to fill in and I'm not really sure what the most efficient way would be to get the strings out of the DB for each successive cell. Do I need to make a separate “SELECT FROM” statement for each cell to get the strings that are tied to each successive “id” number? This seems very inefficient to me. Also the individual strings have the exact same names and I'm beginning to think that this might be somehow bad. Anyway, I'm totally lost as to what to do next. If anyone out there has any ideas or could point me to a good example of how something like this should work that would be really fantastic.

Thanks in advance,

Madar

#2 LogosX

LogosX

    rekcah-rebÜ

  • Moderating Team
  • 728 posts
  • Location:305

Posted 22 November 2005 - 11:53 AM

Try something like this

while (list($call_name, $call_text, $alt_text, $call_photo, $call_audio) = mysql_fetch_row($result)) {

//whatever you want to do with the data here

}


#3 Madar

Madar

    SCRiPT KiDDie

  • Members
  • 26 posts

Posted 23 November 2005 - 03:25 AM

Hey LogosX,

I found a pretty decent tutorial for building a php/mysql blog here http://www.clearps.c...ng-a-weblog.php and I've been using some code much like what you have purposed. It's slow going but I'm beginning to see real progress. Now I just need to rethink my page layout as the dual column table is proving difficult to populate. I'm thinking to use LIMIT to pull ids 2-8 into one CSS div and make a second call for entries 9-15 to go in a second div (or something like that). This is proving to be a major pain in the butt but hey manually rewriting the page for new content was a bigger pain and offered a major zero in learning factor column :)

Thanks for the assist,

Madar

Try something like this

while (list($call_name, $call_text, $alt_text, $call_photo, $call_audio) = mysql_fetch_row($result)) {
//whatever you want to do with the data here
}

View Post






BinRev is hosted by the great people at Lunarpages!