Closed Thread Icon

Topic awaiting preservation: MySQL Table output (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=12657" title="Pages that link to Topic awaiting preservation: MySQL Table output (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: MySQL Table output <span class="small">(Page 1 of 1)</span>\

 
Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 03-18-2003 13:00

Ok guys...here's the scoop. While I'm off in the land of the faeries, I've been working on some PHP/MySQL projects, and one of them requires me to output a table from my database in a certain way. The systme itself will partially be used to book pieces of equipment for certain times of the day, and also to show the times when equipment isn't booked. The table will basically list all the pieces of equipment down the side (The 'equip' field in the table) and then listed the periods of the day accross the top. I know that I can get PHP to echo out the fields with data in them, but I also need to it echo out the fields with nothing in them. If the fields don't have anything in them, it will need to display a 1x1 transparent GIF and stretch it to fit the table. This way, when the table's displayed the user can click on the empty fields in order to book them.

At the moment I'm mostly just typing out an idea that I have, but if anyone else has any thoughts I'll read them the next time I get back online.



DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 03-18-2003 14:16

Well, when you make your query, and use (presumably) mysql_fetch_array() to get your results into PHP, set a variable for each field.

say the name of your field is "time_of_day" and you set a variable to be $time_of_day.

then, you throw a little if statement -

if (empty($time_of_day)) {
$time_of_day = "<img src=\"my_gif.gif\" />";
}

or what have you.

Depending on how data is entered into the database, you may also have to check for a value of "NULL" as well as an empty value.




Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 03-18-2003 15:50

be warned, when you use mysql_fetch_array, and a field in the current row is null, it won't be set in the array.

the usual idom for this is

while ($aRow = mysql_fetch_[row

« BackwardsOnwards »

Show Forum Drop Down Menu