Jump to content

rabadaba

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rabadaba's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am working on my first PHP - My Sql website. I am just starting to get into the data development and I find it quit tedious and slow to use Php MyAdmin to enter data. Note there is no data source - I need to create and enter data from the keyboard. What would be ideal is to have some sort of editor to allow me to copy / paste etc to move data creation along quickly. My ideal set up would be to have the data in Excel, edit it and then load it to the data base. My web host service does not aloow me to upload excel files. I have had all sorts of trouble trying to upload a CSV file. Please help if there is a simple free solution. Thanks, Adi
  2. I am a newbie at php. Is there a function that will let me delete an element of an array? Lets say I have an array: array1("AAA","BBB","CCC","DDD","EEE","FFF") Note that the array will not have multiple elements with the same content. Then lets say get a response from the user that selected : "CCC" I want to delete that content out of the array - thus the resultant array should be : array1("AAA","BBB","DDD","EEE","FFF") or if the user selected "AAA" the result should be: array1("BBB","CCC","DDD","EEE","FFF") (assuming the user did not select "CCC" first)
  3. I am working on my first shopping cart and I need the following: I need to compare if a newly selected item has already been added to my cart using a SESSION variable. What is the best way to compare a variable delimited using ',' and not add the new item if it already exist. I don't need you to formulate code - just help out with the function that compares variable contents. i.e. if my SESSION variable contains 'AAA,BBB,CCC,DDD' and the user selects a second CCC which is not a valid selection for this state, how do I figure that out? Thanks
  4. Thanks for your help. You got it right!!! Also note that I fixed the additional row problem. It was due to the location of the $image_out =''; being set outside the loop. Great help. Appreciate it!
  5. I have just stared to get my first PHP- MySQL code working. I have a couple of odd behaviours occurring. Note that I have replicated this problem on two systems - one my own PC and also on my host provider system and the results are identical - thus my issues are related to my code or DB structure. 1. On one table - I lost the first row in my results - so I created a row of id=0 and other null fields and then the results looked correct. The 'zeroth' id did not display in my results which looks correct - but the coding is dropping the first entry and I want to know why. Code is below (note that I place the results into an array since I need to run a query twice: mysql_select_db($database_dsStockPhotoTree, $dsStockPhotoTree); $query_rsSidebar = "SELECT * FROM sidebar ORDER BY id ASC"; $rsSidebar = mysql_query($query_rsSidebar, $dsStockPhotoTree) or die(mysql_error()); $row_rsSidebar = mysql_fetch_assoc($rsSidebar); $totalRows_rsSidebar = mysql_num_rows($rsSidebar); $rsSidebarArray = array(); while($row = mysql_fetch_array($rsSidebar, MYSQL_ASSOC)) { $rsSidebarArray[] = $row; } and in another section ..... $sidebar = ''; foreach($rsSidebarArray as $rowNum => $row) { if ($row['subtitle'] == '1') // means it is a sidebar title i.e. not an <a> tag {$sidebar .= '<li class="subtitle">'.$row['name'].'</li>'."\n"; } elseif ($row['id'] == $sel_id) // means it is the current page and we want to set class = current {$sidebar .= '<li><a class="current" href="http://www.stockphototree.com/category.php?id=' . $row['id'] .'">' .$row['name'] .' == >></a></li>'."\n"; } else {$sidebar .= '<li><a href="http://www.stockphototree.com/category.php?id=' . $row['id'] . '">' . $row['name'] . '</a></li>' . "\n"; } // means a normal menu item } echo $sidebar; =================================== 2. In my second query - I get an extra result. The first row comes in twice in the results??? Can't have that happen! mysql_select_db($database_dsStockPhotoTree, $dsStockPhotoTree); $query_rsImages = "SELECT * FROM images ORDER BY id ASC"; $rsImages = mysql_query($query_rsImages, $dsStockPhotoTree) or die(mysql_error()); $row_rsImages = mysql_fetch_assoc($rsImages); $totalRows_rsImages = mysql_num_rows($rsImages); $sel_id = $_GET['id']; and in another section ...... $row = ''; $image_out = ''; while($row = mysql_fetch_array($rsImages, MYSQL_ASSOC)){ if ($row['cat_id'] == $sel_id) // the cat_id for the images row matches the the current page category 'id' {$image_out .= '<div id="border"><a href="xxx.php"><img src="images/' . strtolower($row['imageCode']) . '/' . $row['thumbFile'] . '.jpg" width="'; $image_out .= $row['thumbWidth'] . '" height="' . $row['thumbHeight'] .'" border="0" alt="Image: ' . $row['imageCode'] . '-'. $row['imageNum']; $image_out .= '" onMouseOver="showtrail(\'images/'; $image_out .= strtolower($row['imageCode']) . '/' . $row['dispFile'] . '.jpg\', \'' . $row['imageTitle'] . '\', ' .$row['dispHeight'] .');" onmouseout="hidetrail();" ><p class="pcaption">Image: '; $image_out .= $row['imageCode'] . '-' . $row['imageNum'] . '</p><p>' . $row['imageTitle'] .'</p></a></div>' . "\n"; } echo $image_out; } Any help on the missing and duplicated results would be appreciated.
  6. If I don't use the id field for order.... how do I control the order my categories are pulled from the database. I need some field that has a ordered order. What is the proper structure to follow to allow me to oder the category table?
  7. Thanks for your input. It is very useful for a newbie like me. On your last point about deleting a category... I may have a need to add a category in the future and the new category will probably not be at the bottom. Thus I am planning on writing a query (when the time comes) to shift the category table to allow for the insert of the new category item in the proper ('id') order. I will also have to change all the affected 'cat_id's in the content table to match. Any hints on how to set up properly for such an event?
  8. My webiste is quite simple. I am using table names - so there are many other fields but that it not my question. All 'content' items can only belong to only one category. Thus I take the best solution is to add a 'cat_id' field to the content table...
  9. I am new to php - MySQL and need help in defining a proper robust structure for data to be shred between two tables. The first table is the 'category' table, which contains 'id', 'Element X', 'Element Y' etc. I am using the 'id' as the logical category because it ties in well. The second table is the 'content' table with its own 'id' (not related to the category table) 'ElementA' ElementB' etc. My question - I need to link the two tables. Should I: 1. Add a field to the 'category' table to tie to one of the Elements in the 'content' table or 2. Add a field to the 'content' table to tie each row to its parent 'category' 'id'? What makes the most efficient use of coding and structure and why?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.